Re: [PATCH v2 5/6] sched/core: Pause KCOV in try_to_wake_up()

From: Peter Zijlstra

Date: Wed Aug 12 2026 - 06:42:33 EST


On Tue, Aug 11, 2026 at 05:41:10PM +0200, Karl Mehltretter wrote:
> try_to_wake_up() is uninstrumented, but it calls instrumented helpers
> such as kthread_is_per_cpu(), CPU capacity helpers and SCHED_HRTICK
> arming. They can record into current while in_task() is true.
>
> CONFIG_KCOV_SELFTEST exposes this under PREEMPT_RT. The interrupt
> selftest fails on x86_64 in kthread_is_per_cpu(): RT runs the timer
> softirq in a thread, so the wakeup runs in task context during the
> selftest's spin. The same helpers leak into non-RT syscall wakeups such
> as a pipe write waking a reader.
>
> Pause the wakeup body with the kcov_pause guard. Wrapping only
> select_task_rq() would miss SCHED_HRTICK arming during enqueue.
>
> Fixes: 5c9a8750a640 ("kernel: add kcov code coverage")
> Assisted-by: Claude:claude-fable-5
> Signed-off-by: Karl Mehltretter <kmehltretter@xxxxxxxxx>
> ---
> Notes:
> v2:
> - take guard(kcov_pause)()
> - describe the paused wakeup body precisely
>
> kernel/sched/core.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index e49f0bfa0ca73..e863fac02e38f 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -4253,6 +4253,9 @@ int try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
> guard(preempt)();
> int cpu, success = 0;
>
> + /* Instrumented callees would leak coverage into current. */
> + guard(kcov_pause)();

Same problem again. All of this code is instrumented.