[PATCH v5 12/13] rcu-tasks-trace: Assert no reader is held on return to userspace
bot+bpf-ci at kernel.org
bot+bpf-ci at kernel.org
Mon Sep 21 20:11:27 PDT 2026
> diff --git a/include/linux/irq-entry-common.h b/include/linux/irq-entry-common.h
> index e19b41ee6b18..d42568a488a7 100644
> --- a/include/linux/irq-entry-common.h
> +++ b/include/linux/irq-entry-common.h
> @@ -5,6 +5,7 @@
> #include <linux/context_tracking.h>
> #include <linux/hrtimer_rearm.h>
> #include <linux/kmsan.h>
> +#include <linux/rcupdate_trace.h>
> #include <linux/rseq_entry.h>
> #include <linux/static_call_types.h>
> #include <linux/syscalls.h>
> @@ -214,6 +215,7 @@ static __always_inline void __exit_to_user_mode_validate(void)
> {
> /* Ensure that kernel state is sane for a return to userspace */
> kmap_assert_nomap();
> + rcu_tasks_trace_assert_idle();
> lockdep_assert_irqs_disabled();
> lockdep_sys_exit();
> }
> diff --git a/include/linux/rcupdate_trace.h b/include/linux/rcupdate_trace.h
> index dcdb11643496..9eb7f92c710b 100644
> --- a/include/linux/rcupdate_trace.h
> +++ b/include/linux/rcupdate_trace.h
> @@ -217,6 +217,12 @@ unsigned long rcu_tasks_trace_batches_completed(void);
> // Placeholders to enable stepwise transition.
> void __init rcu_tasks_trace_suppress_unused(void);
>
> +/* A task must never reach userspace inside an rcu_read_lock_trace() reader. */
> +static inline void rcu_tasks_trace_assert_idle(void)
> +{
> + WARN_ON_ONCE(IS_ENABLED(CONFIG_PROVE_RCU) && READ_ONCE(current->trc_reader_nesting));
> +}
> +
^^^^
This isn't a bug, but since rcu_read_lock_trace_held() already exists a
few lines up, would rcu_tasks_trace_assert_no_reader() (or
..._assert_not_held()) read better here than ..._assert_idle(), given
that "idle" already means the dynticks/RCU-not-watching state elsewhere
in RCU?
And would it be worth moving it above the "Placeholders to enable
stepwise transition" comment so it does not read as part of that group?
> #else
> static inline unsigned long rcu_tasks_trace_batches_completed(void) { return 0; }
> /*
[ ... ]
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/35680506278
More information about the linux-arm-kernel
mailing list