Skip to contentSkip to conversation

sched/core: Skip sched_core_fork/free() when core sched is disabled

PATCH In review Cruz Zhao 2 participants 3 messages Apr 24, 2022 – Apr 25, 2022 Scheduler

lore
Share & tools
lore

Cruz Zhao

author
#0 lore raw

PATCH v2 1/1 sched/core: Skip sched_core_fork/free() when core sched is disabled

As __put_task_struct() and copy_process() are hot path functions, the call of sched_core_fork/free() will bring overhead when core sched is disabled, and we skip them in these cases.

---
 kernel/sched/core_sched.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
kernel/sched/core_sched.c +6 -3
index 38a2cec..72a8ef8 100644
@@ -108,13 +108,16 @@ static unsigned long sched_core_clone_cookie(struct task_struct *p)
 
 void sched_core_fork(struct task_struct *p)
 {
-	RB_CLEAR_NODE(&p->core_node);
-	p->core_cookie = sched_core_clone_cookie(current);
+	if (!sched_core_disabled()) {
+		RB_CLEAR_NODE(&p->core_node);
+		p->core_cookie = sched_core_clone_cookie(current);
+	}
 }
 
 void sched_core_free(struct task_struct *p)
 {
-	sched_core_put_cookie(p->core_cookie);
+	if (!sched_core_disabled())
+		sched_core_put_cookie(p->core_cookie);
 }
 
 static void __sched_core_set(struct task_struct *p, unsigned long cookie)
Signature · 1 line
1.8.3.1
maintainer
#1 lore raw
Quoted 3 lines · Cruz Zhao

As __put_task_struct() and copy_process() are hot path functions, the call of sched_core_fork/free() will bring overhead when core sched is disabled, and we skip them in these cases.

Only if you have profile data.. mostly these functions do whole lot of nothing.

author
#2 lore raw
Quoted 7 lines · Peter Zijlstra
Quoted 3 lines · Cruz Zhao

As __put_task_struct() and copy_process() are hot path functions, the call of sched_core_fork/free() will bring overhead when core sched is disabled, and we skip them in these cases.

Only if you have profile data.. mostly these functions do whole lot of nothing.

Many thanks for suggestion, I'll test it.

Best wishes,
Cruz Zhao