* [PATCH 01/10] rcu-tasks: TASKS_TRACE_RCU doesn't need IRQ_WORK
2026-07-16 0:23 [PATCH 0/10] Miscellaneous RCU updates for v7.3 Paul E. McKenney
@ 2026-07-16 0:23 ` Paul E. McKenney
2026-07-16 0:23 ` [PATCH 02/10] rcu: Use task_state_to_char() in stall-warning prints Paul E. McKenney
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Paul E. McKenney @ 2026-07-16 0:23 UTC (permalink / raw)
To: rcu; +Cc: linux-kernel, kernel-team, rostedt, Paul E. McKenney
Now that Tasks Trace RCU is implemented in terms of SRCU, it no longer
has any particular need for the IRQ_WORK Kconfig option. This commit
therefore removes the "select IRQ_WORK" from the TASKS_TRACE_RCU Kconfig
option.
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
kernel/rcu/Kconfig | 1 -
1 file changed, 1 deletion(-)
diff --git a/kernel/rcu/Kconfig b/kernel/rcu/Kconfig
index 762299291e09ba..332df7a7a6347c 100644
--- a/kernel/rcu/Kconfig
+++ b/kernel/rcu/Kconfig
@@ -140,7 +140,6 @@ config FORCE_TASKS_TRACE_RCU
config TASKS_TRACE_RCU
bool
default n
- select IRQ_WORK
config TASKS_TRACE_RCU_NO_MB
bool "Override RCU Tasks Trace inclusion of read-side memory barriers"
--
2.40.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 02/10] rcu: Use task_state_to_char() in stall-warning prints
2026-07-16 0:23 [PATCH 0/10] Miscellaneous RCU updates for v7.3 Paul E. McKenney
2026-07-16 0:23 ` [PATCH 01/10] rcu-tasks: TASKS_TRACE_RCU doesn't need IRQ_WORK Paul E. McKenney
@ 2026-07-16 0:23 ` Paul E. McKenney
2026-07-16 0:23 ` [PATCH 03/10] rcu: Mark __rcu_access_pointer() as context_unsafe() Paul E. McKenney
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Paul E. McKenney @ 2026-07-16 0:23 UTC (permalink / raw)
To: rcu
Cc: linux-kernel, kernel-team, rostedt, Kunwu Chan, Zqiang,
Wang Lian, Paul E . McKenney
From: Kunwu Chan <kunwu.chan@gmail.com>
RCU stall warnings currently print task states as raw hexadecimal
values, requiring developers to manually decode them.
Use task_state_to_char() so that stall warnings show the same symbolic
task-state representation used elsewhere in the kernel.
For example:
->state=0x402 becomes ->state=I
->state=0x0 becomes ->state=R
->state=0x2 becomes ->state=D
This improves readability while preserving the underlying diagnostic
information.
Suggested-by: Zqiang <qiang.zhang@linux.dev>
Co-developed-by: Wang Lian <lianux.mm@gmail.com>
Signed-off-by: Wang Lian <lianux.mm@gmail.com>
Signed-off-by: Kunwu Chan <kunwu.chan@gmail.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
kernel/rcu/tree_stall.h | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/kernel/rcu/tree_stall.h b/kernel/rcu/tree_stall.h
index cf7ae51cba4033..45b9856ccd2b23 100644
--- a/kernel/rcu/tree_stall.h
+++ b/kernel/rcu/tree_stall.h
@@ -573,13 +573,13 @@ static void rcu_check_gp_kthread_starvation(void)
if (rcu_is_gp_kthread_starving(&j)) {
cpu = gpk ? task_cpu(gpk) : -1;
- pr_err("%s kthread starved for %ld jiffies! g%ld f%#x %s(%d) ->state=%#x ->cpu=%d\n",
+ pr_err("%s kthread starved for %ld jiffies! g%ld f%#x %s(%d) ->state=%c ->cpu=%d\n",
rcu_state.name, j,
(long)rcu_seq_current(&rcu_state.gp_seq),
data_race(READ_ONCE(rcu_state.gp_flags)),
gp_state_getname(rcu_state.gp_state),
data_race(READ_ONCE(rcu_state.gp_state)),
- gpk ? data_race(READ_ONCE(gpk->__state)) : ~0, cpu);
+ gpk ? task_state_to_char(gpk) : '?', cpu);
if (gpk) {
struct rcu_data *rdp = per_cpu_ptr(&rcu_data, cpu);
@@ -616,12 +616,12 @@ static void rcu_check_gp_kthread_expired_fqs_timer(void)
time_after(jiffies, jiffies_fqs + RCU_STALL_MIGHT_MIN) &&
gpk && !READ_ONCE(gpk->on_rq)) {
cpu = task_cpu(gpk);
- pr_err("%s kthread timer wakeup didn't happen for %ld jiffies! g%ld f%#x %s(%d) ->state=%#x\n",
+ pr_err("%s kthread timer wakeup didn't happen for %ld jiffies! g%ld f%#x %s(%d) ->state=%c\n",
rcu_state.name, (jiffies - jiffies_fqs),
(long)rcu_seq_current(&rcu_state.gp_seq),
data_race(READ_ONCE(rcu_state.gp_flags)), // Diagnostic read
gp_state_getname(RCU_GP_WAIT_FQS), RCU_GP_WAIT_FQS,
- data_race(READ_ONCE(gpk->__state)));
+ task_state_to_char(gpk));
pr_err("\tPossible timer handling issue on cpu=%d timer-softirq=%u\n",
cpu, kstat_softirqs_cpu(TIMER_SOFTIRQ, cpu));
}
@@ -948,10 +948,10 @@ void show_rcu_gp_kthreads(void)
jr = j - data_race(READ_ONCE(rcu_state.gp_req_activity));
js = j - data_race(READ_ONCE(rcu_state.gp_start));
jw = j - data_race(READ_ONCE(rcu_state.gp_wake_time));
- pr_info("%s: wait state: %s(%d) ->state: %#x ->rt_priority %u delta ->gp_start %lu ->gp_activity %lu ->gp_req_activity %lu ->gp_wake_time %lu ->gp_wake_seq %ld ->gp_seq %ld ->gp_seq_needed %ld ->gp_max %lu ->gp_flags %#x\n",
+ pr_info("%s: wait state: %s(%d) ->state: %c ->rt_priority %u delta ->gp_start %lu ->gp_activity %lu ->gp_req_activity %lu ->gp_wake_time %lu ->gp_wake_seq %ld ->gp_seq %ld ->gp_seq_needed %ld ->gp_max %lu ->gp_flags %#x\n",
rcu_state.name, gp_state_getname(rcu_state.gp_state),
data_race(READ_ONCE(rcu_state.gp_state)),
- t ? data_race(READ_ONCE(t->__state)) : 0x1ffff, t ? t->rt_priority : 0xffU,
+ t ? task_state_to_char(t) : '?', t ? t->rt_priority : 0xffU,
js, ja, jr, jw, (long)data_race(READ_ONCE(rcu_state.gp_wake_seq)),
(long)data_race(READ_ONCE(rcu_state.gp_seq)),
(long)data_race(READ_ONCE(rcu_get_root()->gp_seq_needed)),
--
2.40.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 03/10] rcu: Mark __rcu_access_pointer() as context_unsafe()
2026-07-16 0:23 [PATCH 0/10] Miscellaneous RCU updates for v7.3 Paul E. McKenney
2026-07-16 0:23 ` [PATCH 01/10] rcu-tasks: TASKS_TRACE_RCU doesn't need IRQ_WORK Paul E. McKenney
2026-07-16 0:23 ` [PATCH 02/10] rcu: Use task_state_to_char() in stall-warning prints Paul E. McKenney
@ 2026-07-16 0:23 ` Paul E. McKenney
2026-07-16 0:23 ` [PATCH 04/10] doc: RCU: Adopt new coding style of type-aware kmalloc-family - part 2/2 Paul E. McKenney
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Paul E. McKenney @ 2026-07-16 0:23 UTC (permalink / raw)
To: rcu
Cc: linux-kernel, kernel-team, rostedt, Paul E. McKenney,
Christoph Hellwig, Marco Elver, Nilay Shroff
A simple comparison of a pointer returned by rcu_access_pointer() results
in a context-analysis warning for lockless inspection of the RCU-protected
(also known as __rcu-protected) pointer. This can be suppressed by
placing context_unsafe() calls around calls rcu_access_pointer(),
but this is messy and distracting. This commit therefore wraps the
underlying __rcu_access_pointer() macro with a call to context_unsafe(),
thereby informing the context-analysis code that rcu_access_pointer()
may safely be invoked outside of an RCU read-side critical section.
Reported-by: Christoph Hellwig <hch@lst.de>
Suggested-by: Marco Elver <elver@google.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Tested-by: Nilay Shroff <nilay@linux.ibm.com>
Reviewed-by: Marco Elver <elver@google.com>
---
include/linux/rcupdate.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index 5e95acc33989b6..e40dc2e20c5b1f 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -490,12 +490,12 @@ context_unsafe( \
*/
#define unrcu_pointer(p) __unrcu_pointer(p, __UNIQUE_ID(rcu))
-#define __rcu_access_pointer(p, local, space) \
+#define __rcu_access_pointer(p, local, space) context_unsafe( \
({ \
typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \
rcu_check_sparse(p, space); \
((typeof(*p) __force __kernel *)(local)); \
-})
+}) )
#define __rcu_dereference_check(p, local, c, space) \
({ \
/* Dependency order vs. p above. */ \
--
2.40.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 04/10] doc: RCU: Adopt new coding style of type-aware kmalloc-family - part 2/2
2026-07-16 0:23 [PATCH 0/10] Miscellaneous RCU updates for v7.3 Paul E. McKenney
` (2 preceding siblings ...)
2026-07-16 0:23 ` [PATCH 03/10] rcu: Mark __rcu_access_pointer() as context_unsafe() Paul E. McKenney
@ 2026-07-16 0:23 ` Paul E. McKenney
2026-07-16 0:23 ` [PATCH 05/10] rcu-tasks: Remove unused struct rcu_tasks's->n_ipis_fails variables Paul E. McKenney
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Paul E. McKenney @ 2026-07-16 0:23 UTC (permalink / raw)
To: rcu; +Cc: linux-kernel, kernel-team, rostedt, Manuel Ebner, Paul E . McKenney
From: Manuel Ebner <manuelebner@mailbox.org>
Update Documentation/RCU/* to suggest using the new type-aware
kmalloc_obj() per commit 2932ba8d9c99 ("slab: Introduce kmalloc_obj()
and family")
p = kmalloc(...);
-> p = kmalloc_obj(...);
Signed-off-by: Manuel Ebner <manuelebner@mailbox.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
Documentation/RCU/rcu_dereference.rst | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Documentation/RCU/rcu_dereference.rst b/Documentation/RCU/rcu_dereference.rst
index 2524dcdadde2b8..5bc3785ebfc2ae 100644
--- a/Documentation/RCU/rcu_dereference.rst
+++ b/Documentation/RCU/rcu_dereference.rst
@@ -236,7 +236,7 @@ precautions. To see this, consider the following code fragment::
{
struct foo *p;
- p = kmalloc(...);
+ p = kmalloc_obj(*p);
if (p == NULL)
deal_with_it();
p->a = 42; /* Each field in its own cache line. */
@@ -293,7 +293,7 @@ Then one approach is to use locking, for example, as follows::
{
struct foo *p;
- p = kmalloc(...);
+ p = kmalloc_obj(*p);
if (p == NULL)
deal_with_it();
spin_lock(&p->lock);
--
2.40.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 0/10] Miscellaneous RCU updates for v7.3
@ 2026-07-16 0:23 Paul E. McKenney
2026-07-16 0:23 ` [PATCH 01/10] rcu-tasks: TASKS_TRACE_RCU doesn't need IRQ_WORK Paul E. McKenney
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: Paul E. McKenney @ 2026-07-16 0:23 UTC (permalink / raw)
To: rcu; +Cc: linux-kernel, kernel-team, rostedt
Hello!
This series contains miscellaneous RCU updates for v7.3:
1. TASKS_TRACE_RCU doesn't need IRQ_WORK.
2. Use task_state_to_char() in stall-warning prints, courtesy of
Kunwu Chan.
3. Mark __rcu_access_pointer() as context_unsafe().
4. RCU: Adopt new coding style of type-aware kmalloc-family -
part 2/2, courtesy of Manuel Ebner.
5. Remove unused struct rcu_tasks's->n_ipis_fails variables,
courtesy of Zqiang.
6. Dump rcu tasks status when the boot-test failed, courtesy
of Zqiang.
7. RCU: Fix brackets, courtesy of Manuel Ebner.
8. Apply READ_ONCE() and WRITE_ONCE() to fix data race.
9. Remove smp_mb() in rcu_spawn_tasks_kthread_generic(), courtesy
of Zqiang.
10. Update comments in call_rcu_tasks_generic(), courtesy of Zqiang.
Thanx, Paul
------------------------------------------------------------------------
b/Documentation/RCU/Design/Expedited-Grace-Periods/Expedited-Grace-Periods.rst | 2 -
b/Documentation/RCU/Design/Memory-Ordering/TreeRCU-gp.svg | 2 -
b/Documentation/RCU/Design/Memory-Ordering/TreeRCU-qs.svg | 2 -
b/Documentation/RCU/Design/Requirements/Requirements.rst | 2 -
b/Documentation/RCU/rcu_dereference.rst | 4 +--
b/include/linux/rcupdate.h | 4 +--
b/include/linux/rcupdate_trace.h | 10 ++++++--
b/kernel/rcu/Kconfig | 1
b/kernel/rcu/tasks.h | 6 +----
b/kernel/rcu/tree_stall.h | 12 +++++-----
kernel/rcu/tasks.h | 12 ++++++++--
11 files changed, 34 insertions(+), 23 deletions(-)
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 05/10] rcu-tasks: Remove unused struct rcu_tasks's->n_ipis_fails variables
2026-07-16 0:23 [PATCH 0/10] Miscellaneous RCU updates for v7.3 Paul E. McKenney
` (3 preceding siblings ...)
2026-07-16 0:23 ` [PATCH 04/10] doc: RCU: Adopt new coding style of type-aware kmalloc-family - part 2/2 Paul E. McKenney
@ 2026-07-16 0:23 ` Paul E. McKenney
2026-07-16 0:23 ` [PATCH 06/10] rcu-tasks: Dump rcu tasks status when the boot-test failed Paul E. McKenney
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Paul E. McKenney @ 2026-07-16 0:23 UTC (permalink / raw)
To: rcu; +Cc: linux-kernel, kernel-team, rostedt, Zqiang, Paul E . McKenney
From: Zqiang <qiang.zhang@linux.dev>
The RCU tasks trace has been reimplemented by 'commit c27cea4416a3
("rcu: Re-implement RCU Tasks Trace in terms of SRCU-fast")', the
rcu_tasks structure's->n_ipis_fails is no longer used, this commit
therefore remove it.
Signed-off-by: Zqiang <qiang.zhang@linux.dev>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
kernel/rcu/tasks.h | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/kernel/rcu/tasks.h b/kernel/rcu/tasks.h
index f4da5fad70f516..7f7d1e6362178a 100644
--- a/kernel/rcu/tasks.h
+++ b/kernel/rcu/tasks.h
@@ -67,7 +67,6 @@ struct rcu_tasks_percpu {
* @gp_start: Most recent grace-period start in jiffies.
* @tasks_gp_seq: Number of grace periods completed since boot in upper bits.
* @n_ipis: Number of IPIs sent to encourage grace periods to end.
- * @n_ipis_fails: Number of IPI-send failures.
* @kthread_ptr: This flavor's grace-period/callback-invocation kthread.
* @lazy_jiffies: Number of jiffies to allow callbacks to be lazy.
* @pregp_func: This flavor's pre-grace-period function (optional).
@@ -102,7 +101,6 @@ struct rcu_tasks {
unsigned long gp_start;
unsigned long tasks_gp_seq;
unsigned long n_ipis;
- unsigned long n_ipis_fails;
struct task_struct *kthread_ptr;
unsigned long lazy_jiffies;
rcu_tasks_gp_func_t gp_func;
@@ -735,12 +733,12 @@ static void show_rcu_tasks_generic_gp_kthread(struct rcu_tasks *rtp, char *s)
if (havecbs && haveurgent && haveurgentcbs)
break;
}
- pr_info("%s: %s(%d) since %lu g:%lu i:%lu/%lu %c%c%c%c l:%lu %s\n",
+ pr_info("%s: %s(%d) since %lu g:%lu i:%lu %c%c%c%c l:%lu %s\n",
rtp->kname,
tasks_gp_state_getname(rtp), data_race(rtp->gp_state),
jiffies - data_race(rtp->gp_jiffies),
data_race(rcu_seq_current(&rtp->tasks_gp_seq)),
- data_race(rtp->n_ipis_fails), data_race(rtp->n_ipis),
+ data_race(rtp->n_ipis),
".k"[!!data_race(rtp->kthread_ptr)],
".C"[havecbs],
".u"[haveurgent],
--
2.40.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 06/10] rcu-tasks: Dump rcu tasks status when the boot-test failed
2026-07-16 0:23 [PATCH 0/10] Miscellaneous RCU updates for v7.3 Paul E. McKenney
` (4 preceding siblings ...)
2026-07-16 0:23 ` [PATCH 05/10] rcu-tasks: Remove unused struct rcu_tasks's->n_ipis_fails variables Paul E. McKenney
@ 2026-07-16 0:23 ` Paul E. McKenney
2026-07-16 0:23 ` [PATCH 07/10] doc: RCU: Fix brackets Paul E. McKenney
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Paul E. McKenney @ 2026-07-16 0:23 UTC (permalink / raw)
To: rcu; +Cc: linux-kernel, kernel-team, rostedt, Zqiang, Paul E . McKenney
From: Zqiang <qiang.zhang@linux.dev>
This commit adds a dump RCU task status function to rcu tasks tests,
used to obtain more information to help debug when the RCU tasks
boot-time tests failed.
Signed-off-by: Zqiang <qiang.zhang@linux.dev>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
kernel/rcu/tasks.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/kernel/rcu/tasks.h b/kernel/rcu/tasks.h
index 7f7d1e6362178a..d9e1e53f4ccf31 100644
--- a/kernel/rcu/tasks.h
+++ b/kernel/rcu/tasks.h
@@ -1453,6 +1453,7 @@ struct rcu_tasks_test_desc {
const char *name;
bool notrun;
unsigned long runstart;
+ void (*gp_dbg)(void);
};
static struct rcu_tasks_test_desc tests[] = {
@@ -1460,6 +1461,8 @@ static struct rcu_tasks_test_desc tests[] = {
.name = "call_rcu_tasks()",
/* If not defined, the test is skipped. */
.notrun = IS_ENABLED(CONFIG_TASKS_RCU),
+ /* Dump rcu tasks status, if test failed. */
+ .gp_dbg = show_rcu_tasks_classic_gp_kthread
},
{
.name = "call_rcu_tasks_trace()",
@@ -1519,6 +1522,8 @@ static int rcu_tasks_verify_self_tests(void)
while (tests[i].notrun) { // still hanging.
if (time_after(jiffies, tests[i].runstart + bst)) {
pr_err("%s has failed boot-time tests.\n", tests[i].name);
+ if (tests[i].gp_dbg)
+ tests[i].gp_dbg();
ret = -1;
break;
}
--
2.40.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 07/10] doc: RCU: Fix brackets
2026-07-16 0:23 [PATCH 0/10] Miscellaneous RCU updates for v7.3 Paul E. McKenney
` (5 preceding siblings ...)
2026-07-16 0:23 ` [PATCH 06/10] rcu-tasks: Dump rcu tasks status when the boot-test failed Paul E. McKenney
@ 2026-07-16 0:23 ` Paul E. McKenney
2026-07-16 0:23 ` [PATCH 08/10] rcu-tasks: Apply READ_ONCE() and WRITE_ONCE() to fix data race Paul E. McKenney
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Paul E. McKenney @ 2026-07-16 0:23 UTC (permalink / raw)
To: rcu; +Cc: linux-kernel, kernel-team, rostedt, Manuel Ebner, Paul E . McKenney
From: Manuel Ebner <manuelebner@mailbox.org>
Remove needless brackets and add missing brackets.
Signed-off-by: Manuel Ebner <manuelebner@mailbox.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
.../Design/Expedited-Grace-Periods/Expedited-Grace-Periods.rst | 2 +-
Documentation/RCU/Design/Memory-Ordering/TreeRCU-gp.svg | 2 +-
Documentation/RCU/Design/Memory-Ordering/TreeRCU-qs.svg | 2 +-
Documentation/RCU/Design/Requirements/Requirements.rst | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/Documentation/RCU/Design/Expedited-Grace-Periods/Expedited-Grace-Periods.rst b/Documentation/RCU/Design/Expedited-Grace-Periods/Expedited-Grace-Periods.rst
index 414f8a2012d684..cf0f9cdca7e8cb 100644
--- a/Documentation/RCU/Design/Expedited-Grace-Periods/Expedited-Grace-Periods.rst
+++ b/Documentation/RCU/Design/Expedited-Grace-Periods/Expedited-Grace-Periods.rst
@@ -410,7 +410,7 @@ workqueues (see Documentation/core-api/workqueue.rst).
The requesting task still does counter snapshotting and funnel-lock
processing, but the task reaching the top of the funnel lock does a
-``schedule_work()`` (from ``_synchronize_rcu_expedited()`` so that a
+``schedule_work()`` (from ``_synchronize_rcu_expedited()``) so that a
workqueue kthread does the actual grace-period processing. Because
workqueue kthreads do not accept POSIX signals, grace-period-wait
processing need not allow for POSIX signals. In addition, this approach
diff --git a/Documentation/RCU/Design/Memory-Ordering/TreeRCU-gp.svg b/Documentation/RCU/Design/Memory-Ordering/TreeRCU-gp.svg
index d05bc7b27edb7a..95a66de40ca5a2 100644
--- a/Documentation/RCU/Design/Memory-Ordering/TreeRCU-gp.svg
+++ b/Documentation/RCU/Design/Memory-Ordering/TreeRCU-gp.svg
@@ -3933,7 +3933,7 @@
font-style="normal"
y="-3914.085"
x="3745.7725"
- xml:space="preserve">rcu__report_qs_rdp())</text>
+ xml:space="preserve">rcu__report_qs_rdp()</text>
</g>
<g
id="g4504-3"
diff --git a/Documentation/RCU/Design/Memory-Ordering/TreeRCU-qs.svg b/Documentation/RCU/Design/Memory-Ordering/TreeRCU-qs.svg
index 7d6c5f7e505c68..882132680308ef 100644
--- a/Documentation/RCU/Design/Memory-Ordering/TreeRCU-qs.svg
+++ b/Documentation/RCU/Design/Memory-Ordering/TreeRCU-qs.svg
@@ -815,7 +815,7 @@
font-style="normal"
y="-3914.085"
x="3745.7725"
- xml:space="preserve">rcu__report_qs_rdp())</text>
+ xml:space="preserve">rcu__report_qs_rdp()</text>
</g>
<g
id="g4504-3"
diff --git a/Documentation/RCU/Design/Requirements/Requirements.rst b/Documentation/RCU/Design/Requirements/Requirements.rst
index 8a216e4a46a7df..8101fe6229d579 100644
--- a/Documentation/RCU/Design/Requirements/Requirements.rst
+++ b/Documentation/RCU/Design/Requirements/Requirements.rst
@@ -2785,7 +2785,7 @@ both srcu_read_lock() and srcu_read_unlock(). This need is handled by
a Tasks Trace RCU API implemented as thin wrappers around SRCU-fast,
which avoids the read-side memory barriers, at least for architectures
that apply noinstr to kernel entry/exit code (or that build with
-``CONFIG_TASKS_TRACE_RCU_NO_MB=y``.
+``CONFIG_TASKS_TRACE_RCU_NO_MB=y``).
Now that the implementation is based on SRCU-fast, a call
to synchronize_rcu_tasks_trace() implies at least one call to
--
2.40.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 08/10] rcu-tasks: Apply READ_ONCE() and WRITE_ONCE() to fix data race
2026-07-16 0:23 [PATCH 0/10] Miscellaneous RCU updates for v7.3 Paul E. McKenney
` (6 preceding siblings ...)
2026-07-16 0:23 ` [PATCH 07/10] doc: RCU: Fix brackets Paul E. McKenney
@ 2026-07-16 0:23 ` Paul E. McKenney
2026-07-16 0:23 ` [PATCH 09/10] rcu-tasks: Remove smp_mb() in rcu_spawn_tasks_kthread_generic() Paul E. McKenney
2026-07-16 0:23 ` [PATCH 10/10] rcu-tasks: Update comments in call_rcu_tasks_generic() Paul E. McKenney
9 siblings, 0 replies; 11+ messages in thread
From: Paul E. McKenney @ 2026-07-16 0:23 UTC (permalink / raw)
To: rcu; +Cc: linux-kernel, kernel-team, rostedt, Paul E. McKenney
Now that rcutorture tests readers from interrupt handlers, KCSAN spotted
an additional data race. This commit therefore fixes it by applying
READ_ONCE() and WRITE_ONCE().
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
include/linux/rcupdate_trace.h | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/include/linux/rcupdate_trace.h b/include/linux/rcupdate_trace.h
index cee89e51e45cbb..fd3ddeb6aa3bd2 100644
--- a/include/linux/rcupdate_trace.h
+++ b/include/linux/rcupdate_trace.h
@@ -95,10 +95,13 @@ static inline void rcu_read_unlock_tasks_trace(struct srcu_ctr __percpu *scp)
*/
static inline void rcu_read_lock_trace(void)
{
+ int n;
struct task_struct *t = current;
rcu_try_lock_acquire(&rcu_tasks_trace_srcu_struct.dep_map);
- if (t->trc_reader_nesting++) {
+ n = READ_ONCE(t->trc_reader_nesting);
+ WRITE_ONCE(t->trc_reader_nesting, n + 1);
+ if (n) {
// In case we interrupted a Tasks Trace RCU reader.
return;
}
@@ -119,12 +122,15 @@ static inline void rcu_read_lock_trace(void)
*/
static inline void rcu_read_unlock_trace(void)
{
+ int n;
struct srcu_ctr __percpu *scp;
struct task_struct *t = current;
scp = t->trc_reader_scp;
barrier(); // scp before nesting to protect against interrupt handler.
- if (!--t->trc_reader_nesting) {
+ n = READ_ONCE(t->trc_reader_nesting) - 1;
+ WRITE_ONCE(t->trc_reader_nesting, n);
+ if (!n) {
if (!IS_ENABLED(CONFIG_TASKS_TRACE_RCU_NO_MB))
smp_mb(); // Placeholder for more selective ordering
__srcu_read_unlock_fast(&rcu_tasks_trace_srcu_struct, scp);
--
2.40.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 09/10] rcu-tasks: Remove smp_mb() in rcu_spawn_tasks_kthread_generic()
2026-07-16 0:23 [PATCH 0/10] Miscellaneous RCU updates for v7.3 Paul E. McKenney
` (7 preceding siblings ...)
2026-07-16 0:23 ` [PATCH 08/10] rcu-tasks: Apply READ_ONCE() and WRITE_ONCE() to fix data race Paul E. McKenney
@ 2026-07-16 0:23 ` Paul E. McKenney
2026-07-16 0:23 ` [PATCH 10/10] rcu-tasks: Update comments in call_rcu_tasks_generic() Paul E. McKenney
9 siblings, 0 replies; 11+ messages in thread
From: Paul E. McKenney @ 2026-07-16 0:23 UTC (permalink / raw)
To: rcu; +Cc: linux-kernel, kernel-team, rostedt, Zqiang, Paul E . McKenney
From: Zqiang <qiang.zhang@linux.dev>
For the smp_mb() after kthread_run() in rcu_spawn_tasks_kthread_generic()
from these commits:
'commit eacd6f04a133 ("rcu-tasks: Move Tasks RCU to its own file")'
'commit 84a8f446ffd7 ("rcu: Defer rcu_tasks_kthread() creation till
first call_rcu_tasks()")'
the memory order pairing as follows:
rcu_spawn_tasks_kthread()
->t = kthread_run(rcu_tasks_kthread, ...);
->smp_mb(); /* Ensure others see full kthread. */
->WRITE_ONCE(rcu_tasks_kthread_ptr, t);
call_rcu_tasks()
->if (READ_ONCE(rcu_tasks_kthread_ptr))
->wake_up(&rcu_tasks_cbs_wq)
->try_to_wake_up()
lock pi_lock
->smp_mb__after_spinlock()
//see full kthread
Because the 'commit d119357d0743 ("rcu-tasks: Treat only synchronous
grace periods urgently")' moved the kthread_ptr assignment into the
rcu_tasks_kthread() function, the following memory order pairings are
sufficient:
The runq's raw_spinlock/unlock(or smp_mb__after_spinlock()) from
wake_up_process() in kthread_run() and __schedule() provides memory order
barrier when the kthread is first scheduled, this ensures the kthread's
func observes all of the kthread's initialization.
The kthread's smp_store_release(&rtp->kthread_ptr, ...) in
rcu_tasks_kthread() and smp_load_acquire(&rtp->kthread_ptr)
in call_rcu_tasks_generic() compose release/acquire pairing, the
cumulativity of smp_store_release() propagates visibility of the kthread's
initialization through the scheduler chain.
This commit therefore remove smp_mb() in rcu_spawn_tasks_kthread_generic().
Signed-off-by: Zqiang <qiang.zhang@linux.dev>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
kernel/rcu/tasks.h | 1 -
1 file changed, 1 deletion(-)
diff --git a/kernel/rcu/tasks.h b/kernel/rcu/tasks.h
index d9e1e53f4ccf31..79aa5d51388c45 100644
--- a/kernel/rcu/tasks.h
+++ b/kernel/rcu/tasks.h
@@ -681,7 +681,6 @@ static void __init rcu_spawn_tasks_kthread_generic(struct rcu_tasks *rtp)
t = kthread_run(rcu_tasks_kthread, rtp, "%s_kthread", rtp->kname);
if (WARN_ONCE(IS_ERR(t), "%s: Could not start %s grace-period kthread, OOM is now expected behavior\n", __func__, rtp->name))
return;
- smp_mb(); /* Ensure others see full kthread. */
}
#ifndef CONFIG_TINY_RCU
--
2.40.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 10/10] rcu-tasks: Update comments in call_rcu_tasks_generic()
2026-07-16 0:23 [PATCH 0/10] Miscellaneous RCU updates for v7.3 Paul E. McKenney
` (8 preceding siblings ...)
2026-07-16 0:23 ` [PATCH 09/10] rcu-tasks: Remove smp_mb() in rcu_spawn_tasks_kthread_generic() Paul E. McKenney
@ 2026-07-16 0:23 ` Paul E. McKenney
9 siblings, 0 replies; 11+ messages in thread
From: Paul E. McKenney @ 2026-07-16 0:23 UTC (permalink / raw)
To: rcu; +Cc: linux-kernel, kernel-team, rostedt, Zqiang, Paul E . McKenney
From: Zqiang <qiang.zhang@linux.dev>
This commit updates the comment "We can't create the thread unless
interrupts are enabled." from 'commit 4929c913bda5 ("rcu: Make
call_rcu_tasks() tolerate first call with irqs disabled")' to be more
clear and also to cover deferred wakeup and to take into account the fact
that kthread creation has been move to core_initcall() time by 'commit
c63eb17ff06d ("rcu: Create call_rcu_tasks() kthread at boot time")'.
Signed-off-by: Zqiang <qiang.zhang@linux.dev>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
kernel/rcu/tasks.h | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/kernel/rcu/tasks.h b/kernel/rcu/tasks.h
index 79aa5d51388c45..8456b132950278 100644
--- a/kernel/rcu/tasks.h
+++ b/kernel/rcu/tasks.h
@@ -395,7 +395,11 @@ static void call_rcu_tasks_generic(struct rcu_head *rhp, rcu_callback_t func,
raw_spin_unlock_irqrestore(&rtp->cbs_gbl_lock, flags);
}
rcu_read_unlock();
- /* We can't create the thread unless interrupts are enabled. */
+ // We can't create the kthread with interrupts disabled because a
+ // scheduler spinlock might be held, so kthread creation is deferred
+ // until core_initcall() time. Similarly, wakeups are deferred using
+ // irq_work in order to to avoid potential scheduler-lock-deadlock
+ // lockdep splats.
if (needwake && READ_ONCE(rtp->kthread_ptr))
irq_work_queue(&rtpcp->rtp_irq_work);
}
--
2.40.1
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2026-07-16 0:23 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-16 0:23 [PATCH 0/10] Miscellaneous RCU updates for v7.3 Paul E. McKenney
2026-07-16 0:23 ` [PATCH 01/10] rcu-tasks: TASKS_TRACE_RCU doesn't need IRQ_WORK Paul E. McKenney
2026-07-16 0:23 ` [PATCH 02/10] rcu: Use task_state_to_char() in stall-warning prints Paul E. McKenney
2026-07-16 0:23 ` [PATCH 03/10] rcu: Mark __rcu_access_pointer() as context_unsafe() Paul E. McKenney
2026-07-16 0:23 ` [PATCH 04/10] doc: RCU: Adopt new coding style of type-aware kmalloc-family - part 2/2 Paul E. McKenney
2026-07-16 0:23 ` [PATCH 05/10] rcu-tasks: Remove unused struct rcu_tasks's->n_ipis_fails variables Paul E. McKenney
2026-07-16 0:23 ` [PATCH 06/10] rcu-tasks: Dump rcu tasks status when the boot-test failed Paul E. McKenney
2026-07-16 0:23 ` [PATCH 07/10] doc: RCU: Fix brackets Paul E. McKenney
2026-07-16 0:23 ` [PATCH 08/10] rcu-tasks: Apply READ_ONCE() and WRITE_ONCE() to fix data race Paul E. McKenney
2026-07-16 0:23 ` [PATCH 09/10] rcu-tasks: Remove smp_mb() in rcu_spawn_tasks_kthread_generic() Paul E. McKenney
2026-07-16 0:23 ` [PATCH 10/10] rcu-tasks: Update comments in call_rcu_tasks_generic() Paul E. McKenney
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox