Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Drivers: hv: vmbus: Further improve CPU affiliation logic

Keep track of CPU affiliations of sub-channels within the scope of the primary
channel. This will allow us to better distribute the load amongst available
CPUs.

Signed-off-by: Dexuan Cui <decui@microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Dexuan Cui and committed by
Greg Kroah-Hartman
3b71107d 9f01ec53

+19 -2
+18 -2
drivers/hv/channel_mgmt.c
··· 448 448 cpumask_xor(&available_mask, alloced_mask, 449 449 cpumask_of_node(primary->numa_node)); 450 450 451 - cur_cpu = cpumask_next(-1, &available_mask); 452 - cpumask_set_cpu(cur_cpu, alloced_mask); 451 + cur_cpu = -1; 452 + while (true) { 453 + cur_cpu = cpumask_next(cur_cpu, &available_mask); 454 + if (cur_cpu >= nr_cpu_ids) { 455 + cur_cpu = -1; 456 + cpumask_copy(&available_mask, 457 + cpumask_of_node(primary->numa_node)); 458 + continue; 459 + } 460 + 461 + if (!cpumask_test_cpu(cur_cpu, 462 + &primary->alloced_cpus_in_node)) { 463 + cpumask_set_cpu(cur_cpu, 464 + &primary->alloced_cpus_in_node); 465 + cpumask_set_cpu(cur_cpu, alloced_mask); 466 + break; 467 + } 468 + } 453 469 454 470 channel->target_cpu = cur_cpu; 455 471 channel->target_vp = hv_context.vp_index[cur_cpu];
+1
include/linux/hyperv.h
··· 699 699 /* 700 700 * State to manage the CPU affiliation of channels. 701 701 */ 702 + struct cpumask alloced_cpus_in_node; 702 703 int numa_node; 703 704 /* 704 705 * Support for sub-channels. For high performance devices,