public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] sched/deadline: minor code cleanups
@ 2025-10-14 10:03 Shrikanth Hegde
  2025-10-14 10:03 ` [PATCH 1/2] " Shrikanth Hegde
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Shrikanth Hegde @ 2025-10-14 10:03 UTC (permalink / raw)
  To: peterz, juri.lelli, mingo, vincent.guittot
  Cc: sshegde, linux-kernel, rostedt, dietmar.eggemann, nico

While trying to understand the dl_server changes, noticed these minor
code optimizations/cleanups possible. 

Let me know if these should be squashed into one patch. Kept is separate
as of now.

No change in functionality. Could save a few cycles.

Shrikanth Hegde (2):
  sched/deadline: minor code cleanups
  sched/deadline: Use cpumask_weight_and in dl_bw_cpus

 kernel/sched/deadline.c | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)

-- 
2.47.3


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

* [PATCH 1/2] sched/deadline: minor code cleanups
  2025-10-14 10:03 [PATCH 0/2] sched/deadline: minor code cleanups Shrikanth Hegde
@ 2025-10-14 10:03 ` Shrikanth Hegde
  2025-11-10 14:10   ` Peter Zijlstra
                     ` (2 more replies)
  2025-10-14 10:03 ` [PATCH 2/2] sched/deadline: Use cpumask_weight_and in dl_bw_cpus Shrikanth Hegde
  2025-10-15  8:41 ` [PATCH 0/2] sched/deadline: minor code cleanups Juri Lelli
  2 siblings, 3 replies; 12+ messages in thread
From: Shrikanth Hegde @ 2025-10-14 10:03 UTC (permalink / raw)
  To: peterz, juri.lelli, mingo, vincent.guittot
  Cc: sshegde, linux-kernel, rostedt, dietmar.eggemann, nico

- In dl_server_timer, there is same dl_runtime check above. So
this check is duplicate. This could save a few cycles.

- In select_task_rq_dl, there is only one goto statement, there is
no need for it. 

