From: hupu <hupu.gm@gmail.com>
To: jstultz@google.com, linux-kernel@vger.kernel.org
Cc: juri.lelli@redhat.com, peterz@infradead.org, vschneid@redhat.com,
mingo@redhat.com, vincent.guittot@linaro.org,
dietmar.eggemann@arm.com, rostedt@goodmis.org,
bsegall@google.com, mgorman@suse.de, hupu@transsion.com,
hupu <hupu.gm@gmail.com>
Subject: [RFC 1/1] sched: Skip redundant operations for proxy tasks needing return migration
Date: Mon, 7 Apr 2025 21:47:12 +0800 [thread overview]
Message-ID: <20250407134712.93062-1-hupu.gm@gmail.com> (raw)
Move the proxy_needs_return() check earlier in ttwu_runnable() to avoid
unnecessary scheduling operations when a proxy task requires return
migration to its original CPU.
The current implementation performs several operations (rq clock update,
enqueue, and wakeup preemption checks) before checking for return
migration needs. This is inefficient because:
1. For tasks needing return migration, these operations are redundant
since the task will be dequeued from current rq anyway
2. The task may not even be allowed to run on current CPU due to
possible affinity changes during blocking
3. The proper CPU selection will be handled by select_task_rq() in
the subsequent try_to_wake_up() logic
By moving the proxy_needs_return() check to the beginning, we:
- Avoid unnecessary rq clock updates
- Skip redundant enqueue operations
- Eliminate meaningless wakeup preemption checks
- Let the normal wakeup path handle proper CPU selection
This optimization is particularly valuable in proxy execution scenarios
where tasks frequently migrate between CPUs.
Signed-off-by: hupu <hupu.gm@gmail.com>
---
kernel/sched/core.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index ca4ca739eb85..ebb4bc1800e3 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4162,6 +4162,10 @@ static int ttwu_runnable(struct task_struct *p, int wake_flags)
rq = __task_rq_lock(p, &rf);
if (task_on_rq_queued(p)) {
+ if (proxy_needs_return(rq, p)) {
+ _trace_sched_pe_return_migration(p);
+ goto out;
+ }
update_rq_clock(rq);
if (p->se.sched_delayed) {
proxy_remove_from_sleeping_owner(p);
@@ -4174,10 +4178,6 @@ static int ttwu_runnable(struct task_struct *p, int wake_flags)
*/
wakeup_preempt(rq, p, wake_flags);
}
- if (proxy_needs_return(rq, p)) {
- _trace_sched_pe_return_migration(p);
- goto out;
- }
ttwu_do_wakeup(p);
ret = 1;
}
--
2.47.0
next reply other threads:[~2025-04-07 13:47 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-07 13:47 hupu [this message]
2025-04-09 7:11 ` hupu
2025-04-10 2:41 ` John Stultz
2025-04-10 9:51 ` hupu
2025-04-17 0:23 ` John Stultz
2025-04-17 0:24 ` John Stultz
2025-04-17 2:29 ` hupu
2025-05-18 14:51 ` hupu
2025-05-25 7:43 ` [RESEND RFC V2 " hupu
2025-05-28 6:24 ` [RFC " John Stultz
2025-06-04 8:13 ` hupu
2025-06-05 14:50 ` hupu
2025-06-11 2:32 ` hupu
2025-06-11 5:05 ` John Stultz
2025-06-11 6:16 ` hupu
2025-06-12 9:57 ` hupu
2025-06-14 5:20 ` John Stultz
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=20250407134712.93062-1-hupu.gm@gmail.com \
--to=hupu.gm@gmail.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=hupu@transsion.com \
--cc=jstultz@google.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
/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
all inboxes | Powered by JetHome®