[PATCH v3 6/6] sched/core: Pause KCOV in wake_up_new_task()

From: Karl Mehltretter

Date: Mon Sep 14 2026 - 01:50:54 EST


wake_up_new_task() is built without KCOV instrumentation, but CPU
selection and enqueue call instrumented helpers. During a KCOV-enabled
fork, they can record scheduler, hrtimer and clockevent coverage into the
parent.

The paths depend on runqueue and CPU state, so coverage varies between
identical forks. Pause KCOV for the whole function, extending the
scheduler exclusion to new-task wakeups.

Assisted-by: LLM
Signed-off-by: Karl Mehltretter <kmehltretter@xxxxxxxxx>
---
kernel/sched/core.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index e3b50bbdf3a9..a669f8d99653 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4962,6 +4962,9 @@ void wake_up_new_task(struct task_struct *p)
struct rq *rq;
int wake_flags = WF_FORK;

+ /* Instrumented callees would leak coverage into current. */
+ guard(kcov_pause)();
+
raw_spin_lock_irqsave(&p->pi_lock, rf.flags);
WRITE_ONCE(p->__state, TASK_RUNNING);
/*
--
2.53.0