Commit a1adce22 authored by Tom Zanussi's avatar Tom Zanussi Committed by Xiaochen Shen
Browse files

crypto: iaa - Use cpumask_weight() when rebalancing

mainline inclusion
from mainline-v6.10-rc1
commit 8f0e0cf74ccef41b383daddcf5447bba655031b3
category: bugfix
bugzilla: https://gitee.com/openeuler/intel-kernel/issues/I9TA1S
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8f0e0cf74ccef41b383daddcf5447bba655031b3



--------------------------------

If some cpus are offlined, or if the node mask is smaller than
expected, the 'nonexistent cpu' warning in rebalance_wq_table() may be
erroneously triggered.

Use cpumask_weight() to make sure we only iterate over the exact
number of cpus in the mask.

Also use num_possible_cpus() instead of num_online_cpus() to make sure
all slots in the wq table are initialized.

Intel-SIG: commit 8f0e0cf74cce crypto: iaa - Use cpumask_weight() when rebalancing.
Backporting patches for Intel IAA crypto driver on Intel Xeon platform.

Signed-off-by: default avatarTom Zanussi <tom.zanussi@linux.intel.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: default avatarXiaochen Shen <xiaochen.shen@intel.com>
parent bc6632b1
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -922,7 +922,7 @@ static void rebalance_wq_table(void)
	for_each_node_with_cpus(node) {
		node_cpus = cpumask_of_node(node);

		for (cpu = 0; cpu < nr_cpus_per_node; cpu++) {
		for (cpu = 0; cpu <  cpumask_weight(node_cpus); cpu++) {
			int node_cpu = cpumask_nth(cpu, node_cpus);

			if (WARN_ON(node_cpu >= nr_cpu_ids)) {
@@ -2005,7 +2005,7 @@ static int __init iaa_crypto_init_module(void)
	int ret = 0;
	int node;

	nr_cpus = num_online_cpus();
	nr_cpus = num_possible_cpus();
	for_each_node_with_cpus(node)
		nr_nodes++;
	if (!nr_nodes) {