From: sashiko-bot@kernel.org
To: "Jinchao Wang" <wangjinchao600@gmail.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [RFC PATCH 10/13] mm/kwatch: add anchor thread for global watchpoints
Date: Tue, 14 Jul 2026 18:48:29 +0000 [thread overview]
Message-ID: <20260714184830.485E31F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260714183253.12848-1-wangjinchao600@gmail.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] The anchor thread sleeps in TASK_UNINTERRUPTIBLE, artificially inflating the system load average and risking hung task panics.
- [Medium] The thread's polling loop violates voluntary sleeping rules by checking the exit condition before setting the task state, leading to a lost wakeup.
- [Low] The function `kwatch_auto_stop()` is called in the work handler but is never implemented in the patch, leading to a build failure.
--
--- Patch [10]: [RFC PATCH 10/13] mm/kwatch: add anchor thread for global watchpoints ---
commit e6c643e7bd2882c0ca1793a1b13c96d1e132942e
Author: Jinchao Wang <wangjinchao600@gmail.com>
mm/kwatch: add anchor thread for global watchpoints
Global variables have no function whose execution can bound the
watch window. Provide one: a kernel thread sleeps for the configured
duration inside a dedicated noinline function, kwatch_global_anchor(),
and the probe runtime hooks that function like any other target.
> diff --git a/mm/kwatch/anchor.c b/mm/kwatch/anchor.c
> new file mode 100644
> index 0000000000000..11da6aff94133
> --- /dev/null
> +++ b/mm/kwatch/anchor.c
> @@ -0,0 +1,82 @@
[ ... ]
> +static void kwatch_auto_stop_handler(struct work_struct *work)
> +{
> + kwatch_auto_stop();
[Severity: Low]
Does this cause a build failure? This function appears to be referenced
here but isn't implemented in this patch, which could lead to an undefined
symbol linker error and break bisectability.
> +}
> +
> +static DECLARE_WORK(kwatch_auto_stop_work, kwatch_auto_stop_handler);
> +
> +noinline void kwatch_global_anchor(unsigned long duration_sec)
> +{
> + wait_event_timeout(kwatch_anchor_wq, kthread_should_stop(),
> + duration_sec * HZ);
[Severity: High]
Does this use of wait_event_timeout risk triggering the hung task
watchdog? Because wait_event_timeout implicitly uses TASK_UNINTERRUPTIBLE,
long watch durations could trigger a panic (if the watchdog is configured)
and permanently inflate the system load average by 1.0 during the session.
> +}
> +
> +static int kwatch_anchor_thread_fn(void *data)
> +{
> + unsigned long duration = (unsigned long)data;
> +
> + kwatch_global_anchor(duration);
> +
> + if (!kthread_should_stop()) {
> + /* mark before scheduling; cleared under the control mutex */
> + WRITE_ONCE(kwatch_anchor_expired, true);
> + schedule_work(&kwatch_auto_stop_work);
> + }
> +
> + while (!kthread_should_stop())
> + schedule_timeout_uninterruptible(HZ);
[Severity: High]
Can this loop also artificially inflate the load average? Sleeping
in TASK_UNINTERRUPTIBLE here will add to the system load while waiting
for teardown.
[Severity: Medium]
Could this sequence result in a lost wakeup? The stop condition is checked
before the task state is set. If kthread_stop() signals the thread
after the while condition is evaluated but before
schedule_timeout_uninterruptible() sets the state to TASK_UNINTERRUPTIBLE,
the thread might sleep for an unnecessary second before observing the stop
flag.
> +
> + return 0;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260714182243.10687-1-wangjinchao600@gmail.com?part=10
next prev parent reply other threads:[~2026-07-14 18:48 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-14 18:22 [RFC PATCH 00/13] mm/kwatch: dynamic hardware watchpoints for hunting memory corruption Jinchao Wang
2026-07-14 18:22 ` [RFC PATCH 01/13] arch: add HAVE_REINSTALL_HW_BREAKPOINT Jinchao Wang
2026-07-14 18:22 ` [RFC PATCH 02/13] x86/hw_breakpoint: Unify breakpoint install/uninstall Jinchao Wang
2026-07-14 18:47 ` sashiko-bot
2026-07-14 18:22 ` [RFC PATCH 03/13] x86/hw_breakpoint: Add arch_reinstall_hw_breakpoint Jinchao Wang
2026-07-14 19:22 ` sashiko-bot
2026-07-14 18:30 ` [RFC PATCH 04/13] HWBP: Add modify_wide_hw_breakpoint_local() API Jinchao Wang
2026-07-14 19:41 ` sashiko-bot
2026-07-14 18:31 ` [RFC PATCH 05/13] mm/kwatch: add watch expression parser and dereference engine Jinchao Wang
2026-07-14 18:45 ` sashiko-bot
2026-07-14 18:31 ` [RFC PATCH 06/13] mm/kwatch: add lockless per-task context pool Jinchao Wang
2026-07-14 18:44 ` sashiko-bot
2026-07-14 18:31 ` [RFC PATCH 07/13] stacktrace: export stack_trace_save_regs() Jinchao Wang
2026-07-14 18:42 ` sashiko-bot
2026-07-14 18:32 ` [RFC PATCH 08/13] mm/kwatch: add hardware breakpoint backend Jinchao Wang
2026-07-14 18:50 ` sashiko-bot
2026-07-14 21:14 ` Steven Rostedt
2026-07-14 18:32 ` [RFC PATCH 09/13] mm/kwatch: add probe lifecycle runtime Jinchao Wang
2026-07-14 19:53 ` sashiko-bot
2026-07-14 18:32 ` [RFC PATCH 10/13] mm/kwatch: add anchor thread for global watchpoints Jinchao Wang
2026-07-14 18:48 ` sashiko-bot [this message]
2026-07-14 18:33 ` [RFC PATCH 11/13] mm/kwatch: add debugfs control plane Jinchao Wang
2026-07-14 18:58 ` sashiko-bot
2026-07-14 18:33 ` [RFC PATCH 12/13] mm/kwatch: add KUnit tests for the watch expression parser Jinchao Wang
2026-07-14 18:50 ` sashiko-bot
2026-07-14 18:33 ` [RFC PATCH 13/13] Documentation/dev-tools: document KWatch Jinchao Wang
2026-07-14 18:48 ` sashiko-bot
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=20260714184830.485E31F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=wangjinchao600@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox