mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-09-13 07:54:09 -04:00
KVM: selftests: Return the target CPU from pin_task_to_random_cpu()
When pinning a task to a random CPU, return which CPU the task was pinned to so that the caller can do things like avoid running other tasks on the target CPU. Link: https://patch.msgid.link/20260731195612.2697986-5-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
This commit is contained in:
@@ -1094,7 +1094,7 @@ static inline void pin_task_to_cpu(pthread_t task, int cpu)
|
||||
TEST_ASSERT(!r, "Failed to set thread affinity to pCPU '%u'", cpu);
|
||||
}
|
||||
|
||||
void pin_task_to_random_cpu(pthread_t task, cpu_set_t *possible_cpus);
|
||||
int pin_task_to_random_cpu(pthread_t task, cpu_set_t *possible_cpus);
|
||||
|
||||
static inline int pin_task_to_any_cpu(pthread_t task)
|
||||
{
|
||||
|
||||
@@ -668,7 +668,7 @@ void kvm_print_vcpu_pinning_help(void)
|
||||
" (default: no pinning)\n", name, name);
|
||||
}
|
||||
|
||||
void pin_task_to_random_cpu(pthread_t task, cpu_set_t *possible_cpus)
|
||||
int pin_task_to_random_cpu(pthread_t task, cpu_set_t *possible_cpus)
|
||||
{
|
||||
int target_idx;
|
||||
int nr_cpus;
|
||||
@@ -682,11 +682,12 @@ void pin_task_to_random_cpu(pthread_t task, cpu_set_t *possible_cpus)
|
||||
for (cpu = 0; cpu < CPU_SETSIZE; cpu++) {
|
||||
if (CPU_ISSET(cpu, possible_cpus) && target_idx-- == 0) {
|
||||
pin_task_to_cpu(task, cpu);
|
||||
return;
|
||||
return cpu;
|
||||
}
|
||||
}
|
||||
|
||||
TEST_FAIL("Failed to find random CPU in possible_cpus");
|
||||
return -1;
|
||||
}
|
||||
|
||||
void kvm_parse_vcpu_pinning(const char *pcpus_string, u32 vcpu_to_pcpu[],
|
||||
|
||||
Reference in New Issue
Block a user