* [PATCH v2] sched/debug: Introduce per-CPU debugfs files
@ 2026-07-28 20:52 Aaron Tomlin
2026-07-29 13:25 ` Aaron Tomlin
0 siblings, 1 reply; 3+ messages in thread
From: Aaron Tomlin @ 2026-07-28 20:52 UTC (permalink / raw)
To: mingo, peterz, juri.lelli, vincent.guittot
Cc: dietmar.eggemann, rostedt, bsegall, mgorman, vschneid,
kprateek.nayak, zhanxusheng1024, neelx, sean, steve,
linux-kernel
Currently, accessing scheduler debugging details for a specific CPU
requires reading /sys/kernel/debug/sched/debug, which outputs
information for all online CPUs. When investigating a latency anomaly or
scheduling issue isolated to a specific CPU, accessing
/sys/kernel/debug/sched/cpu/cpu<N>/debug provides an immediate, targeted
view of that runqueue.
Add support for per-CPU debug files under:
/sys/kernel/debug/sched/cpu/cpu<N>/debug. Reading
/sys/kernel/debug/sched/cpu/cpu<N>/debug calls print_cpu() specifically
for CPU <N>, exposing CPU-specific runqueue details on demand. If the
target CPU is currently offline, reading its file returns -ENODEV.
Signed-off-by: Aaron Tomlin <atomlin@atomlin.com>
---
Changes since v1:
- Reframed commit message motivation around targeted interactive
debugging on large SMP topologies (Peter Zijlstra and Zhan Xusheng)
- Gated sched_debug_cpu_show() with a cpu_online(cpu) check
returning -ENODEV when target CPU is offline (Zhan Xusheng)
- Linked to v1: https://lore.kernel.org/lkml/20260728020309.6169-1-atomlin@atomlin.com/
---
kernel/sched/debug.c | 43 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index 40584b27ea0c..af6f68f73e5f 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -356,6 +356,7 @@ static const struct file_operations sched_verbose_fops = {
};
static const struct seq_operations sched_debug_sops;
+static void print_cpu(struct seq_file *m, int cpu);
static int sched_debug_open(struct inode *inode, struct file *filp)
{
@@ -633,6 +634,47 @@ static void debugfs_fair_server_init(void)
}
}
+static int sched_debug_cpu_show(struct seq_file *m, void *v)
+{
+ unsigned long cpu = (unsigned long) m->private;
+
+ if (!cpu_online(cpu))
+ return -ENODEV;
+
+ print_cpu(m, cpu);
+ return 0;
+}
+
+static int sched_debug_cpu_open(struct inode *inode, struct file *filp)
+{
+ return single_open(filp, sched_debug_cpu_show, inode->i_private);
+}
+
+static const struct file_operations sched_debug_cpu_fops = {
+ .open = sched_debug_cpu_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
+static __init void debugfs_cpu_init(void)
+{
+ struct dentry *d_cpu_dir;
+ unsigned long cpu;
+ char buf[16];
+
+ d_cpu_dir = debugfs_create_dir("cpu", debugfs_sched);
+
+ for_each_possible_cpu(cpu) {
+ struct dentry *d_cpu;
+
+ snprintf(buf, sizeof(buf), "cpu%lu", cpu);
+ d_cpu = debugfs_create_dir(buf, d_cpu_dir);
+
+ debugfs_create_file("debug", 0444, d_cpu, (void *) cpu, &sched_debug_cpu_fops);
+ }
+}
+
static __init int sched_init_debug(void)
{
struct dentry __maybe_unused *numa, *llc;
@@ -690,6 +732,7 @@ static __init int sched_init_debug(void)
#ifdef CONFIG_SCHED_CLASS_EXT
debugfs_ext_server_init();
#endif
+ debugfs_cpu_init();
return 0;
}
--
2.55.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] sched/debug: Introduce per-CPU debugfs files
2026-07-28 20:52 [PATCH v2] sched/debug: Introduce per-CPU debugfs files Aaron Tomlin
@ 2026-07-29 13:25 ` Aaron Tomlin
2026-08-05 12:36 ` Aaron Tomlin
0 siblings, 1 reply; 3+ messages in thread
From: Aaron Tomlin @ 2026-07-29 13:25 UTC (permalink / raw)
To: mingo, peterz, juri.lelli, vincent.guittot
Cc: dietmar.eggemann, rostedt, bsegall, mgorman, vschneid,
kprateek.nayak, zhanxusheng1024, neelx, sean, steve,
linux-kernel
On Tue, Jul 28, 2026 at 04:52:38PM -0400, Aaron Tomlin wrote:
> Currently, accessing scheduler debugging details for a specific CPU
> requires reading /sys/kernel/debug/sched/debug, which outputs
> information for all online CPUs. When investigating a latency anomaly or
> scheduling issue isolated to a specific CPU, accessing
> /sys/kernel/debug/sched/cpu/cpu<N>/debug provides an immediate, targeted
> view of that runqueue.
>
> Add support for per-CPU debug files under:
> /sys/kernel/debug/sched/cpu/cpu<N>/debug. Reading
> /sys/kernel/debug/sched/cpu/cpu<N>/debug calls print_cpu() specifically
> for CPU <N>, exposing CPU-specific runqueue details on demand. If the
> target CPU is currently offline, reading its file returns -ENODEV.
>
> Signed-off-by: Aaron Tomlin <atomlin@atomlin.com>
> ---
> Changes since v1:
>
> - Reframed commit message motivation around targeted interactive
> debugging on large SMP topologies (Peter Zijlstra and Zhan Xusheng)
>
> - Gated sched_debug_cpu_show() with a cpu_online(cpu) check
> returning -ENODEV when target CPU is offline (Zhan Xusheng)
>
> - Linked to v1: https://lore.kernel.org/lkml/20260728020309.6169-1-atomlin@atomlin.com/
> ---
> kernel/sched/debug.c | 43 +++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 43 insertions(+)
Hi Peter, Ingo, Juri, Vincent,
Sashiko found [1] pre-existing issues, which are not related to this patch.
Would you prefer that I investigate these concerns in this series?
Thank you.
[1]: https://sashiko.dev/#/patchset/20260728205238.18447-1-atomlin%40atomlin.com
Kind regards,
--
Aaron Tomlin
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] sched/debug: Introduce per-CPU debugfs files
2026-07-29 13:25 ` Aaron Tomlin
@ 2026-08-05 12:36 ` Aaron Tomlin
0 siblings, 0 replies; 3+ messages in thread
From: Aaron Tomlin @ 2026-08-05 12:36 UTC (permalink / raw)
To: mingo, peterz, juri.lelli, vincent.guittot
Cc: dietmar.eggemann, rostedt, bsegall, mgorman, vschneid,
kprateek.nayak, zhanxusheng1024, neelx, sean, steve,
linux-kernel
On Wed, Jul 29, 2026 at 09:25:20AM -0400, Aaron Tomlin wrote:
> On Tue, Jul 28, 2026 at 04:52:38PM -0400, Aaron Tomlin wrote:
> > Currently, accessing scheduler debugging details for a specific CPU
> > requires reading /sys/kernel/debug/sched/debug, which outputs
> > information for all online CPUs. When investigating a latency anomaly or
> > scheduling issue isolated to a specific CPU, accessing
> > /sys/kernel/debug/sched/cpu/cpu<N>/debug provides an immediate, targeted
> > view of that runqueue.
> >
> > Add support for per-CPU debug files under:
> > /sys/kernel/debug/sched/cpu/cpu<N>/debug. Reading
> > /sys/kernel/debug/sched/cpu/cpu<N>/debug calls print_cpu() specifically
> > for CPU <N>, exposing CPU-specific runqueue details on demand. If the
> > target CPU is currently offline, reading its file returns -ENODEV.
> >
> > Signed-off-by: Aaron Tomlin <atomlin@atomlin.com>
> > ---
> > Changes since v1:
> >
> > - Reframed commit message motivation around targeted interactive
> > debugging on large SMP topologies (Peter Zijlstra and Zhan Xusheng)
> >
> > - Gated sched_debug_cpu_show() with a cpu_online(cpu) check
> > returning -ENODEV when target CPU is offline (Zhan Xusheng)
> >
> > - Linked to v1: https://lore.kernel.org/lkml/20260728020309.6169-1-atomlin@atomlin.com/
> > ---
> > kernel/sched/debug.c | 43 +++++++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 43 insertions(+)
>
> Hi Peter, Ingo, Juri, Vincent,
>
> Sashiko found [1] pre-existing issues, which are not related to this patch.
> Would you prefer that I investigate these concerns in this series?
> Thank you.
>
> [1]: https://sashiko.dev/#/patchset/20260728205238.18447-1-atomlin%40atomlin.com
Hi Peter, Ingo, Juri, Vincent,
These concerns appear valid.
I'll address them.
Kind regards,
--
Aaron Tomlin
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-08-05 12:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-28 20:52 [PATCH v2] sched/debug: Introduce per-CPU debugfs files Aaron Tomlin
2026-07-29 13:25 ` Aaron Tomlin
2026-08-05 12:36 ` Aaron Tomlin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®