lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211015041412.5569-1-21cnbao@gmail.com>
Date:   Fri, 15 Oct 2021 12:14:12 +0800
From:   Barry Song <21cnbao@...il.com>
To:     mingo@...hat.com, peterz@...radead.org, juri.lelli@...hat.com,
        vincent.guittot@...aro.org, dietmar.eggemann@....com,
        rostedt@...dmis.org, bsegall@...gle.com, mgorman@...e.de,
        bristot@...hat.com
Cc:     linux-kernel@...r.kernel.org, linuxarm@...wei.com,
        yangyicong@...ilicon.com, Barry Song <song.bao.hua@...ilicon.com>
Subject: [PATCH] sched/fair: document the slow path and fast path in select_task_rq_fair

From: Barry Song <song.bao.hua@...ilicon.com>

All people I know including myself took a long time to understand typical
wake_up will always go to fast path and never go to slow path except
FORK and EXEC.
Vincent reminded me once in a linaro meeting and it 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 <vincent.guittot@...aro.org>
Signed-off-by: Barry Song <song.bao.hua@...ilicon.com>
---
 kernel/sched/fair.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index f6a05d9b5443..ccf8f73dd4d1 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -6951,6 +6951,11 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int wake_flags)
 			break;
 		}
 
+		/*
+		 * This is usually true only for WF_EXEC and WF_FORK, for WF_TTWU
+		 * it is almost always false as sched_domain hasn't SD_BALANCE_WAKE
+		 * in default
+		 */
 		if (tmp->flags & sd_flag)
 			sd = tmp;
 		else if (!want_affine)
@@ -6958,7 +6963,11 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int wake_flags)
 	}
 
 	if (unlikely(sd)) {
-		/* Slow path */
+		/*
+		 * Slow path, usually only for WF_EXEC and WF_FORK; WF_TTWU almost
+		 * always goes to fast path as sched_domain hasn't SD_BALANCE_WAKE
+		 * in default
+		 */
 		new_cpu = find_idlest_cpu(sd, p, cpu, prev_cpu, sd_flag);
 	} else if (wake_flags & WF_TTWU) { /* XXX always ? */
 		/* Fast path */
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