No functional changes.

Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
---
 kernel/sched/deadline.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index 7b7671060bf9..8b7c4ee41fd8 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -1166,9 +1166,6 @@ static enum hrtimer_restart dl_server_timer(struct hrtimer *timer, struct sched_
 		sched_clock_tick();
 		update_rq_clock(rq);
 
-		if (!dl_se->dl_runtime)
-			return HRTIMER_NORESTART;
-
 		if (dl_se->dl_defer_armed) {
 			/*
 			 * First check if the server could consume runtime in background.
@@ -2173,7 +2170,7 @@ select_task_rq_dl(struct task_struct *p, int cpu, int flags)
 	struct rq *rq;
 
 	if (!(flags & WF_TTWU))
-		goto out;
+		return cpu;
 
 	rq = cpu_rq(cpu);
 
@@ -2211,7 +2208,6 @@ select_task_rq_dl(struct task_struct *p, int cpu, int flags)
 	}
 	rcu_read_unlock();
 
-out:
 	return cpu;
 }
 
-- 
2.47.3


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

* [PATCH 2/2] sched/deadline: Use cpumask_weight_and in dl_bw_cpus
  2025-10-14 10:03 [PATCH 0/2] sched/deadline: minor code cleanups Shrikanth Hegde
  2025-10-14 10:03 ` [PATCH 1/2] " Shrikanth Hegde
@ 2025-10-14 10:03 ` Shrikanth Hegde
  2025-11-10 14:11   ` Peter Zijlstra
                     ` (2 more replies)
  2025-10-15  8:41 ` [PATCH 0/2] sched/deadline: minor code cleanups Juri Lelli
  2 siblings, 3 replies; 12+ messages in thread
From: Shrikanth Hegde @ 2025-10-14 10:03 UTC (permalink / raw)
  To: peterz, juri.lelli, mingo, vincent.guittot
  Cc: sshegde, linux-kernel, rostedt, dietmar.eggemann, nico

- cpumask_subset(a,b) -> cpumask_weight(a) should be same as 
cpumask_weight_and(a,b)

- for_each_cpu_and(a,b) to count cpus could be replaced by
cpumask_weight_and(a,b)

No Functional Change. It could save a few cycles since cpumask_weight_and 
would be more efficient. Plus one less stack variable. 

Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
---
 kernel/sched/deadline.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index 8b7c4ee41fd8..a18f64b2e47c 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -125,20 +125,11 @@ static inline struct dl_bw *dl_bw_of(int i)
 static inline int dl_bw_cpus(int i)
 {
 	struct root_domain *rd = cpu_rq(i)->rd;
-	int cpus;
 
 	RCU_LOCKDEP_WARN(!rcu_read_lock_sched_held(),
 			 "sched RCU must be held");
 
-	if (cpumask_subset(rd->span, cpu_active_mask))
-		return cpumask_weight(rd->span);
-
-	cpus = 0;
-
-	for_each_cpu_and(i, rd->span, cpu_active_mask)
-		cpus++;
-
-	return cpus;
+	return cpumask_weight_and(rd->span, cpu_active_mask);
 }
 
 static inline unsigned long __dl_bw_capacity(const struct cpumask *mask)
-- 
2.47.3


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

* Re: [PATCH 0/2] sched/deadline: minor code cleanups
  2025-10-14 10:03 [PATCH 0/2] sched/deadline: minor code cleanups Shrikanth Hegde
  2025-10-14 10:03 ` [PATCH 1/2] " Shrikanth Hegde
  2025-10-14 10:03 ` [PATCH 2/2] sched/deadline: Use cpumask_weight_and in dl_bw_cpus Shrikanth Hegde
@ 2025-10-15  8:41 ` Juri Lelli
  2025-11-10  8:25   ` Shrikanth Hegde
  2 siblings, 1 reply; 12+ messages in thread
From: Juri Lelli @ 2025-10-15  8:41 UTC (permalink / raw)
  To: Shrikanth Hegde
  Cc: peterz, mingo, vincent.guittot, linux-kernel, rostedt,
	dietmar.eggemann, nico

Hello,

On 14/10/25 15:33, Shrikanth Hegde wrote:
> While trying to understand the dl_server changes, noticed these minor
> code optimizations/cleanups possible. 
> 
> Let me know if these should be squashed into one patch. Kept is separate
> as of now.
> 
> No change in functionality. Could save a few cycles.
> 
> Shrikanth Hegde (2):
>   sched/deadline: minor code cleanups
>   sched/deadline: Use cpumask_weight_and in dl_bw_cpus

For the series (I would keep the fixes separate)

Acked-by: Juri Lelli <juri.lelli@redhat.com>

Thanks,
Juri


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

* Re: [PATCH 0/2] sched/deadline: minor code cleanups
  2025-10-15  8:41 ` [PATCH 0/2] sched/deadline: minor code cleanups Juri Lelli
@ 2025-11-10  8:25   ` Shrikanth Hegde
  0 siblings, 0 replies; 12+ messages in thread
From: Shrikanth Hegde @ 2025-11-10  8:25 UTC (permalink / raw)
  To: Juri Lelli, peterz, mingo
  Cc: vincent.guittot, linux-kernel, rostedt, dietmar.eggemann, nico


Gentle Ping.

On 10/15/25 2:11 PM, Juri Lelli wrote:
> Hello,
> 
> On 14/10/25 15:33, Shrikanth Hegde wrote:
>> While trying to understand the dl_server changes, noticed these minor
>> code optimizations/cleanups possible.
>>
>> Let me know if these should be squashed into one patch. Kept is separate
>> as of now.
>>
>> No change in functionality. Could save a few cycles.
>>
>> Shrikanth Hegde (2):
>>    sched/deadline: minor code cleanups
>>    sched/deadline: Use cpumask_weight_and in dl_bw_cpus
> 
> For the series (I would keep the fixes separate)
> 
> Acked-by: Juri Lelli <juri.lelli@redhat.com>
> 

Thanks Juri.

> Thanks,
> Juri
> 

Hi Peter, Ingo,

Do you have any comments on this?
Should I resend collecting the tag? It applies on v6.18-rc4

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

* Re: [PATCH 1/2] sched/deadline: minor code cleanups
  2025-10-14 10:03 ` [PATCH 1/2] " Shrikanth Hegde
@ 2025-11-10 14:10   ` Peter Zijlstra
  2025-11-10 14:17     ` Peter Zijlstra
  2025-11-11 11:37   ` [tip: sched/core] sched/deadline: Minor cleanup in select_task_rq_dl() tip-bot2 for Shrikanth Hegde
  2025-11-11 16:33   ` tip-bot2 for Shrikanth Hegde
  2 siblings, 1 reply; 12+ messages in thread
From: Peter Zijlstra @ 2025-11-10 14:10 UTC (permalink / raw)
  To: Shrikanth Hegde
  Cc: juri.lelli, mingo, vincent.guittot, linux-kernel, rostedt,
	dietmar.eggemann, nico

On Tue, Oct 14, 2025 at 03:33:41PM +0530, Shrikanth Hegde wrote:
> - In dl_server_timer, there is same dl_runtime check above. So
> this check is duplicate. This could save a few cycles.
> 
> - In select_task_rq_dl, there is only one goto statement, there is
> no need for it. 
> 
> No functional changes.
> 
> Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
> ---
>  kernel/sched/deadline.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index 7b7671060bf9..8b7c4ee41fd8 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
> @@ -1166,9 +1166,6 @@ static enum hrtimer_restart dl_server_timer(struct hrtimer *timer, struct sched_
>  		sched_clock_tick();
>  		update_rq_clock(rq);
>  
> -		if (!dl_se->dl_runtime)
> -			return HRTIMER_NORESTART;
> -
>  		if (dl_se->dl_defer_armed) {
>  			/*
>  			 * First check if the server could consume runtime in background.

That one got lost here:

  https://lkml.kernel.org/r/20251020141130.GJ3245006@noisy.programming.kicks-ass.net

> @@ -2173,7 +2170,7 @@ select_task_rq_dl(struct task_struct *p, int cpu, int flags)
>  	struct rq *rq;
>  
>  	if (!(flags & WF_TTWU))
> -		goto out;
> +		return cpu;
>  
>  	rq = cpu_rq(cpu);
>  
> @@ -2211,7 +2208,6 @@ select_task_rq_dl(struct task_struct *p, int cpu, int flags)
>  	}
>  	rcu_read_unlock();
>  
> -out:
>  	return cpu;
>  }

And this is completely different code, which would suggest it ought to
have been a separate patch.

But yeah, that makes sense.

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

* Re: [PATCH 2/2] sched/deadline: Use cpumask_weight_and in dl_bw_cpus
  2025-10-14 10:03 ` [PATCH 2/2] sched/deadline: Use cpumask_weight_and in dl_bw_cpus Shrikanth Hegde
@ 2025-11-10 14:11   ` Peter Zijlstra
  2025-11-11 11:37   ` [tip: sched/core] sched/deadline: Use cpumask_weight_and() " tip-bot2 for Shrikanth Hegde
  2025-11-11 16:33   ` tip-bot2 for Shrikanth Hegde
  2 siblings, 0 replies; 12+ messages in thread
From: Peter Zijlstra @ 2025-11-10 14:11 UTC (permalink / raw)
  To: Shrikanth Hegde
  Cc: juri.lelli, mingo, vincent.guittot, linux-kernel, rostedt,
	dietmar.eggemann, nico

On Tue, Oct 14, 2025 at 03:33:42PM +0530, Shrikanth Hegde wrote:
> - cpumask_subset(a,b) -> cpumask_weight(a) should be same as 
> cpumask_weight_and(a,b)
> 
> - for_each_cpu_and(a,b) to count cpus could be replaced by
> cpumask_weight_and(a,b)
> 
> No Functional Change. It could save a few cycles since cpumask_weight_and 
> would be more efficient. Plus one less stack variable. 
> 
> Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
> ---
>  kernel/sched/deadline.c | 11 +----------
>  1 file changed, 1 insertion(+), 10 deletions(-)
> 
> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index 8b7c4ee41fd8..a18f64b2e47c 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
> @@ -125,20 +125,11 @@ static inline struct dl_bw *dl_bw_of(int i)
>  static inline int dl_bw_cpus(int i)
>  {
>  	struct root_domain *rd = cpu_rq(i)->rd;
> -	int cpus;
>  
>  	RCU_LOCKDEP_WARN(!rcu_read_lock_sched_held(),
>  			 "sched RCU must be held");
>  
> -	if (cpumask_subset(rd->span, cpu_active_mask))
> -		return cpumask_weight(rd->span);
> -
> -	cpus = 0;
> -
> -	for_each_cpu_and(i, rd->span, cpu_active_mask)
> -		cpus++;
> -
> -	return cpus;
> +	return cpumask_weight_and(rd->span, cpu_active_mask);
>  }

Right, let me stick that on top of the change I have in queue/sched/core

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

* Re: [PATCH 1/2] sched/deadline: minor code cleanups
  2025-11-10 14:10   ` Peter Zijlstra
@ 2025-11-10 14:17     ` Peter Zijlstra
  0 siblings, 0 replies; 12+ messages in thread
From: Peter Zijlstra @ 2025-11-10 14:17 UTC (permalink / raw)
  To: Shrikanth Hegde
  Cc: juri.lelli, mingo, vincent.guittot, linux-kernel, rostedt,
	dietmar.eggemann, nico

On Mon, Nov 10, 2025 at 03:10:38PM +0100, Peter Zijlstra wrote:
> On Tue, Oct 14, 2025 at 03:33:41PM +0530, Shrikanth Hegde wrote:
> > - In dl_server_timer, there is same dl_runtime check above. So
> > this check is duplicate. This could save a few cycles.
> > 
> > - In select_task_rq_dl, there is only one goto statement, there is
> > no need for it. 
> > 
> > No functional changes.
> > 
> > Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
> > ---
> >  kernel/sched/deadline.c | 6 +-----
> >  1 file changed, 1 insertion(+), 5 deletions(-)
> > 
> > diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> > index 7b7671060bf9..8b7c4ee41fd8 100644
> > --- a/kernel/sched/deadline.c
> > +++ b/kernel/sched/deadline.c
> > @@ -1166,9 +1166,6 @@ static enum hrtimer_restart dl_server_timer(struct hrtimer *timer, struct sched_
> >  		sched_clock_tick();
> >  		update_rq_clock(rq);
> >  
> > -		if (!dl_se->dl_runtime)
> > -			return HRTIMER_NORESTART;
> > -
> >  		if (dl_se->dl_defer_armed) {
> >  			/*
> >  			 * First check if the server could consume runtime in background.
> 
> That one got lost here:
> 
>   https://lkml.kernel.org/r/20251020141130.GJ3245006@noisy.programming.kicks-ass.net

I deleted this hunk and frobbed the changelog. Should be in
queue/sched/core now.

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

* [tip: sched/core] sched/deadline: Minor cleanup in select_task_rq_dl()
  2025-10-14 10:03 ` [PATCH 1/2] " Shrikanth Hegde
  2025-11-10 14:10   ` Peter Zijlstra
@ 2025-11-11 11:37   ` tip-bot2 for Shrikanth Hegde
  2025-11-11 16:33   ` tip-bot2 for Shrikanth Hegde
  2 siblings, 0 replies; 12+ messages in thread
From: tip-bot2 for Shrikanth Hegde @ 2025-11-11 11:37 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Shrikanth Hegde, Peter Zijlstra (Intel), Juri Lelli, x86,
	linux-kernel

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

Commit-ID:     46f61fb2e7678daae743d601efac3b957041ed56
Gitweb:        https://git.kernel.org/tip/46f61fb2e7678daae743d601efac3b957041ed56
Author:        Shrikanth Hegde <sshegde@linux.ibm.com>
AuthorDate:    Tue, 14 Oct 2025 15:33:41 +05:30
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Tue, 11 Nov 2025 12:33:40 +01:00

sched/deadline: Minor cleanup in select_task_rq_dl()

In select_task_rq_dl, there is only one goto statement, there is no
need for it.

No functional changes.

Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Juri Lelli <juri.lelli@redhat.com>
Link: https://patch.msgid.link/20251014100342.978936-2-sshegde@linux.ibm.com
---
 kernel/sched/deadline.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index e46df89..141c9b9 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -2384,7 +2384,7 @@ select_task_rq_dl(struct task_struct *p, int cpu, int flags)
 	struct rq *rq;
 
 	if (!(flags & WF_TTWU))
-		goto out;
+		return cpu;
 
 	rq = cpu_rq(cpu);
 
@@ -2422,7 +2422,6 @@ select_task_rq_dl(struct task_struct *p, int cpu, int flags)
 	}
 	rcu_read_unlock();
 
-out:
 	return cpu;
 }
 

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

* [tip: sched/core] sched/deadline: Use cpumask_weight_and() in dl_bw_cpus
  2025-10-14 10:03 ` [PATCH 2/2] sched/deadline: Use cpumask_weight_and in dl_bw_cpus Shrikanth Hegde
  2025-11-10 14:11   ` Peter Zijlstra
@ 2025-11-11 11:37   ` tip-bot2 for Shrikanth Hegde
  2025-11-11 16:33   ` tip-bot2 for Shrikanth Hegde
  2 siblings, 0 replies; 12+ messages in thread
From: tip-bot2 for Shrikanth Hegde @ 2025-11-11 11:37 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Shrikanth Hegde, Peter Zijlstra (Intel), Juri Lelli, x86,
	linux-kernel

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

Commit-ID:     7259e53915cc99298952a35aa8772d33d1e51866
Gitweb:        https://git.kernel.org/tip/7259e53915cc99298952a35aa8772d33d1e51866
Author:        Shrikanth Hegde <sshegde@linux.ibm.com>
AuthorDate:    Tue, 14 Oct 2025 15:33:42 +05:30
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Tue, 11 Nov 2025 12:33:39 +01:00

sched/deadline: Use cpumask_weight_and() in dl_bw_cpus

cpumask_subset(a,b) -> cpumask_weight(a) should be same as cpumask_weight_and(a,b)
for_each_cpu_and(a,b) to count cpus could be replaced by cpumask_weight_and(a,b)

No Functional Change. It could save a few cycles since cpumask_weight_and
would be more efficient. Plus one less stack variable.

Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Juri Lelli <juri.lelli@redhat.com>
Link: https://patch.msgid.link/20251014100342.978936-3-sshegde@linux.ibm.com
---
 kernel/sched/deadline.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index 4d6eaf2..e46df89 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -125,20 +125,11 @@ static inline struct dl_bw *dl_bw_of(int i)
 static inline int dl_bw_cpus(int i)
 {
 	struct root_domain *rd = cpu_rq(i)->rd;
-	int cpus;
 
 	RCU_LOCKDEP_WARN(!rcu_read_lock_sched_held(),
 			 "sched RCU must be held");
 
-	if (cpumask_subset(rd->span, cpu_active_mask))
-		return cpumask_weight(rd->span);
-
-	cpus = 0;
-
-	for_each_cpu_and(i, rd->span, cpu_active_mask)
-		cpus++;
-
-	return cpus;
+	return cpumask_weight_and(rd->span, cpu_active_mask);
 }
 
 static inline unsigned long __dl_bw_capacity(const struct cpumask *mask)

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

* [tip: sched/core] sched/deadline: Minor cleanup in select_task_rq_dl()
  2025-10-14 10:03 ` [PATCH 1/2] " Shrikanth Hegde
  2025-11-10 14:10   ` Peter Zijlstra
  2025-11-11 11:37   ` [tip: sched/core] sched/deadline: Minor cleanup in select_task_rq_dl() tip-bot2 for Shrikanth Hegde
@ 2025-11-11 16:33   ` tip-bot2 for Shrikanth Hegde
  2 siblings, 0 replies; 12+ messages in thread
From: tip-bot2 for Shrikanth Hegde @ 2025-11-11 16:33 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Shrikanth Hegde, Peter Zijlstra (Intel), Juri Lelli, x86,
	linux-kernel

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

Commit-ID:     65177ea9f64d7402a0b8028e0dbbd01e8a9d1b1d
Gitweb:        https://git.kernel.org/tip/65177ea9f64d7402a0b8028e0dbbd01e8a9d1b1d
Author:        Shrikanth Hegde <sshegde@linux.ibm.com>
AuthorDate:    Tue, 14 Oct 2025 15:33:41 +05:30
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Tue, 11 Nov 2025 17:27:55 +01:00

sched/deadline: Minor cleanup in select_task_rq_dl()

In select_task_rq_dl, there is only one goto statement, there is no
need for it.

No functional changes.

Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Juri Lelli <juri.lelli@redhat.com>
Link: https://patch.msgid.link/20251014100342.978936-2-sshegde@linux.ibm.com
---
 kernel/sched/deadline.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index 4dd4b2f..67f540c 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -2384,7 +2384,7 @@ select_task_rq_dl(struct task_struct *p, int cpu, int flags)
 	struct rq *rq;
 
 	if (!(flags & WF_TTWU))
-		goto out;
+		return cpu;
 
 	rq = cpu_rq(cpu);
 
@@ -2422,7 +2422,6 @@ select_task_rq_dl(struct task_struct *p, int cpu, int flags)
 	}
 	rcu_read_unlock();
 
-out:
 	return cpu;
 }
 

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

* [tip: sched/core] sched/deadline: Use cpumask_weight_and() in dl_bw_cpus
  2025-10-14 10:03 ` [PATCH 2/2] sched/deadline: Use cpumask_weight_and in dl_bw_cpus Shrikanth Hegde
  2025-11-10 14:11   ` Peter Zijlstra
  2025-11-11 11:37   ` [tip: sched/core] sched/deadline: Use cpumask_weight_and() " tip-bot2 for Shrikanth Hegde
@ 2025-11-11 16:33   ` tip-bot2 for Shrikanth Hegde
  2 siblings, 0 replies; 12+ messages in thread
From: tip-bot2 for Shrikanth Hegde @ 2025-11-11 16:33 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Shrikanth Hegde, Peter Zijlstra (Intel), Juri Lelli, x86,
	linux-kernel

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

Commit-ID:     b4bfacd39216755c058f6d13c71c86a9bf5a1631
Gitweb:        https://git.kernel.org/tip/b4bfacd39216755c058f6d13c71c86a9bf5a1631
Author:        Shrikanth Hegde <sshegde@linux.ibm.com>
AuthorDate:    Tue, 14 Oct 2025 15:33:42 +05:30
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Tue, 11 Nov 2025 17:27:55 +01:00

sched/deadline: Use cpumask_weight_and() in dl_bw_cpus

cpumask_subset(a,b) -> cpumask_weight(a) should be same as cpumask_weight_and(a,b)
for_each_cpu_and(a,b) to count cpus could be replaced by cpumask_weight_and(a,b)

No Functional Change. It could save a few cycles since cpumask_weight_and
would be more efficient. Plus one less stack variable.

Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Juri Lelli <juri.lelli@redhat.com>
Link: https://patch.msgid.link/20251014100342.978936-3-sshegde@linux.ibm.com
---
 kernel/sched/deadline.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index e958cf9..4dd4b2f 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -125,20 +125,11 @@ static inline struct dl_bw *dl_bw_of(int i)
 static inline int dl_bw_cpus(int i)
 {
 	struct root_domain *rd = cpu_rq(i)->rd;
-	int cpus;
 
 	RCU_LOCKDEP_WARN(!rcu_read_lock_sched_held(),
 			 "sched RCU must be held");
 
-	if (cpumask_subset(rd->span, cpu_active_mask))
-		return cpumask_weight(rd->span);
-
-	cpus = 0;
-
-	for_each_cpu_and(i, rd->span, cpu_active_mask)
-		cpus++;
-
-	return cpus;
+	return cpumask_weight_and(rd->span, cpu_active_mask);
 }
 
 static inline unsigned long __dl_bw_capacity(const struct cpumask *mask)

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

end of thread, other threads:[~2025-11-11 16:33 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-14 10:03 [PATCH 0/2] sched/deadline: minor code cleanups Shrikanth Hegde
2025-10-14 10:03 ` [PATCH 1/2] " Shrikanth Hegde
2025-11-10 14:10   ` Peter Zijlstra
2025-11-10 14:17     ` Peter Zijlstra
2025-11-11 11:37   ` [tip: sched/core] sched/deadline: Minor cleanup in select_task_rq_dl() tip-bot2 for Shrikanth Hegde
2025-11-11 16:33   ` tip-bot2 for Shrikanth Hegde
2025-10-14 10:03 ` [PATCH 2/2] sched/deadline: Use cpumask_weight_and in dl_bw_cpus Shrikanth Hegde
2025-11-10 14:11   ` Peter Zijlstra
2025-11-11 11:37   ` [tip: sched/core] sched/deadline: Use cpumask_weight_and() " tip-bot2 for Shrikanth Hegde
2025-11-11 16:33   ` tip-bot2 for Shrikanth Hegde
2025-10-15  8:41 ` [PATCH 0/2] sched/deadline: minor code cleanups Juri Lelli
2025-11-10  8:25   ` Shrikanth Hegde

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