[PATCH 5/5] sched: pause KCOV in wake_up_new_task()
From: Karl Mehltretter
Date: Fri Aug 07 2026 - 16:51:07 EST
wake_up_new_task() is uninstrumented, 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.
Fixes: 5c9a8750a640 ("kernel: add kcov code coverage")
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Karl Mehltretter <kmehltretter@xxxxxxxxx>
---
kernel/sched/core.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 1e562a7ff0afb..cad1b01063450 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4945,8 +4945,12 @@ void wake_up_new_task(struct task_struct *p)
{
struct rq_flags rf;
struct rq *rq;
+ unsigned int kcov_paused;
int wake_flags = WF_FORK;
+ /* KCOV: sched/ is uninstrumented but the wakeup callees are not. */
+ kcov_paused = kcov_pause(current);
+
raw_spin_lock_irqsave(&p->pi_lock, rf.flags);
WRITE_ONCE(p->__state, TASK_RUNNING);
/*
@@ -4976,6 +4980,7 @@ void wake_up_new_task(struct task_struct *p)
rq_repin_lock(rq, &rf);
}
task_rq_unlock(rq, p, &rf);
+ kcov_resume(current, kcov_paused);
}
#ifdef CONFIG_PREEMPT_NOTIFIERS
--
2.53.0