public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Cyrill Gorcunov <gorcunov@gmail.com>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>, Peter Zijlstra <peterz@infradead.org>
Subject: [PATCH] sched/core: Drop unused return code of context_switch()
Date: Mon, 26 Aug 2024 00:01:24 +0300	[thread overview]
Message-ID: <ZsubpFiRXXvkxZzw@grain> (raw)

Since the commit 565790d28b1e @rq returned by finish_task_switch -> context_switch
call chain is not longer used by __schedule() so there is no need to keep it (and
compiler already optimize it out).

CC: Ingo Molnar <mingo@redhat.com>
CC: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
Initially I thought there might be some hidden use of @rq returned by finish_task_switch
but didn't notice any even potential future use, thus until I miss something we're safe
to drop this redundant return variable.

 kernel/sched/core.c |   10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

Index: linux-tip.git/kernel/sched/core.c
===================================================================
--- linux-tip.git.orig/kernel/sched/core.c
+++ linux-tip.git/kernel/sched/core.c
@@ -5088,7 +5088,7 @@ prepare_task_switch(struct rq *rq, struc
  * past. 'prev == current' is still correct but we need to recalculate this_rq
  * because prev may have moved to another CPU.
  */
-static struct rq *finish_task_switch(struct task_struct *prev)
+static void finish_task_switch(struct task_struct *prev)
 	__releases(rq->lock)
 {
 	struct rq *rq = this_rq();
@@ -5168,8 +5168,6 @@ static struct rq *finish_task_switch(str
 
 		put_task_struct_rcu_user(prev);
 	}
-
-	return rq;
 }
 
 /**
@@ -5200,7 +5198,7 @@ asmlinkage __visible void schedule_tail(
 /*
  * context_switch - switch to the new MM and the new thread's register state.
  */
-static __always_inline struct rq *
+static __always_inline void
 context_switch(struct rq *rq, struct task_struct *prev,
 	       struct task_struct *next, struct rq_flags *rf)
 {
@@ -5260,7 +5258,7 @@ context_switch(struct rq *rq, struct tas
 	switch_to(prev, next, prev);
 	barrier();
 
-	return finish_task_switch(prev);
+	finish_task_switch(prev);
 }
 
 /*
@@ -6602,7 +6600,7 @@ static void __sched notrace __schedule(u
 		trace_sched_switch(sched_mode & SM_MASK_PREEMPT, prev, next, prev_state);
 
 		/* Also unlocks the rq: */
-		rq = context_switch(rq, prev, next, &rf);
+		context_switch(rq, prev, next, &rf);
 	} else {
 		rq_unpin_lock(rq, &rf);
 		__balance_callbacks(rq);

                 reply	other threads:[~2024-08-25 21:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZsubpFiRXXvkxZzw@grain \
    --to=gorcunov@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox