From: Gustavo Luiz Duarte <gustavold@gmail.com>
To: "Paul E. McKenney" <paulmck@kernel.org>,
Frederic Weisbecker <frederic@kernel.org>,
Neeraj Upadhyay <neeraj.upadhyay@kernel.org>,
Joel Fernandes <joelagnelf@nvidia.com>,
Josh Triplett <josh@joshtriplett.org>,
Boqun Feng <boqun@kernel.org>,
Uladzislau Rezki <urezki@gmail.com>,
Steven Rostedt <rostedt@goodmis.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Lai Jiangshan <jiangshanlai@gmail.com>,
Zqiang <qiang.zhang@linux.dev>,
Vlastimil Babka <vbabka@kernel.org>,
Harry Yoo <harry@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Hao Li <hao.li@linux.dev>, Christoph Lameter <cl@gentwo.org>,
David Rientjes <rientjes@google.com>,
Roman Gushchin <roman.gushchin@linux.dev>,
Breno Leitao <leitao@debian.org>
Cc: rcu@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, Gustavo Luiz Duarte <gustavold@gmail.com>
Subject: [PATCH RFC 2/2] rcu: Include kfree_rcu/kvfree_rcu batched counts in pending_cbs
Date: Thu, 07 May 2026 10:37:08 -0700 [thread overview]
Message-ID: <20260507-rcu-pending-cbs-stats-v1-2-8f4eb3553bc9@gmail.com> (raw)
In-Reply-To: <20260507-rcu-pending-cbs-stats-v1-0-8f4eb3553bc9@gmail.com>
The batched kfree_rcu()/kvfree_rcu() path (CONFIG_KVFREE_RCU_BATCHED)
manages its own per-CPU queues in struct kfree_rcu_cpu, bypassing the
main RCU segmented callback list. Objects queued through this path
were not visible in the debugfs pending_cbs file.
Add a kfree_rcu_pending() helper that returns the number of objects
waiting in the kfree_rcu batching layer for a given CPU, and include
this count as a "kfree_rcu" column in the debugfs output.
Example output:
cpu done wait next_ready next lazy kfree_rcu
0 0 0 0 5 5 12
1 0 0 0 3 3 8
total 0 0 0 8 8 20
Signed-off-by: Gustavo Luiz Duarte <gustavold@gmail.com>
---
kernel/rcu/rcu.h | 1 +
kernel/rcu/tree_stall.h | 17 +++++++++++------
mm/slab_common.c | 18 ++++++++++++++++++
3 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/kernel/rcu/rcu.h b/kernel/rcu/rcu.h
index fa6d30ce73d1..a28c3c7dc4da 100644
--- a/kernel/rcu/rcu.h
+++ b/kernel/rcu/rcu.h
@@ -652,6 +652,7 @@ void rcu_fwd_progress_check(unsigned long j);
void rcu_force_quiescent_state(void);
extern struct workqueue_struct *rcu_gp_wq;
extern struct kthread_worker *rcu_exp_gp_kworker;
+int kfree_rcu_pending(int cpu);
void rcu_gp_slow_register(atomic_t *rgssp);
void rcu_gp_slow_unregister(atomic_t *rgssp);
#endif /* #else #ifdef CONFIG_TINY_RCU */
diff --git a/kernel/rcu/tree_stall.h b/kernel/rcu/tree_stall.h
index d9fc9bfdaf96..5fd63730d5f5 100644
--- a/kernel/rcu/tree_stall.h
+++ b/kernel/rcu/tree_stall.h
@@ -84,14 +84,17 @@ late_initcall(kernel_rcu_stall_sysfs_init);
static int rcu_pending_cbs_show(struct seq_file *m, void *v)
{
int cpu;
+ int kfree;
long done, wait, nxtrdy, nxt, lazy;
long total_done = 0, total_wait = 0, total_nxtrdy = 0;
long total_nxt = 0, total_lazy = 0;
+ int total_kfree = 0;
struct rcu_data *rdp;
struct rcu_segcblist *rsclp;
- seq_printf(m, "%-8s %10s %10s %10s %10s %10s\n",
- "cpu", "done", "wait", "next_ready", "next", "lazy");
+ seq_printf(m, "%-8s %10s %10s %10s %10s %10s %10s\n",
+ "cpu", "done", "wait", "next_ready", "next", "lazy",
+ "kfree_rcu");
for_each_possible_cpu(cpu) {
rdp = per_cpu_ptr(&rcu_data, cpu);
@@ -105,20 +108,22 @@ static int rcu_pending_cbs_show(struct seq_file *m, void *v)
nxtrdy = rcu_segcblist_get_seglen(rsclp, RCU_NEXT_READY_TAIL);
nxt = rcu_segcblist_get_seglen(rsclp, RCU_NEXT_TAIL);
lazy = READ_ONCE(rdp->lazy_len);
+ kfree = kfree_rcu_pending(cpu);
- seq_printf(m, "%-8d %10ld %10ld %10ld %10ld %10ld\n",
- cpu, done, wait, nxtrdy, nxt, lazy);
+ seq_printf(m, "%-8d %10ld %10ld %10ld %10ld %10ld %10d\n",
+ cpu, done, wait, nxtrdy, nxt, lazy, kfree);
total_done += done;
total_wait += wait;
total_nxtrdy += nxtrdy;
total_nxt += nxt;
total_lazy += lazy;
+ total_kfree += kfree;
}
- seq_printf(m, "%-8s %10ld %10ld %10ld %10ld %10ld\n",
+ seq_printf(m, "%-8s %10ld %10ld %10ld %10ld %10ld %10d\n",
"total", total_done, total_wait, total_nxtrdy,
- total_nxt, total_lazy);
+ total_nxt, total_lazy, total_kfree);
return 0;
}
diff --git a/mm/slab_common.c b/mm/slab_common.c
index d5a70a831a2a..93b5d64399f2 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -1280,6 +1280,11 @@ void kvfree_call_rcu(struct rcu_head *head, void *ptr)
}
EXPORT_SYMBOL_GPL(kvfree_call_rcu);
+int kfree_rcu_pending(int cpu)
+{
+ return 0;
+}
+
void __init kvfree_rcu_init(void)
{
}
@@ -2216,4 +2221,17 @@ void __init kvfree_rcu_init(void)
shrinker_register(kfree_rcu_shrinker);
}
+/**
+ * kfree_rcu_pending() - Return number of objects pending in kfree_rcu batches.
+ * @cpu: CPU number to query.
+ *
+ * Returns the number of objects queued in kfree_rcu()/kvfree_rcu() batches
+ * on @cpu that are waiting for a grace period. These objects are tracked
+ * separately from the main RCU callback list.
+ */
+int kfree_rcu_pending(int cpu)
+{
+ return krc_count(per_cpu_ptr(&krc, cpu));
+}
+
#endif /* CONFIG_KVFREE_RCU_BATCHED */
--
2.53.0-Meta
next prev parent reply other threads:[~2026-05-07 17:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-07 17:37 [PATCH RFC 0/2] rcu: Add debugfs interface for pending callback monitoring Gustavo Luiz Duarte
2026-05-07 17:37 ` [PATCH RFC 1/2] rcu: Expose per-CPU segmented callback counts via debugfs Gustavo Luiz Duarte
2026-05-07 17:37 ` Gustavo Luiz Duarte [this message]
2026-05-07 18:59 ` [PATCH RFC 0/2] rcu: Add debugfs interface for pending callback monitoring Joel Fernandes
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=20260507-rcu-pending-cbs-stats-v1-2-8f4eb3553bc9@gmail.com \
--to=gustavold@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=boqun@kernel.org \
--cc=cl@gentwo.org \
--cc=frederic@kernel.org \
--cc=hao.li@linux.dev \
--cc=harry@kernel.org \
--cc=jiangshanlai@gmail.com \
--cc=joelagnelf@nvidia.com \
--cc=josh@joshtriplett.org \
--cc=leitao@debian.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=neeraj.upadhyay@kernel.org \
--cc=paulmck@kernel.org \
--cc=qiang.zhang@linux.dev \
--cc=rcu@vger.kernel.org \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=rostedt@goodmis.org \
--cc=urezki@gmail.com \
--cc=vbabka@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox