Skip to contentSkip to conversation

sched/isolation: Make use of more than one housekeeping cpu

PATCH Superseded Phil Auld 4 participants 13 messages Feb 11, 2025 – Feb 21, 2025 Scheduler

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Phil Auld

author
#0 lore raw

PATCH 1/2 sched/isolation: Make use of more than one housekeeping cpu

The exising code uses housekeeping_any_cpu() to select a cpu for a given housekeeping task. However, this often ends up calling cpumask_any_and() which is defined as cpumask_first_and() which has the effect of alyways using the first cpu among those available.

The same applies when multiple NUMA nodes are involved. In that case the first cpu in the local node is chosen which does provide a bit of spreading but with multiple HK cpus per node the same issues arise.

Spread the HK work out by having housekeeping_any_cpu() and sched_numa_find_closest() use cpumask_any_and_distribute() instead of cpumask_any_and().

Cc Peter Zijlstra <[email protected]>
Cc Juri Lelli <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Waiman Long <[email protected]>
---
 kernel/sched/isolation.c | 2 +-
 kernel/sched/topology.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
kernel/sched/isolation.c +1 -1
index 81bc8b329ef1..93b038d48900 100644
@@ -40,7 +40,7 @@ int housekeeping_any_cpu(enum hk_type type)
 			if (cpu < nr_cpu_ids)
 				return cpu;
 
