Skip to contentSkip to conversation

sched/fair: Document the slow path and fast path in select_task_rq_fair

PATCH Applied Barry Song 3 participants 3 messages Oct 16, 2021 – Dec 7, 2021 Scheduler

lore
Share & tools
lore

Barry Song

author
#0 lore raw

PATCH v2 1/1 sched/fair: Document the slow path and fast path in select_task_rq_fair

From: Barry Song <[email protected]>

All People I know including myself took a long time to figure out that typical wakeup will always go to fast path and never go to slow path except WF_FORK and WF_EXEC.
Vincent reminded me once in a linaro meeting and made me understand slow path won't happen for WF_TTWU. But my other friends repeatedly wasted a lot of time on testing this path like me before I reminded them.
So obviously the code needs some document.

Cc Vincent Guittot <[email protected]>

---
-v2: refine according to Steven's comments, thanks!

 kernel/sched/fair.c | 5 +++++
 1 file changed, 5 insertions(+)
kernel/sched/fair.c +5 -0
index f6a05d9b5443..816c8ddf1b6d 100644
@@ -6951,6 +6951,11 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int wake_flags)
 			break;
 		}
 
+		/*
+		 * Usually only true for WF_EXEC and WF_FORK, as sched_domains
+		 * usually do not have SD_BALANCE_WAKE set. That means wakeup
+		 * will usually go to the fast path.
+		 */
 		if (tmp->flags & sd_flag)
 			sd = tmp;
 		else if (!want_affine)
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 11 lines · Barry Song

From: Barry Song <[email protected]>

All People I know including myself took a long time to figure out that typical wakeup will always go to fast path and never go to slow path except WF_FORK and WF_EXEC.
Vincent reminded me once in a linaro meeting and made me understand slow path won't happen for WF_TTWU. But my other friends repeatedly wasted a lot of time on testing this path like me before I reminded them.
So obviously the code needs some document.

Quoted 3 lines
Cc Vincent Guittot <[email protected]>

---

Thanks!

merge bot Applied
#2 lore raw
In reply to Barry Song
The following commit has been merged into the sched/core branch of tip:

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

Commit-ID:     2917406c352757642c3c1a13a4c99c96e6d22fde
Gitweb:        https://git.kernel.org/tip/2917406c352757642c3c1a13a4c99c96e6d22fde
Author:        Barry Song <[email protected]>
AuthorDate:    Sat, 16 Oct 2021 19:11:09 +08:00
Committer:     Peter Zijlstra <[email protected]>
CommitterDate: Tue, 07 Dec 2021 15:14:10 +01:00

sched/fair: Document the slow path and fast path in select_task_rq_fair

All People I know including myself took a long time to figure out that typical wakeup will always go to fast path and never go to slow path except WF_FORK and WF_EXEC.

Vincent reminded me once in a linaro meeting and made me understand slow path won't happen for WF_TTWU. But my other friends repeatedly wasted a lot of time on testing this path like me before I reminded them.

So obviously the code needs some document.

---
 kernel/sched/fair.c | 5 +++++
 1 file changed, 5 insertions(+)
kernel/sched/fair.c +5 -0
index 0672218..f34f2f3 100644
@@ -6917,6 +6917,11 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int wake_flags)
 			break;
 		}
 
+		/*
+		 * Usually only true for WF_EXEC and WF_FORK, as sched_domains
+		 * usually do not have SD_BALANCE_WAKE set. That means wakeup
+		 * will usually go to the fast path.
+		 */
 		if (tmp->flags & sd_flag)
 			sd = tmp;
 		else if (!want_affine)