From: Tejun Heo <tj@kernel.org>
To: Wilson Felipe Pereira <wfelipe@google.com>
Cc: Lai Jiangshan <jiangshanlai@gmail.com>,
Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>,
Randy Dunlap <rdunlap@infradead.org>,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
Shuhao Tan <tanshuhao@google.com>
Subject: Re: [PATCH 2/3] workqueue: expose per-workqueue stats in debugfs
Date: Thu, 22 Oct 2026 14:19:01 -1000 [thread overview]
Message-ID: <fa32d01cf66a6ca9818425f33bed0c96@kernel.org> (raw)
In-Reply-To: <p973mrs5tkuc.fsf@wfelipe-west1.c.googlers.com>
Hello, Wilson.
On Thu, Oct 22, 2026 at 10:46:19PM +0000, Wilson Felipe Pereira wrote:
> Why not drgn? For continuous monitoring, running drgn on every machine,
> with vmlinux debuginfo, and memory footprint from Python/drgn, while
> having CONFIG_PROC_KCORE available, it adds up. Having a simple file
> interface, it can be read from an existing monitoring collector.
>
> Why debugfs? If sysfs is picked, not all queues are in
> /sys/bus/workqueue/devices/. Using debugfs, a single file can include
> all queues. If you have a suggestion, I'm open to change this series.
I'm usually really skeptical when people suggest debugfs as a solution.
If you need continuous monitoring and drgn is too heavy, this is trivial
to do with BPF. The following bpftrace script prints the per-workqueue
stats and needs only BTF, no DWARF debuginfo, /proc/kcore or Python:
BEGIN
{
printf("%-24s %10s %10s %12s %6s %6s %6s\n", "workqueue", "started",
"completed", "cpu_time_us", "active", "cmw", "mayday");
$whead = (uint64)kaddr("workqueues");
$wpos = (uint64)((struct list_head *)$whead)->next;
for ($i : 0..4096) {
if ($wpos == $whead) {
break;
}
$wq = (struct workqueue_struct *)($wpos - offsetof(struct workqueue_struct, list));
$started = (uint64)0; $completed = (uint64)0; $cpu = (uint64)0;
$cmw = (uint64)0; $mayday = (uint64)0; $active = 0;
$phead = (uint64)$wq + offsetof(struct workqueue_struct, pwqs);
$ppos = (uint64)((struct list_head *)$phead)->next;
for ($j : 0..8192) {
if ($ppos == $phead) {
break;
}
$pwq = (struct pool_workqueue *)($ppos - offsetof(struct pool_workqueue, pwqs_node));
$started += $pwq->stats[PWQ_STAT_STARTED];
$completed += $pwq->stats[PWQ_STAT_COMPLETED];
$cpu += $pwq->stats[PWQ_STAT_CPU_TIME];
$cmw += $pwq->stats[PWQ_STAT_CM_WAKEUP];
$mayday += $pwq->stats[PWQ_STAT_MAYDAY];
$active += $pwq->nr_active;
$ppos = (uint64)((struct list_head *)$ppos)->next;
}
printf("%-24s %10lu %10lu %12lu %6d %6lu %6lu\n", $wq->name, $started,
$completed, $cpu, $active, $cmw, $mayday);
$wpos = (uint64)((struct list_head *)$wpos)->next;
}
exit();
}
It took an AI agent about a minute to write and test.
Thanks.
--
tejun
next prev parent reply other threads:[~2026-10-23 0:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-22 15:53 [PATCH 0/3] workqueue: expose per-workqueue stats in debugfs Wilson Felipe Pereira
2026-10-22 15:53 ` [PATCH 1/3] workqueue: preserve pwq->stats[] when unbound pwqs are released Wilson Felipe Pereira
2026-10-22 15:53 ` [PATCH 2/3] workqueue: expose per-workqueue stats in debugfs Wilson Felipe Pereira
2026-10-22 20:35 ` Tejun Heo
2026-10-22 22:46 ` Wilson Felipe Pereira
2026-10-23 0:19 ` Tejun Heo [this message]
2026-10-23 2:46 ` Wilson Felipe Pereira
2026-10-23 16:45 ` Tejun Heo
2026-10-22 15:53 ` [PATCH 3/3] tools/workqueue: report queued items and retired stats in wq_monitor.py Wilson Felipe Pereira
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=fa32d01cf66a6ca9818425f33bed0c96@kernel.org \
--to=tj@kernel.org \
--cc=corbet@lwn.net \
--cc=jiangshanlai@gmail.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rdunlap@infradead.org \
--cc=skhan@linuxfoundation.org \
--cc=tanshuhao@google.com \
--cc=wfelipe@google.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.