-			cpu = cpumask_any_and(housekeeping.cpumasks[type], cpu_online_mask);
+			cpu = cpumask_any_and_distribute(housekeeping.cpumasks[type], cpu_online_mask);
 			if (likely(cpu < nr_cpu_ids))
 				return cpu;
 			/*
kernel/sched/topology.c +1 -1
index c49aea8c1025..94133f843485 100644
@@ -2101,7 +2101,7 @@ int sched_numa_find_closest(const struct cpumask *cpus, int cpu)
 	for (i = 0; i < sched_domains_numa_levels; i++) {
 		if (!masks[i][j])
 			break;
-		cpu = cpumask_any_and(cpus, masks[i][j]);
+		cpu = cpumask_any_and_distribute(cpus, masks[i][j]);
 		if (cpu < nr_cpu_ids) {
 			found = cpu;
 			break;
Signature · 1 line
2.47.1
author
#1 lore raw

Oops, sorry... meant "[PATCH]"

Quoted 55 lines · On Tue, Feb 11, 2025 at 02:01:04PM +0000 Phil Auld wrote:

The exising code uses housekeeping_any_cpu() to select a cpu for a given housekeeping task. However, this often ends up calling cpumask_any_and() which is defined as cpumask_first_and() which has the effect of alyways using the first cpu among those available.

The same applies when multiple NUMA nodes are involved. In that case the first cpu in the local node is chosen which does provide a bit of spreading but with multiple HK cpus per node the same issues arise.

Spread the HK work out by having housekeeping_any_cpu() and sched_numa_find_closest() use cpumask_any_and_distribute() instead of cpumask_any_and().

Cc Peter Zijlstra <[email protected]>
Cc Juri Lelli <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Waiman Long <[email protected]>
---
 kernel/sched/isolation.c | 2 +-
 kernel/sched/topology.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
kernel/sched/isolation.c +1 -1
index 81bc8b329ef1..93b038d48900 100644
@@ -40,7 +40,7 @@ int housekeeping_any_cpu(enum hk_type type)
 			if (cpu < nr_cpu_ids)
 				return cpu;
 
-			cpu = cpumask_any_and(housekeeping.cpumasks[type], cpu_online_mask);
+			cpu = cpumask_any_and_distribute(housekeeping.cpumasks[type], cpu_online_mask);
 			if (likely(cpu < nr_cpu_ids))
 				return cpu;
 			/*
kernel/sched/topology.c +1 -1
index c49aea8c1025..94133f843485 100644
@@ -2101,7 +2101,7 @@ int sched_numa_find_closest(const struct cpumask *cpus, int cpu)
 	for (i = 0; i < sched_domains_numa_levels; i++) {
 		if (!masks[i][j])
 			break;
-		cpu = cpumask_any_and(cpus, masks[i][j]);
+		cpu = cpumask_any_and_distribute(cpus, masks[i][j]);
 		if (cpu < nr_cpu_ids) {
 			found = cpu;
 			break;
Signature · 1 line
2.47.1
Reviewed-by
#2 lore raw
Quoted 50 lines · Phil Auld

Oops, sorry... meant "[PATCH]"

Quoted 47 lines · On Tue, Feb 11, 2025 at 02:01:04PM +0000 Phil Auld wrote:

The exising code uses housekeeping_any_cpu() to select a cpu for a given housekeeping task. However, this often ends up calling cpumask_any_and() which is defined as cpumask_first_and() which has the effect of alyways using the first cpu among those available.

The same applies when multiple NUMA nodes are involved. In that case the first cpu in the local node is chosen which does provide a bit of spreading but with multiple HK cpus per node the same issues arise.

Spread the HK work out by having housekeeping_any_cpu() and sched_numa_find_closest() use cpumask_any_and_distribute() instead of cpumask_any_and().

Cc Peter Zijlstra <[email protected]>
Cc Juri Lelli <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Waiman Long <[email protected]>
---
  kernel/sched/isolation.c | 2 +-
  kernel/sched/topology.c  | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
kernel/sched/isolation.c +1 -1
index 81bc8b329ef1..93b038d48900 100644
@@ -40,7 +40,7 @@ int housekeeping_any_cpu(enum hk_type type)
  			if (cpu < nr_cpu_ids)
  				return cpu;
 
-			cpu = cpumask_any_and(housekeeping.cpumasks[type], cpu_online_mask);
+			cpu = cpumask_any_and_distribute(housekeeping.cpumasks[type], cpu_online_mask);
  			if (likely(cpu < nr_cpu_ids))
  				return cpu;
  			/*
kernel/sched/topology.c +0 -1
index c49aea8c1025..94133f843485 100644
@@ -2101,7 +2101,7 @@ int sched_numa_find_closest(const struct cpumask *cpus, int cpu)
  	for (i = 0; i < sched_domains_numa_levels; i++) {
  		if (!masks[i][j])
  			break;
-		cpu = cpumask_any_and(cpus, masks[i][j]);
Quoted 8 lines
Quoted 8 lines
kernel/sched/topology.c +1 -0
+		cpu = cpumask_any_and_distribute(cpus, masks[i][j]);
  		if (cpu < nr_cpu_ids) {
  			found = cpu;
  			break;
Signature · 1 line
2.47.1

LGTM

#3 lore raw
In reply to Phil Auld

Hi Phil Auld,

Quoted 5 lines · Phil Auld

The exising code uses housekeeping_any_cpu() to select a cpu for a given housekeeping task. However, this often ends up calling cpumask_any_and() which is defined as cpumask_first_and() which has the effect of alyways using the first cpu among those available.

Quoted 9 lines

The same applies when multiple NUMA nodes are involved. In that case the first cpu in the local node is chosen which does provide a bit of spreading but with multiple HK cpus per node the same issues arise.

Spread the HK work out by having housekeeping_any_cpu() and sched_numa_find_closest() use cpumask_any_and_distribute() instead of cpumask_any_and().

Got the overall intent of the patch for better load distribution on housekeeping tasks. However, one potential drawback could be that by spreading HK work across multiple CPUs might reduce the time that some cores can spend in deeper idle states which can be beneficial for power-sensitive systems.

Thoughts?

Thanks,
Madadi Vineeth Reddy

Quoted 37 lines
Cc Peter Zijlstra <[email protected]>
Cc Juri Lelli <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Waiman Long <[email protected]>
---
 kernel/sched/isolation.c | 2 +-
 kernel/sched/topology.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
kernel/sched/isolation.c +1 -1
index 81bc8b329ef1..93b038d48900 100644
@@ -40,7 +40,7 @@ int housekeeping_any_cpu(enum hk_type type)
 			if (cpu < nr_cpu_ids)
 				return cpu;
 
-			cpu = cpumask_any_and(housekeeping.cpumasks[type], cpu_online_mask);
+			cpu = cpumask_any_and_distribute(housekeeping.cpumasks[type], cpu_online_mask);
 			if (likely(cpu < nr_cpu_ids))
 				return cpu;
 			/*
kernel/sched/topology.c +1 -1
index c49aea8c1025..94133f843485 100644
@@ -2101,7 +2101,7 @@ int sched_numa_find_closest(const struct cpumask *cpus, int cpu)
 	for (i = 0; i < sched_domains_numa_levels; i++) {
 		if (!masks[i][j])
 			break;
-		cpu = cpumask_any_and(cpus, masks[i][j]);
+		cpu = cpumask_any_and_distribute(cpus, masks[i][j]);
 		if (cpu < nr_cpu_ids) {
 			found = cpu;
 			break;
author
#4 lore raw
Quoted 18 lines · On Thu, Feb 13, 2025 at 10:14:04AM +0530 Madadi Vineeth Reddy wrote:

Hi Phil Auld,

Quoted 5 lines · Phil Auld

The exising code uses housekeeping_any_cpu() to select a cpu for a given housekeeping task. However, this often ends up calling cpumask_any_and() which is defined as cpumask_first_and() which has the effect of alyways using the first cpu among those available.

Quoted 9 lines

The same applies when multiple NUMA nodes are involved. In that case the first cpu in the local node is chosen which does provide a bit of spreading but with multiple HK cpus per node the same issues arise.

Spread the HK work out by having housekeeping_any_cpu() and sched_numa_find_closest() use cpumask_any_and_distribute() instead of cpumask_any_and().

Quoted 7 lines

Got the overall intent of the patch for better load distribution on housekeeping tasks. However, one potential drawback could be that by spreading HK work across multiple CPUs might reduce the time that some cores can spend in deeper idle states which can be beneficial for power-sensitive systems.

Thoughts?

NOHZ_full setups are not generally used in power sensitive systems I think. They aren't in our use cases at least.

In cases with many cpus a single housekeeping cpu can not keep up. Having other HK cpus in deep idle states while the one in use is overloaded is not a win.

If your single HK cpu can keep up then only configure that one HK cpu. The others will go idle and stay there. And since they are nohz_full might get to stay idle even longer.

I do have a patch that has this controlled by a sched feature if that is of interest. Then it could be disabled if you don't want it.

Cheers,
Phil

Quoted 42 lines

Thanks,
Madadi Vineeth Reddy

Quoted 37 lines
Cc Peter Zijlstra <[email protected]>
Cc Juri Lelli <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Waiman Long <[email protected]>
---
 kernel/sched/isolation.c | 2 +-
 kernel/sched/topology.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
kernel/sched/isolation.c +1 -1
index 81bc8b329ef1..93b038d48900 100644
@@ -40,7 +40,7 @@ int housekeeping_any_cpu(enum hk_type type)
 			if (cpu < nr_cpu_ids)
 				return cpu;
 
-			cpu = cpumask_any_and(housekeeping.cpumasks[type], cpu_online_mask);
+			cpu = cpumask_any_and_distribute(housekeeping.cpumasks[type], cpu_online_mask);
 			if (likely(cpu < nr_cpu_ids))
 				return cpu;
 			/*
kernel/sched/topology.c +1 -1
index c49aea8c1025..94133f843485 100644
@@ -2101,7 +2101,7 @@ int sched_numa_find_closest(const struct cpumask *cpus, int cpu)
 	for (i = 0; i < sched_domains_numa_levels; i++) {
 		if (!masks[i][j])
 			break;
-		cpu = cpumask_any_and(cpus, masks[i][j]);
+		cpu = cpumask_any_and_distribute(cpus, masks[i][j]);
 		if (cpu < nr_cpu_ids) {
 			found = cpu;
 			break;
#5 lore raw

Hi Phil, Vineeth

Quoted 25 lines · Phil Auld
Quoted 24 lines · On Thu, Feb 13, 2025 at 10:14:04AM +0530 Madadi Vineeth Reddy wrote:

Hi Phil Auld,

Quoted 5 lines · Phil Auld

The exising code uses housekeeping_any_cpu() to select a cpu for a given housekeeping task. However, this often ends up calling cpumask_any_and() which is defined as cpumask_first_and() which has the effect of alyways using the first cpu among those available.

Quoted 9 lines

The same applies when multiple NUMA nodes are involved. In that case the first cpu in the local node is chosen which does provide a bit of spreading but with multiple HK cpus per node the same issues arise.

Spread the HK work out by having housekeeping_any_cpu() and sched_numa_find_closest() use cpumask_any_and_distribute() instead of cpumask_any_and().

Got the overall intent of the patch for better load distribution on housekeeping tasks. However, one potential drawback could be that by spreading HK work across multiple CPUs might reduce the time that some cores can spend in deeper idle states which can be beneficial for power-sensitive systems.

Quoted 8 lines
Quoted 1 line

Thoughts?

NOHZ_full setups are not generally used in power sensitive systems I think. They aren't in our use cases at least.

In cases with many cpus a single housekeeping cpu can not keep up. Having other HK cpus in deep idle states while the one in use is overloaded is not a win.

To me, an overloaded CPU sounds like where more than one tasks are ready to run, and a HK CPU is one receiving periodic scheduling clock ticks, so HP CPU is bound to comes out of any power-saving state it is in.

Quoted 4 lines

If your single HK cpu can keep up then only configure that one HK cpu. The others will go idle and stay there. And since they are nohz_full might get to stay idle even longer.

While it is good to distribute the load across each HK CPU in the HK cpumask (queuing jobs on different CPUs each time), this can cause jitter in virtualized environments. Unnecessaryily evicting other tenants, when it's better to overload a VP than to wake up other VPs of a tenant.

Quoted 3 lines

I do have a patch that has this controlled by a sched feature if that is of interest. Then it could be disabled if you don't want it.

Vishal

Quoted 49 lines

Cheers,
Phil

Quoted 42 lines

Thanks,
Madadi Vineeth Reddy

Quoted 37 lines
Cc Peter Zijlstra <[email protected]>
Cc Juri Lelli <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Waiman Long <[email protected]>
---
 kernel/sched/isolation.c | 2 +-
 kernel/sched/topology.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
kernel/sched/isolation.c +1 -1
index 81bc8b329ef1..93b038d48900 100644
@@ -40,7 +40,7 @@ int housekeeping_any_cpu(enum hk_type type)
 			if (cpu < nr_cpu_ids)
 				return cpu;
 
-			cpu = cpumask_any_and(housekeeping.cpumasks[type], cpu_online_mask);
+			cpu = cpumask_any_and_distribute(housekeeping.cpumasks[type], cpu_online_mask);
 			if (likely(cpu < nr_cpu_ids))
 				return cpu;
 			/*
kernel/sched/topology.c +1 -1
index c49aea8c1025..94133f843485 100644
@@ -2101,7 +2101,7 @@ int sched_numa_find_closest(const struct cpumask *cpus, int cpu)
 	for (i = 0; i < sched_domains_numa_levels; i++) {
 		if (!masks[i][j])
 			break;
-		cpu = cpumask_any_and(cpus, masks[i][j]);
+		cpu = cpumask_any_and_distribute(cpus, masks[i][j]);
 		if (cpu < nr_cpu_ids) {
 			found = cpu;
 			break;
author
#6 lore raw

Hi Vishal.

Quoted 33 lines · On Fri, Feb 14, 2025 at 11:08:19AM +0530 Vishal Chourasia wrote:

Hi Phil, Vineeth

Quoted 30 lines · Phil Auld
Quoted 18 lines · On Thu, Feb 13, 2025 at 10:14:04AM +0530 Madadi Vineeth Reddy wrote:

Hi Phil Auld,

Quoted 5 lines · Phil Auld

The exising code uses housekeeping_any_cpu() to select a cpu for a given housekeeping task. However, this often ends up calling cpumask_any_and() which is defined as cpumask_first_and() which has the effect of alyways using the first cpu among those available.

Quoted 9 lines

The same applies when multiple NUMA nodes are involved. In that case the first cpu in the local node is chosen which does provide a bit of spreading but with multiple HK cpus per node the same issues arise.

Spread the HK work out by having housekeeping_any_cpu() and sched_numa_find_closest() use cpumask_any_and_distribute() instead of cpumask_any_and().

Quoted 7 lines

Got the overall intent of the patch for better load distribution on housekeeping tasks. However, one potential drawback could be that by spreading HK work across multiple CPUs might reduce the time that some cores can spend in deeper idle states which can be beneficial for power-sensitive systems.

Thoughts?

NOHZ_full setups are not generally used in power sensitive systems I think. They aren't in our use cases at least.

Quoted 7 lines
Quoted 3 lines

In cases with many cpus a single housekeeping cpu can not keep up. Having other HK cpus in deep idle states while the one in use is overloaded is not a win.

To me, an overloaded CPU sounds like where more than one tasks are ready to run, and a HK CPU is one receiving periodic scheduling clock ticks, so HP CPU is bound to comes out of any power-saving state it is in.

If the overload is caused by HK and interrupts there is nothing in the system to help. Tasks, sure, can get load balanced.

And as you say, the HK cpus will have generally ticks happening anyway.

Quoted 10 lines
Quoted 4 lines

If your single HK cpu can keep up then only configure that one HK cpu. The others will go idle and stay there. And since they are nohz_full might get to stay idle even longer.

While it is good to distribute the load across each HK CPU in the HK cpumask (queuing jobs on different CPUs each time), this can cause jitter in virtualized environments. Unnecessaryily evicting other tenants, when it's better to overload a VP than to wake up other VPs of a tenant.

Sorry I'm not sure I understand your setup. Are your running virtual tenants on the HK cpus? nohz_full in the guests? Maybe you only need on HK then it won't matter.

My concern is that currently there is no point in having more than one HK cpu (per node in a NUMA case). The code as currently implemented is just not doing what it needs to.

We have numerous cases where a single HK cpu just cannot keep up and the remote_tick warning fires. It also can lead to the other things (orchastration sw, HA keepalives etc) on the HK cpus getting starved which leads to other issues. In these cases we recommend increasing the number of HK cpus. But... that only helps the userspace tasks somewhat. It does not help the actual housekeeping part.

It seems clear to me that the intent of the cpumask_any_and() calls is to pick _any_ cpu in the hk mask. Not just the first, otherwise it would just use cpumask_first_and().

I'm open to alternate suggestions of how to fix this.

Cheers,
Phil

Quoted 55 lines
Quoted 3 lines

I do have a patch that has this controlled by a sched feature if that is of interest. Then it could be disabled if you don't want it.

Vishal

Quoted 49 lines

Cheers,
Phil

Quoted 42 lines

Thanks,
Madadi Vineeth Reddy

Quoted 37 lines
Cc Peter Zijlstra <[email protected]>
Cc Juri Lelli <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Waiman Long <[email protected]>
---
 kernel/sched/isolation.c | 2 +-
 kernel/sched/topology.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
kernel/sched/isolation.c +1 -1
index 81bc8b329ef1..93b038d48900 100644
@@ -40,7 +40,7 @@ int housekeeping_any_cpu(enum hk_type type)
 			if (cpu < nr_cpu_ids)
 				return cpu;
 
-			cpu = cpumask_any_and(housekeeping.cpumasks[type], cpu_online_mask);
+			cpu = cpumask_any_and_distribute(housekeeping.cpumasks[type], cpu_online_mask);
 			if (likely(cpu < nr_cpu_ids))
 				return cpu;
 			/*
kernel/sched/topology.c +1 -1
index c49aea8c1025..94133f843485 100644
@@ -2101,7 +2101,7 @@ int sched_numa_find_closest(const struct cpumask *cpus, int cpu)
 	for (i = 0; i < sched_domains_numa_levels; i++) {
 		if (!masks[i][j])
 			break;
-		cpu = cpumask_any_and(cpus, masks[i][j]);
+		cpu = cpumask_any_and_distribute(cpus, masks[i][j]);
 		if (cpu < nr_cpu_ids) {
 			found = cpu;
 			break;
#7 lore raw
Quoted 62 lines · Phil Auld

Hi Vishal.

Quoted 31 lines · On Fri, Feb 14, 2025 at 11:08:19AM +0530 Vishal Chourasia wrote:

Hi Phil, Vineeth

Quoted 28 lines · Phil Auld
Quoted 17 lines · On Thu, Feb 13, 2025 at 10:14:04AM +0530 Madadi Vineeth Reddy wrote:

Hi Phil Auld,

Quoted 5 lines · Phil Auld

The exising code uses housekeeping_any_cpu() to select a cpu for a given housekeeping task. However, this often ends up calling cpumask_any_and() which is defined as cpumask_first_and() which has the effect of alyways using the first cpu among those available.

Quoted 9 lines

The same applies when multiple NUMA nodes are involved. In that case the first cpu in the local node is chosen which does provide a bit of spreading but with multiple HK cpus per node the same issues arise.

Spread the HK work out by having housekeeping_any_cpu() and sched_numa_find_closest() use cpumask_any_and_distribute() instead of cpumask_any_and().

Quoted 7 lines

Got the overall intent of the patch for better load distribution on housekeeping tasks. However, one potential drawback could be that by spreading HK work across multiple CPUs might reduce the time that some cores can spend in deeper idle states which can be beneficial for power-sensitive systems.

Thoughts?

NOHZ_full setups are not generally used in power sensitive systems I think. They aren't in our use cases at least.

Quoted 6 lines
Quoted 3 lines

In cases with many cpus a single housekeeping cpu can not keep up. Having other HK cpus in deep idle states while the one in use is overloaded is not a win.

To me, an overloaded CPU sounds like where more than one tasks are ready to run, and a HK CPU is one receiving periodic scheduling clock ticks, so HP CPU is bound to comes out of any power-saving state it is in.

If the overload is caused by HK and interrupts there is nothing in the system to help. Tasks, sure, can get load balanced.

And as you say, the HK cpus will have generally ticks happening anyway.

Quoted 9 lines
Quoted 3 lines

If your single HK cpu can keep up then only configure that one HK cpu. The others will go idle and stay there. And since they are nohz_full might get to stay idle even longer.

While it is good to distribute the load across each HK CPU in the HK cpumask (queuing jobs on different CPUs each time), this can cause jitter in virtualized environments. Unnecessaryily evicting other tenants, when it's better to overload a VP than to wake up other VPs of a tenant.

Sorry I'm not sure I understand your setup. Are your running virtual tenants on the HK cpus? nohz_full in the guests? Maybe you only need on HK then it won't matter.

My concern is that currently there is no point in having more than one HK cpu (per node in a NUMA case). The code as currently implemented is just not doing what it needs to.

Quoted 6 lines

We have numerous cases where a single HK cpu just cannot keep up and the remote_tick warning fires. It also can lead to the other things (orchastration sw, HA keepalives etc) on the HK cpus getting starved which leads to other issues. In these cases we recommend increasing the number of HK cpus. But... that only helps the userspace tasks somewhat. It does not help the actual housekeeping part.

That is the part that should go into the commit log as well as it is the rationale behind your patch.

Cheers,
Longman

author
#8 lore raw
Quoted 71 lines · On Tue, Feb 18, 2025 at 10:23:50AM -0500 Waiman Long wrote:
Quoted 62 lines · Phil Auld

Hi Vishal.

Quoted 31 lines · On Fri, Feb 14, 2025 at 11:08:19AM +0530 Vishal Chourasia wrote:

Hi Phil, Vineeth

Quoted 28 lines · Phil Auld
Quoted 17 lines · On Thu, Feb 13, 2025 at 10:14:04AM +0530 Madadi Vineeth Reddy wrote:

Hi Phil Auld,

Quoted 5 lines · Phil Auld

The exising code uses housekeeping_any_cpu() to select a cpu for a given housekeeping task. However, this often ends up calling cpumask_any_and() which is defined as cpumask_first_and() which has the effect of alyways using the first cpu among those available.

Quoted 9 lines

The same applies when multiple NUMA nodes are involved. In that case the first cpu in the local node is chosen which does provide a bit of spreading but with multiple HK cpus per node the same issues arise.

Spread the HK work out by having housekeeping_any_cpu() and sched_numa_find_closest() use cpumask_any_and_distribute() instead of cpumask_any_and().

Quoted 7 lines

Got the overall intent of the patch for better load distribution on housekeeping tasks. However, one potential drawback could be that by spreading HK work across multiple CPUs might reduce the time that some cores can spend in deeper idle states which can be beneficial for power-sensitive systems.

Thoughts?

NOHZ_full setups are not generally used in power sensitive systems I think. They aren't in our use cases at least.

Quoted 6 lines
Quoted 3 lines

In cases with many cpus a single housekeeping cpu can not keep up. Having other HK cpus in deep idle states while the one in use is overloaded is not a win.

To me, an overloaded CPU sounds like where more than one tasks are ready to run, and a HK CPU is one receiving periodic scheduling clock ticks, so HP CPU is bound to comes out of any power-saving state it is in.

If the overload is caused by HK and interrupts there is nothing in the system to help. Tasks, sure, can get load balanced.

And as you say, the HK cpus will have generally ticks happening anyway.

Quoted 9 lines
Quoted 3 lines

If your single HK cpu can keep up then only configure that one HK cpu. The others will go idle and stay there. And since they are nohz_full might get to stay idle even longer.

While it is good to distribute the load across each HK CPU in the HK cpumask (queuing jobs on different CPUs each time), this can cause jitter in virtualized environments. Unnecessaryily evicting other tenants, when it's better to overload a VP than to wake up other VPs of a tenant.

Sorry I'm not sure I understand your setup. Are your running virtual tenants on the HK cpus? nohz_full in the guests? Maybe you only need on HK then it won't matter.

My concern is that currently there is no point in having more than one HK cpu (per node in a NUMA case). The code as currently implemented is just not doing what it needs to.

Quoted 6 lines

We have numerous cases where a single HK cpu just cannot keep up and the remote_tick warning fires. It also can lead to the other things (orchastration sw, HA keepalives etc) on the HK cpus getting starved which leads to other issues. In these cases we recommend increasing the number of HK cpus. But... that only helps the userspace tasks somewhat. It does not help the actual housekeeping part.

Quoted 3 lines

That is the part that should go into the commit log as well as it is the rationale behind your patch.

Sure, I can add that piece and resend.

Cheers,
Phil

Quoted 3 lines

Cheers,
Longman

#9 lore raw
Quoted 70 lines · Phil Auld
Quoted 69 lines · On Tue, Feb 18, 2025 at 10:23:50AM -0500 Waiman Long wrote:
Quoted 68 lines · Phil Auld

Hi Vishal.

Quoted 31 lines · On Fri, Feb 14, 2025 at 11:08:19AM +0530 Vishal Chourasia wrote:

Hi Phil, Vineeth

Quoted 28 lines · Phil Auld
Quoted 17 lines · On Thu, Feb 13, 2025 at 10:14:04AM +0530 Madadi Vineeth Reddy wrote:

Hi Phil Auld,

Quoted 5 lines · Phil Auld

The exising code uses housekeeping_any_cpu() to select a cpu for a given housekeeping task. However, this often ends up calling cpumask_any_and() which is defined as cpumask_first_and() which has the effect of alyways using the first cpu among those available.

Quoted 9 lines

The same applies when multiple NUMA nodes are involved. In that case the first cpu in the local node is chosen which does provide a bit of spreading but with multiple HK cpus per node the same issues arise.

Spread the HK work out by having housekeeping_any_cpu() and sched_numa_find_closest() use cpumask_any_and_distribute() instead of cpumask_any_and().

Quoted 7 lines

Got the overall intent of the patch for better load distribution on housekeeping tasks. However, one potential drawback could be that by spreading HK work across multiple CPUs might reduce the time that some cores can spend in deeper idle states which can be beneficial for power-sensitive systems.

Thoughts?

NOHZ_full setups are not generally used in power sensitive systems I think. They aren't in our use cases at least.

Quoted 6 lines
Quoted 3 lines

In cases with many cpus a single housekeeping cpu can not keep up. Having other HK cpus in deep idle states while the one in use is overloaded is not a win.

To me, an overloaded CPU sounds like where more than one tasks are ready to run, and a HK CPU is one receiving periodic scheduling clock ticks, so HP CPU is bound to comes out of any power-saving state it is in.

If the overload is caused by HK and interrupts there is nothing in the system to help. Tasks, sure, can get load balanced.

And as you say, the HK cpus will have generally ticks happening anyway.

Quoted 9 lines
Quoted 3 lines

If your single HK cpu can keep up then only configure that one HK cpu. The others will go idle and stay there. And since they are nohz_full might get to stay idle even longer.

While it is good to distribute the load across each HK CPU in the HK cpumask (queuing jobs on different CPUs each time), this can cause jitter in virtualized environments. Unnecessaryily evicting other tenants, when it's better to overload a VP than to wake up other VPs of a tenant.

Sorry I'm not sure I understand your setup. Are your running virtual tenants on the HK cpus? nohz_full in the guests? Maybe you only need on HK then it won't matter.

My concern is that currently there is no point in having more than one HK cpu (per node in a NUMA case). The code as currently implemented is just not doing what it needs to.

We have numerous cases where a single HK cpu just cannot keep up and the remote_tick warning fires. It also can lead to the other things (orchastration sw, HA keepalives etc) on the HK cpus getting starved which leads to other issues. In these cases we recommend increasing the number of HK cpus. But... that only helps the userspace tasks somewhat. It does not help the actual housekeeping part.

Quoted 4 lines
Quoted 3 lines

That is the part that should go into the commit log as well as it is the rationale behind your patch.

Sure, I can add that piece and resend.

While at it, you can also add some text to address the other concerns that reviewers have so far.

Cheers,
Longman

Quoted 9 lines

Cheers,
Phil

Quoted 3 lines

Cheers,
Longman

#10 lore raw
In reply to Phil Auld
Quoted 60 lines · Phil Auld

Hi Vishal.

Quoted 33 lines · On Fri, Feb 14, 2025 at 11:08:19AM +0530 Vishal Chourasia wrote:

Hi Phil, Vineeth

Quoted 30 lines · Phil Auld
Quoted 18 lines · On Thu, Feb 13, 2025 at 10:14:04AM +0530 Madadi Vineeth Reddy wrote:

Hi Phil Auld,

Quoted 5 lines · Phil Auld

The exising code uses housekeeping_any_cpu() to select a cpu for a given housekeeping task. However, this often ends up calling cpumask_any_and() which is defined as cpumask_first_and() which has the effect of alyways using the first cpu among those available.

Quoted 9 lines

The same applies when multiple NUMA nodes are involved. In that case the first cpu in the local node is chosen which does provide a bit of spreading but with multiple HK cpus per node the same issues arise.

Spread the HK work out by having housekeeping_any_cpu() and sched_numa_find_closest() use cpumask_any_and_distribute() instead of cpumask_any_and().

Quoted 7 lines

Got the overall intent of the patch for better load distribution on housekeeping tasks. However, one potential drawback could be that by spreading HK work across multiple CPUs might reduce the time that some cores can spend in deeper idle states which can be beneficial for power-sensitive systems.

Thoughts?

NOHZ_full setups are not generally used in power sensitive systems I think. They aren't in our use cases at least.

Quoted 7 lines
Quoted 3 lines

In cases with many cpus a single housekeeping cpu can not keep up. Having other HK cpus in deep idle states while the one in use is overloaded is not a win.

To me, an overloaded CPU sounds like where more than one tasks are ready to run, and a HK CPU is one receiving periodic scheduling clock ticks, so HP CPU is bound to comes out of any power-saving state it is in.

If the overload is caused by HK and interrupts there is nothing in the system to help. Tasks, sure, can get load balanced.

And as you say, the HK cpus will have generally ticks happening anyway.

Quoted 10 lines
Quoted 4 lines

If your single HK cpu can keep up then only configure that one HK cpu. The others will go idle and stay there. And since they are nohz_full might get to stay idle even longer.

While it is good to distribute the load across each HK CPU in the HK cpumask (queuing jobs on different CPUs each time), this can cause jitter in virtualized environments. Unnecessaryily evicting other tenants, when it's better to overload a VP than to wake up other VPs of a tenant.

Quoted 4 lines

Sorry I'm not sure I understand your setup. Are your running virtual tenants on the HK cpus? nohz_full in the guests? Maybe you only need on HK then it won't matter.

Firstly, I am unaware if nohz_full is being used in virtualized environment. Please correct me it is. I am not saying it can't or shouldn't be used, it's just I don't know if anybody is using it.

nohz_full in guests would mean that tick is disabled inside the guest but the host might still be getting ticks. So, I am unsure, whether it is a good idea to have nohz_full in virtualized environment.

Nevertheless, the idea of nohz_full is to reduce to the kernel interference for CPUs marked as nohz_full. And, it does help with guest interference.

I would like to mention, In SPLPAR environment, scheduling work on different HK CPU each time can caused VM preemption in a multi-tenant setup in cases where CPUs in HK cpumask spans across VPs, its better to consolidate them within few VPs.

VP is virtual core/processor.

Quoted 11 lines

My concern is that currently there is no point in having more than one HK cpu (per node in a NUMA case). The code as currently implemented is just not doing what it needs to.

We have numerous cases where a single HK cpu just cannot keep up and the remote_tick warning fires. It also can lead to the other things (orchastration sw, HA keepalives etc) on the HK cpus getting starved which leads to other issues. In these cases we recommend increasing the number of HK cpus. But... that only helps the userspace tasks somewhat. It does not help the actual housekeeping part.

Quoted 5 lines

It seems clear to me that the intent of the cpumask_any_and() calls is to pick _any_ cpu in the hk mask. Not just the first, otherwise it would just use cpumask_first_and().

I'm open to alternate suggestions of how to fix this.

Your approach looks good to me.

I wanted to mention the case of overcommitted multi-tenant setup where this will cause noisy neighbour sort of situation, but this can be avoided by carefully selecting HK CPUs.

Thanks,
vishalc

Quoted 63 lines

Cheers,
Phil

Quoted 55 lines
Quoted 3 lines

I do have a patch that has this controlled by a sched feature if that is of interest. Then it could be disabled if you don't want it.

Vishal

Quoted 49 lines

Cheers,
Phil

Quoted 42 lines

Thanks,
Madadi Vineeth Reddy

Quoted 37 lines
Cc Peter Zijlstra <[email protected]>
Cc Juri Lelli <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Waiman Long <[email protected]>
---
 kernel/sched/isolation.c | 2 +-
 kernel/sched/topology.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
kernel/sched/isolation.c +1 -1
index 81bc8b329ef1..93b038d48900 100644
@@ -40,7 +40,7 @@ int housekeeping_any_cpu(enum hk_type type)
 			if (cpu < nr_cpu_ids)
 				return cpu;
 
-			cpu = cpumask_any_and(housekeeping.cpumasks[type], cpu_online_mask);
+			cpu = cpumask_any_and_distribute(housekeeping.cpumasks[type], cpu_online_mask);
 			if (likely(cpu < nr_cpu_ids))
 				return cpu;
 			/*
kernel/sched/topology.c +1 -1
index c49aea8c1025..94133f843485 100644
@@ -2101,7 +2101,7 @@ int sched_numa_find_closest(const struct cpumask *cpus, int cpu)
 	for (i = 0; i < sched_domains_numa_levels; i++) {
 		if (!masks[i][j])
 			break;
-		cpu = cpumask_any_and(cpus, masks[i][j]);
+		cpu = cpumask_any_and_distribute(cpus, masks[i][j]);
 		if (cpu < nr_cpu_ids) {
 			found = cpu;
 			break;
author
#11 lore raw

Hi Vishal,

Quoted 61 lines · On Thu, Feb 20, 2025 at 02:50:40PM +0530 Vishal Chourasia wrote:
Quoted 60 lines · Phil Auld

Hi Vishal.

Quoted 33 lines · On Fri, Feb 14, 2025 at 11:08:19AM +0530 Vishal Chourasia wrote:

Hi Phil, Vineeth

Quoted 30 lines · Phil Auld
Quoted 18 lines · On Thu, Feb 13, 2025 at 10:14:04AM +0530 Madadi Vineeth Reddy wrote:

Hi Phil Auld,

Quoted 5 lines · Phil Auld

The exising code uses housekeeping_any_cpu() to select a cpu for a given housekeeping task. However, this often ends up calling cpumask_any_and() which is defined as cpumask_first_and() which has the effect of alyways using the first cpu among those available.

Quoted 9 lines

The same applies when multiple NUMA nodes are involved. In that case the first cpu in the local node is chosen which does provide a bit of spreading but with multiple HK cpus per node the same issues arise.

Spread the HK work out by having housekeeping_any_cpu() and sched_numa_find_closest() use cpumask_any_and_distribute() instead of cpumask_any_and().

Quoted 7 lines

Got the overall intent of the patch for better load distribution on housekeeping tasks. However, one potential drawback could be that by spreading HK work across multiple CPUs might reduce the time that some cores can spend in deeper idle states which can be beneficial for power-sensitive systems.

Thoughts?

NOHZ_full setups are not generally used in power sensitive systems I think. They aren't in our use cases at least.

Quoted 7 lines
Quoted 3 lines

In cases with many cpus a single housekeeping cpu can not keep up. Having other HK cpus in deep idle states while the one in use is overloaded is not a win.

To me, an overloaded CPU sounds like where more than one tasks are ready to run, and a HK CPU is one receiving periodic scheduling clock ticks, so HP CPU is bound to comes out of any power-saving state it is in.

If the overload is caused by HK and interrupts there is nothing in the system to help. Tasks, sure, can get load balanced.

And as you say, the HK cpus will have generally ticks happening anyway.

Quoted 10 lines
Quoted 4 lines

If your single HK cpu can keep up then only configure that one HK cpu. The others will go idle and stay there. And since they are nohz_full might get to stay idle even longer.

While it is good to distribute the load across each HK CPU in the HK cpumask (queuing jobs on different CPUs each time), this can cause jitter in virtualized environments. Unnecessaryily evicting other tenants, when it's better to overload a VP than to wake up other VPs of a tenant.

Quoted 8 lines
Quoted 4 lines

Sorry I'm not sure I understand your setup. Are your running virtual tenants on the HK cpus? nohz_full in the guests? Maybe you only need on HK then it won't matter.

Firstly, I am unaware if nohz_full is being used in virtualized environment. Please correct me it is. I am not saying it can't or shouldn't be used, it's just I don't know if anybody is using it.

I've seen some people trying it in various ways and to varying degrees of success if I recall correctly.

Quoted 7 lines

nohz_full in guests would mean that tick is disabled inside the guest but the host might still be getting ticks. So, I am unsure, whether it is a good idea to have nohz_full in virtualized environment.

Nevertheless, the idea of nohz_full is to reduce to the kernel interference for CPUs marked as nohz_full. And, it does help with guest interference.

Quoted 6 lines

I would like to mention, In SPLPAR environment, scheduling work on different HK CPU each time can caused VM preemption in a multi-tenant setup in cases where CPUs in HK cpumask spans across VPs, its better to consolidate them within few VPs.

VP is virtual core/processor.

I have a hard time reconciling you saying you are not using virtualization and then talking about VMs and VPs ;)

Sometimes I forget how interesting PPC can be...

Quoted 16 lines
Quoted 16 lines

My concern is that currently there is no point in having more than one HK cpu (per node in a NUMA case). The code as currently implemented is just not doing what it needs to.

We have numerous cases where a single HK cpu just cannot keep up and the remote_tick warning fires. It also can lead to the other things (orchastration sw, HA keepalives etc) on the HK cpus getting starved which leads to other issues. In these cases we recommend increasing the number of HK cpus. But... that only helps the userspace tasks somewhat. It does not help the actual housekeeping part.

It seems clear to me that the intent of the cpumask_any_and() calls is to pick _any_ cpu in the hk mask. Not just the first, otherwise it would just use cpumask_first_and().

Quoted 6 lines
Quoted 1 line

I'm open to alternate suggestions of how to fix this.

Your approach looks good to me.

I wanted to mention the case of overcommitted multi-tenant setup where this will cause noisy neighbour sort of situation, but this can be avoided by carefully selecting HK CPUs.

Yes, it can be configured away, hopefully.

Still, this could easily be a sched feat if that make sense to people.

Thanks for the review!

Cheers,
Phil

Quoted 67 lines

Thanks,
vishalc

Quoted 63 lines

Cheers,
Phil

Quoted 55 lines
Quoted 3 lines

I do have a patch that has this controlled by a sched feature if that is of interest. Then it could be disabled if you don't want it.

Vishal

Quoted 49 lines

Cheers,
Phil

Quoted 42 lines

Thanks,
Madadi Vineeth Reddy

Quoted 37 lines
Cc Peter Zijlstra <[email protected]>
Cc Juri Lelli <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Waiman Long <[email protected]>
---
 kernel/sched/isolation.c | 2 +-
 kernel/sched/topology.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
kernel/sched/isolation.c +1 -1
index 81bc8b329ef1..93b038d48900 100644
@@ -40,7 +40,7 @@ int housekeeping_any_cpu(enum hk_type type)
 			if (cpu < nr_cpu_ids)
 				return cpu;
 
-			cpu = cpumask_any_and(housekeeping.cpumasks[type], cpu_online_mask);
+			cpu = cpumask_any_and_distribute(housekeeping.cpumasks[type], cpu_online_mask);
 			if (likely(cpu < nr_cpu_ids))
 				return cpu;
 			/*
kernel/sched/topology.c +1 -1
index c49aea8c1025..94133f843485 100644
@@ -2101,7 +2101,7 @@ int sched_numa_find_closest(const struct cpumask *cpus, int cpu)
 	for (i = 0; i < sched_domains_numa_levels; i++) {
 		if (!masks[i][j])
 			break;
-		cpu = cpumask_any_and(cpus, masks[i][j]);
+		cpu = cpumask_any_and_distribute(cpus, masks[i][j]);
 		if (cpu < nr_cpu_ids) {
 			found = cpu;
 			break;
#12 lore raw
Quoted 90 lines · Phil Auld

Hi Vishal,

Quoted 61 lines · On Thu, Feb 20, 2025 at 02:50:40PM +0530 Vishal Chourasia wrote:
Quoted 60 lines · Phil Auld

Hi Vishal.

Quoted 33 lines · On Fri, Feb 14, 2025 at 11:08:19AM +0530 Vishal Chourasia wrote:

Hi Phil, Vineeth

Quoted 30 lines · Phil Auld
Quoted 18 lines · On Thu, Feb 13, 2025 at 10:14:04AM +0530 Madadi Vineeth Reddy wrote:

Hi Phil Auld,

Quoted 5 lines · Phil Auld

The exising code uses housekeeping_any_cpu() to select a cpu for a given housekeeping task. However, this often ends up calling cpumask_any_and() which is defined as cpumask_first_and() which has the effect of alyways using the first cpu among those available.

Quoted 9 lines

The same applies when multiple NUMA nodes are involved. In that case the first cpu in the local node is chosen which does provide a bit of spreading but with multiple HK cpus per node the same issues arise.

Spread the HK work out by having housekeeping_any_cpu() and sched_numa_find_closest() use cpumask_any_and_distribute() instead of cpumask_any_and().

Quoted 7 lines

Got the overall intent of the patch for better load distribution on housekeeping tasks. However, one potential drawback could be that by spreading HK work across multiple CPUs might reduce the time that some cores can spend in deeper idle states which can be beneficial for power-sensitive systems.

Thoughts?

NOHZ_full setups are not generally used in power sensitive systems I think. They aren't in our use cases at least.

Quoted 7 lines
Quoted 3 lines

In cases with many cpus a single housekeeping cpu can not keep up. Having other HK cpus in deep idle states while the one in use is overloaded is not a win.

To me, an overloaded CPU sounds like where more than one tasks are ready to run, and a HK CPU is one receiving periodic scheduling clock ticks, so HP CPU is bound to comes out of any power-saving state it is in.

If the overload is caused by HK and interrupts there is nothing in the system to help. Tasks, sure, can get load balanced.

And as you say, the HK cpus will have generally ticks happening anyway.

Quoted 10 lines
Quoted 4 lines

If your single HK cpu can keep up then only configure that one HK cpu. The others will go idle and stay there. And since they are nohz_full might get to stay idle even longer.

While it is good to distribute the load across each HK CPU in the HK cpumask (queuing jobs on different CPUs each time), this can cause jitter in virtualized environments. Unnecessaryily evicting other tenants, when it's better to overload a VP than to wake up other VPs of a tenant.

Quoted 8 lines
Quoted 4 lines

Sorry I'm not sure I understand your setup. Are your running virtual tenants on the HK cpus? nohz_full in the guests? Maybe you only need on HK then it won't matter.

Firstly, I am unaware if nohz_full is being used in virtualized environment. Please correct me it is. I am not saying it can't or shouldn't be used, it's just I don't know if anybody is using it.

I've seen some people trying it in various ways and to varying degrees of success if I recall correctly.

Quoted 12 lines

nohz_full in guests would mean that tick is disabled inside the guest but the host might still be getting ticks. So, I am unsure, whether it is a good idea to have nohz_full in virtualized environment.

Nevertheless, the idea of nohz_full is to reduce to the kernel interference for CPUs marked as nohz_full. And, it does help with guest interference.

I would like to mention, In SPLPAR environment, scheduling work on different HK CPU each time can caused VM preemption in a multi-tenant setup in cases where CPUs in HK cpumask spans across VPs, its better to consolidate them within few VPs.

Quoted 4 lines
Quoted 1 line

VP is virtual core/processor.

I have a hard time reconciling you saying you are not using virtualization and then talking about VMs and VPs ;)

I was thinking of a possibility in virtualized environments, this isn't specific to PPC

Thanks
vishalc :)

Quoted 109 lines

Sometimes I forget how interesting PPC can be...

Quoted 16 lines
Quoted 16 lines

My concern is that currently there is no point in having more than one HK cpu (per node in a NUMA case). The code as currently implemented is just not doing what it needs to.

We have numerous cases where a single HK cpu just cannot keep up and the remote_tick warning fires. It also can lead to the other things (orchastration sw, HA keepalives etc) on the HK cpus getting starved which leads to other issues. In these cases we recommend increasing the number of HK cpus. But... that only helps the userspace tasks somewhat. It does not help the actual housekeeping part.

It seems clear to me that the intent of the cpumask_any_and() calls is to pick _any_ cpu in the hk mask. Not just the first, otherwise it would just use cpumask_first_and().

Quoted 6 lines
Quoted 1 line

I'm open to alternate suggestions of how to fix this.

Your approach looks good to me.

I wanted to mention the case of overcommitted multi-tenant setup where this will cause noisy neighbour sort of situation, but this can be avoided by carefully selecting HK CPUs.

Yes, it can be configured away, hopefully.

Still, this could easily be a sched feat if that make sense to people.

Thanks for the review!

Cheers,
Phil

Quoted 67 lines

Thanks,
vishalc

Quoted 63 lines

Cheers,
Phil

Quoted 55 lines
Quoted 3 lines

I do have a patch that has this controlled by a sched feature if that is of interest. Then it could be disabled if you don't want it.

Vishal

Quoted 49 lines

Cheers,
Phil

Quoted 42 lines

Thanks,
Madadi Vineeth Reddy

Quoted 37 lines
Cc Peter Zijlstra <[email protected]>
Cc Juri Lelli <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Waiman Long <[email protected]>
---
 kernel/sched/isolation.c | 2 +-
 kernel/sched/topology.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
kernel/sched/isolation.c +1 -1
index 81bc8b329ef1..93b038d48900 100644
@@ -40,7 +40,7 @@ int housekeeping_any_cpu(enum hk_type type)
 			if (cpu < nr_cpu_ids)
 				return cpu;
 
-			cpu = cpumask_any_and(housekeeping.cpumasks[type], cpu_online_mask);
+			cpu = cpumask_any_and_distribute(housekeeping.cpumasks[type], cpu_online_mask);
 			if (likely(cpu < nr_cpu_ids))
 				return cpu;
 			/*
kernel/sched/topology.c +1 -1
index c49aea8c1025..94133f843485 100644
@@ -2101,7 +2101,7 @@ int sched_numa_find_closest(const struct cpumask *cpus, int cpu)
 	for (i = 0; i < sched_domains_numa_levels; i++) {
 		if (!masks[i][j])
 			break;
-		cpu = cpumask_any_and(cpus, masks[i][j]);
+		cpu = cpumask_any_and_distribute(cpus, masks[i][j]);
 		if (cpu < nr_cpu_ids) {
 			found = cpu;
 			break;