From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 58F5544E044 for ; Thu, 7 May 2026 17:37:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778175447; cv=none; b=T29QVleTqAZW4hk9Y+rh8bs2fy3gWN5gXiajHjcEFmm3S0Z64MzzZqRwScHrViUeQs7voStlbFaOwtD5SsE8Fs1TtWNQfo0M/hK4/o1iHHqRvyb2vBYBSNtZQF0xpfSEth/PTChU+XlBzBchN+KyAd1XsCbhRps/ffY4RIonYCA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778175447; c=relaxed/simple; bh=4z/1dmBLjBhdxfo/+CaTY6REGE9UNUbRRcoALV01/lI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FyGR8cPGfgVbNMNHOvnpRj6IecZoVV9EVDUW71mgqytJi7IevMxyPwYXz2DcrFrOgEilsEQQBDzJufPaWO5t45FEjy9u15hv5DbO8qmT2TbIIEVfPXeyuo2KtKQgQt2CFZPMZY8K3xRzUcmC2cuTOXZamFWpHfhovNJFm0K1aus= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=cg/gbNaq; arc=none smtp.client-ip=209.85.221.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cg/gbNaq" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-44a786a9b8aso128789f8f.0 for ; Thu, 07 May 2026 10:37:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778175444; x=1778780244; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=T4m72sXmjSg5D7jXc6/EKa8YJmIxljirw3qApIHaCe8=; b=cg/gbNaqN3pnfi/JCDo9JF0f67Wh+2tJYOTJnaOttt+31xpnfLNsy+I8zUJWHYm0ry LWkKQsUrVxpAzksarTPqCdbV8+TSx8cv2P5PR+q+ye+PS5+h6Oyy9TOWb4wBVxdjupZm EXEW211e0ZTRq5RqVAVSC4N90QnrnF27v/wH5u0JE3GcEonFFgsXkV2VnlBH73Xv0ySK /k9fc3nl7QJXqk2omeiRPbEN03baTGt8LnkESY73KPs7KE4oaD1JQO4UAVXaQ/BALV8Y XBRVs1F1JcC3guRsrs0xFlRGMbhM/YA7PGSPpjrS6YzHbC5Z1wbEdHLk5iEGGnVF0VII V5Cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778175444; x=1778780244; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=T4m72sXmjSg5D7jXc6/EKa8YJmIxljirw3qApIHaCe8=; b=H5BaH/Mk9aeAQuIeVzJSF0gwt2eszsZmejWstj11WO3+PnvkAQUnG6hyWlXpYnbqo0 rWwBcT7LyOLamjqE/Xzi1lGButYEAMbKZgzy67tAOC7SDB+sia05DO71BjtFuzgCPNLy IU2gcOh4kMaWCOhPWGgGXlHWTwvlIKTTYP1+z45YpeK9yNTHG3Wt7Sl6Ox807ub+DwTp Y7mKzPEPrjoqGASAAlmhthc5eMxiZDzJxj5KcTTmtK5m/+4ocwnkIW4JSnrVE2vVRWWE gpEPm7c9dvREZJpT/95TMY+33MfO2Q6v6RKf4NsLEdFSOWe/HbvgurwbKTni7Bwyxsmw 6vCQ== X-Forwarded-Encrypted: i=1; AFNElJ9YjfVk+g55pdlu3sCYB18OHG1TjCyyGS+wVqPUdzkkjQktT/CPvtoRFsNVa1Lo3nMTxC0MCxHgQxbGX44=@vger.kernel.org X-Gm-Message-State: AOJu0YyYs+C6ke2KtNYF/MnMEDKhXz6JmBen5FgVrMo/e6msHcfGM1wn iA0G+ABAgjSS/owc5F6lkL8jJd+sGbwBUBLcdoq9N6Uwe27+yjCQlrA1 X-Gm-Gg: AeBDieukrKc0VJnHgiiNkHXEqhkJh8WDi+zDZnS0khMgc3hfBLEYvzCZOnJgeMj2URt s3ZJn0NV4j+Tr9/iM12T/MYoYY+jlCG2ujp6scMwTd9a0AKXc+/6C5Yvk6nhacukUoB1sMUWIGk tDzWcbVj+r1FFiqfM0qplz46omHUo6JwEqjgRsHA9KvBWw0O6JJu4NqiwiAROu60sbL9mXoEMh3 5WuKf/NHIvq6AgXiQT0kGhsQ+Z9gDFIrHDRCm3gmDe0bCjG5d4MkxRmYdFEl7S2tCwDawRIA4i4 WAS6KbHY//tmG3BRF9V9aHoU7h3k7BH4Ta1CeYWt3xU7J7B5GXYulI9egbuwtFX5vG+QohY6w4E qTobYtq2JK9SqY2FFGrqf7mLMWua/jkK6pMQlQC5TeAGyt6QyuCxc9BVDlbkwFRi56FdUt7Pd7/ QrEFoycY9pM7UZAdlxHi8y/XC4g9/3ahE5Nwvmxvrki5rA7JA6 X-Received: by 2002:a05:600c:4f82:b0:489:1dc6:d6e with SMTP id 5b1f17b1804b1-48e5325025fmr65769755e9.1.1778175443552; Thu, 07 May 2026 10:37:23 -0700 (PDT) Received: from localhost ([2a03:2880:31ff:31::]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e642e2b29sm1783655e9.1.2026.05.07.10.37.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 10:37:23 -0700 (PDT) From: Gustavo Luiz Duarte Date: Thu, 07 May 2026 10:37:07 -0700 Subject: [PATCH RFC 1/2] rcu: Expose per-CPU segmented callback counts via debugfs Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260507-rcu-pending-cbs-stats-v1-1-8f4eb3553bc9@gmail.com> References: <20260507-rcu-pending-cbs-stats-v1-0-8f4eb3553bc9@gmail.com> In-Reply-To: <20260507-rcu-pending-cbs-stats-v1-0-8f4eb3553bc9@gmail.com> To: "Paul E. McKenney" , Frederic Weisbecker , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Vlastimil Babka , Harry Yoo , Andrew Morton , Hao Li , Christoph Lameter , David Rientjes , Roman Gushchin , Breno Leitao Cc: rcu@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Gustavo Luiz Duarte X-Mailer: b4 0.13.0 The existing rcu_segcb_stats tracepoint requires active tracing, so there is no always-on, low-overhead way to inspect how many callbacks are pending on each CPU and at which stage of the grace-period pipeline. Add a debugfs file at /sys/kernel/debug/rcu/pending_cbs that prints per-CPU callback counts broken down by segcblist segment, plus a "total" row aggregating across CPUs: - done: Callbacks ready to invoke (GP completed). - wait: Callbacks waiting for the current GP. - next_ready: Callbacks to be handled by the next GP. - next: Newly queued callbacks not yet assigned a GP. - lazy: Callbacks deferred via the RCU lazy mechanism. The interface has zero steady-state overhead: it reads the existing per-CPU rcu_segcblist.seglen[] counters on demand. These counters are already maintained by the RCU callback infrastructure for its own bookkeeping, so no new runtime accounting is introduced. Example output: cpu done wait next_ready next lazy 0 7 11 0 0 0 1 0 3 2 0 0 2 0 1 8 0 0 3 0 1 1 0 0 total 7 16 11 0 0 Signed-off-by: Gustavo Luiz Duarte --- kernel/rcu/tree_stall.h | 67 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/kernel/rcu/tree_stall.h b/kernel/rcu/tree_stall.h index b67532cb8770..d9fc9bfdaf96 100644 --- a/kernel/rcu/tree_stall.h +++ b/kernel/rcu/tree_stall.h @@ -71,6 +71,73 @@ late_initcall(kernel_rcu_stall_sysfs_init); #endif // CONFIG_SYSFS +#ifdef CONFIG_DEBUG_FS + +#include +#include + +/* + * Debugfs interface for displaying per-CPU RCU callback counts broken down + * by callback-list segment. This allows monitoring how many callbacks are + * waiting for grace periods without any steady-state overhead. + */ +static int rcu_pending_cbs_show(struct seq_file *m, void *v) +{ + int cpu; + long done, wait, nxtrdy, nxt, lazy; + long total_done = 0, total_wait = 0, total_nxtrdy = 0; + long total_nxt = 0, total_lazy = 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"); + + for_each_possible_cpu(cpu) { + rdp = per_cpu_ptr(&rcu_data, cpu); + rsclp = &rdp->cblist; + + if (!rcu_segcblist_is_enabled(rsclp)) + continue; + + done = rcu_segcblist_get_seglen(rsclp, RCU_DONE_TAIL); + wait = rcu_segcblist_get_seglen(rsclp, RCU_WAIT_TAIL); + 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); + + seq_printf(m, "%-8d %10ld %10ld %10ld %10ld %10ld\n", + cpu, done, wait, nxtrdy, nxt, lazy); + + total_done += done; + total_wait += wait; + total_nxtrdy += nxtrdy; + total_nxt += nxt; + total_lazy += lazy; + } + + seq_printf(m, "%-8s %10ld %10ld %10ld %10ld %10ld\n", + "total", total_done, total_wait, total_nxtrdy, + total_nxt, total_lazy); + + return 0; +} +DEFINE_SHOW_ATTRIBUTE(rcu_pending_cbs); + +static struct dentry *rcu_debugfs_dir; + +static int __init rcu_debugfs_init(void) +{ + rcu_debugfs_dir = debugfs_create_dir("rcu", NULL); + debugfs_create_file("pending_cbs", 0444, rcu_debugfs_dir, + NULL, &rcu_pending_cbs_fops); + + return 0; +} +late_initcall(rcu_debugfs_init); + +#endif // #ifdef CONFIG_DEBUG_FS + #ifdef CONFIG_PROVE_RCU #define RCU_STALL_DELAY_DELTA (5 * HZ) #else -- 2.53.0-Meta