[PATCH 1/2] sched/deadline: minor code cleanups

Shrikanth Hegde posted 2 patches 2 months ago
[PATCH 1/2] sched/deadline: minor code cleanups
Posted by Shrikanth Hegde 2 months ago
- 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
Re: [PATCH 1/2] sched/deadline: minor code cleanups
Posted by Peter Zijlstra 1 month, 1 week ago
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.
Re: [PATCH 1/2] sched/deadline: minor code cleanups
Posted by Peter Zijlstra 1 month, 1 week ago
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.
[tip: sched/core] sched/deadline: Minor cleanup in select_task_rq_dl()
Posted by tip-bot2 for Shrikanth Hegde 1 month, 1 week ago
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;
 }
 
[tip: sched/core] sched/deadline: Minor cleanup in select_task_rq_dl()
Posted by tip-bot2 for Shrikanth Hegde 1 month, 1 week ago
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;
 }