From: Karl Mehltretter <kmehltretter@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Karl Mehltretter <kmehltretter@gmail.com>,
Andrey Konovalov <andreyknvl@gmail.com>,
Dmitry Vyukov <dvyukov@google.com>,
Alexander Potapenko <glider@google.com>,
Marco Elver <elver@google.com>,
Bradley Morgan <include@grrlz.net>,
kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Steven Rostedt <rostedt@goodmis.org>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Clark Williams <clrkwllms@kernel.org>,
linux-rt-devel@lists.linux.dev
Subject: [PATCH 4/5] sched: pause KCOV in try_to_wake_up()
Date: Fri, 7 Aug 2026 22:50:26 +0200 [thread overview]
Message-ID: <20260807205027.31972-5-kmehltretter@gmail.com> (raw)
In-Reply-To: <20260807205027.31972-1-kmehltretter@gmail.com>
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 all of try_to_wake_up(). Wrapping only select_task_rq() would miss
SCHED_HRTICK arming during enqueue.
Fixes: 5c9a8750a640 ("kernel: add kcov code coverage")
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>
---
kernel/sched/core.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index d5663df6c702..1e562a7ff0af 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4252,6 +4252,8 @@ int try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
{
guard(preempt)();
int cpu, success = 0;
+ /* KCOV: sched/ is uninstrumented but the wakeup callees are not. */
+ unsigned int kcov_paused = kcov_pause(current);
wake_flags |= WF_TTWU;
@@ -4418,6 +4420,7 @@ int try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
if (success)
ttwu_stat(p, task_cpu(p), wake_flags);
+ kcov_resume(current, kcov_paused);
return success;
}
--
2.53.0
next prev parent reply other threads:[~2026-08-07 20:50 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-07 20:50 [PATCH 0/5] kcov: suppress timer and scheduler coverage leaks Karl Mehltretter
2026-08-07 20:50 ` [PATCH 1/5] kcov: add kcov_pause()/kcov_resume() helpers Karl Mehltretter
2026-08-08 1:16 ` Bradley Morgan
2026-08-07 20:50 ` [PATCH 2/5] hrtimer: pause KCOV during deferred rearm Karl Mehltretter
2026-08-08 1:19 ` Bradley Morgan
2026-08-07 20:50 ` [PATCH 3/5] sched: pause KCOV in __schedule() Karl Mehltretter
2026-08-08 1:21 ` Bradley Morgan
2026-08-07 20:50 ` Karl Mehltretter [this message]
2026-08-07 21:00 ` [PATCH 4/5] sched: pause KCOV in try_to_wake_up() sashiko-bot
2026-08-08 1:28 ` Bradley Morgan
2026-08-07 20:50 ` [PATCH 5/5] sched: pause KCOV in wake_up_new_task() Karl Mehltretter
2026-08-08 1:36 ` Bradley Morgan
2026-08-10 21:57 ` Karl Mehltretter
2026-08-08 8:44 ` [PATCH 0/5] kcov: suppress timer and scheduler coverage leaks Peter Zijlstra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260807205027.31972-5-kmehltretter@gmail.com \
--to=kmehltretter@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=andreyknvl@gmail.com \
--cc=bigeasy@linutronix.de \
--cc=clrkwllms@kernel.org \
--cc=dvyukov@google.com \
--cc=elver@google.com \
--cc=glider@google.com \
--cc=include@grrlz.net \
--cc=juri.lelli@redhat.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.