Skip to contentSkip to conversation

sched/core: Drop unused return code of context_switch()

PATCH New Cyrill Gorcunov 1 participant 1 message Aug 25, 2024 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched/core: Drop unused return code of context_switch()

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 <[email protected]>
CC Peter Zijlstra <[email protected]>

---
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(-)
kernel/sched/core.c +4 -6
Index: 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);