mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH RESEND] sched: fair: drop useless cpumask_empty() in find_energy_efficient_cpu()
@ 2025-12-07  4:05 Yury Norov (NVIDIA)
  2025-12-08  8:50 ` Peter Zijlstra
  2026-01-12  8:03 ` [tip: sched/core] sched/fair: Drop " tip-bot2 for Yury Norov (NVIDIA)
  0 siblings, 2 replies; 3+ messages in thread
From: Yury Norov (NVIDIA) @ 2025-12-07  4:05 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Juri Lelli, Vincent Guittot,
	Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
	Valentin Schneider, linux-kernel
  Cc: Yury Norov (NVIDIA),
	Markus Elfring, Madadi Vineeth Reddy, K Prateek Nayak

cpumask_empty() call is O(N) and useless because the previous
cpumask_and() returns false for empty 'cpus'. Drop it.

CC: Markus Elfring <Markus.Elfring@web.de>
Reviewed-by: Madadi Vineeth Reddy <vineethr@linux.ibm.com>
Reviewed-by: K Prateek Nayak <kprateek.nayak@amd.com>
Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
Signed-off-by: Yury Norov (NVIDIA) <yury.norov@gmail.com>
---
Rebased and re-tested on top of master. Original patch:
https://lore.kernel.org/all/20250911023426.457745-1-yury.norov@gmail.com/

 kernel/sched/fair.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index e04f94233cda..af9e9dbdaa6d 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -8362,9 +8362,7 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
 		int max_spare_cap_cpu = -1;
 		int fits, max_fits = -1;
 
-		cpumask_and(cpus, perf_domain_span(pd), cpu_online_mask);
-
-		if (cpumask_empty(cpus))
+		if (!cpumask_and(cpus, perf_domain_span(pd), cpu_online_mask))
 			continue;
 
 		/* Account external pressure for the energy estimation */
-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH RESEND] sched: fair: drop useless cpumask_empty() in find_energy_efficient_cpu()
  2025-12-07  4:05 [PATCH RESEND] sched: fair: drop useless cpumask_empty() in find_energy_efficient_cpu() Yury Norov (NVIDIA)
@ 2025-12-08  8:50 ` Peter Zijlstra
  2026-01-12  8:03 ` [tip: sched/core] sched/fair: Drop " tip-bot2 for Yury Norov (NVIDIA)
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Zijlstra @ 2025-12-08  8:50 UTC (permalink / raw)
  To: Yury Norov (NVIDIA)
  Cc: Ingo Molnar, Juri Lelli, Vincent Guittot, Dietmar Eggemann,
	Steven Rostedt, Ben Segall, Mel Gorman, Valentin Schneider,
	linux-kernel, Markus Elfring, Madadi Vineeth Reddy,
	K Prateek Nayak

On Sat, Dec 06, 2025 at 11:05:42PM -0500, Yury Norov (NVIDIA) wrote:
> cpumask_empty() call is O(N) and useless because the previous
> cpumask_and() returns false for empty 'cpus'. Drop it.
> 
> CC: Markus Elfring <Markus.Elfring@web.de>
> Reviewed-by: Madadi Vineeth Reddy <vineethr@linux.ibm.com>
> Reviewed-by: K Prateek Nayak <kprateek.nayak@amd.com>
> Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
> Signed-off-by: Yury Norov (NVIDIA) <yury.norov@gmail.com>

Picked it (and the other two) up for processing after rc1.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip: sched/core] sched/fair: Drop useless cpumask_empty() in find_energy_efficient_cpu()
  2025-12-07  4:05 [PATCH RESEND] sched: fair: drop useless cpumask_empty() in find_energy_efficient_cpu() Yury Norov (NVIDIA)
  2025-12-08  8:50 ` Peter Zijlstra
@ 2026-01-12  8:03 ` tip-bot2 for Yury Norov (NVIDIA)
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Yury Norov (NVIDIA) @ 2026-01-12  8:03 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Yury Norov (NVIDIA), Peter Zijlstra (Intel),
	Madadi Vineeth Reddy, K Prateek Nayak, Vincent Guittot, x86,
	linux-kernel

The following commit has been merged into the sched/core branch of tip:

Commit-ID:     ff1de90dd7a69ef43586683535ad87ab899a1214
Gitweb:        https://git.kernel.org/tip/ff1de90dd7a69ef43586683535ad87ab899a1214
Author:        Yury Norov (NVIDIA) <yury.norov@gmail.com>
AuthorDate:    Sat, 06 Dec 2025 23:05:42 -05:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Thu, 08 Jan 2026 12:43:56 +01:00

sched/fair: Drop useless cpumask_empty() in find_energy_efficient_cpu()

cpumask_empty() call is O(N) and useless because the previous
cpumask_and() returns false for empty 'cpus'. Drop it.

Signed-off-by: Yury Norov (NVIDIA) <yury.norov@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Madadi Vineeth Reddy <vineethr@linux.ibm.com>
Reviewed-by: K Prateek Nayak <kprateek.nayak@amd.com>
Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
Link: https://patch.msgid.link/20251207040543.407695-1-yury.norov@gmail.com
---
 kernel/sched/fair.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 7377f91..64275d7 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -8359,9 +8359,7 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
 		int max_spare_cap_cpu = -1;
 		int fits, max_fits = -1;
 
-		cpumask_and(cpus, perf_domain_span(pd), cpu_online_mask);
-
-		if (cpumask_empty(cpus))
+		if (!cpumask_and(cpus, perf_domain_span(pd), cpu_online_mask))
 			continue;
 
 		/* Account external pressure for the energy estimation */

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-01-12  8:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-07  4:05 [PATCH RESEND] sched: fair: drop useless cpumask_empty() in find_energy_efficient_cpu() Yury Norov (NVIDIA)
2025-12-08  8:50 ` Peter Zijlstra
2026-01-12  8:03 ` [tip: sched/core] sched/fair: Drop " tip-bot2 for Yury Norov (NVIDIA)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®