From: Alexey Dobriyan <adobriyan@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Tejun Heo <tj@kernel.org>, linux-kernel@vger.kernel.org
Subject: Re: Fw: [PATCHSET] workqueue: Show the latest workqueue name in /proc/PID/{comm,stat,status}
Date: Thu, 17 May 2018 10:51:24 +0300 [thread overview]
Message-ID: <20180517075124.GA2057@avx2> (raw)
In-Reply-To: <20180516214750.82710e21075ad1461dd4c04b@linux-foundation.org>
On Wed, May 16, 2018 at 09:47:50PM -0700, Andrew Morton wrote:
> Alexey, can you please review the proc bits of this series?
>
> Thanks.
>
> Begin forwarded message:
>
> Date: Wed, 16 May 2018 21:34:42 -0700
> From: Tejun Heo <tj@kernel.org>
> To: torvalds@linux-foundation.org, jiangshanlai@gmail.com, akpm@linux-foundation.org
> Cc: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, kernel-team@fb.com, csmall@enc.com.au
> Subject: [PATCHSET] workqueue: Show the latest workqueue name in /proc/PID/{comm,stat,status}
>
>
> There can be a lot of workqueue workers and they all show up with the
> cryptic kworker/* names making it difficult to understand which is
> doing what and how they came to be.
>
> # ps -ef | grep kworker
> root 4 2 0 Feb25 ? 00:00:00 [kworker/0:0H]
> root 6 2 0 Feb25 ? 00:00:00 [kworker/u112:0]
> root 19 2 0 Feb25 ? 00:00:00 [kworker/1:0H]
> root 25 2 0 Feb25 ? 00:00:00 [kworker/2:0H]
> root 31 2 0 Feb25 ? 00:00:00 [kworker/3:0H]
> ...
>
> This patchset makes workqueue workers report the latest workqueue it
> was executing for through /proc/PID/{comm,stat,status}. The extra
> information is appended to the kthread name with intervening '+' if
> currently executing, otherwise '-'.
>
> # cat /proc/25/comm
> kworker/2:0-events_power_efficient
> # cat /proc/25/stat
> 25 (kworker/2:0-events_power_efficient) I 2 0 0 0 -1 69238880 0 0...
> # grep Name /proc/25/status
> Name: kworker/2:0-events_power_efficient
I'd say anything that extends ->comm past 16 charactes is no-no.
The reason is that userspace may do something stupid like:
char comm[16];
start = strchr(s, '(');
end = strrchr(s, ')');
// 16 bytes tops.
memcpy(comm, s + start + 1, end - start);
I think procps-ng does strdup, but there is an infinite amount of
monitoring tools written.
Add /proc/*/wq for kernel threads which is A SYMBOLIC LINK,
and instantiate it only for kernel threads so it doesn't pollute icache
and dcache much. 4KB realink limit should be enough for kthreads.
Now I'm probably obligated to find such a broken userspace tool...
next parent reply other threads:[~2018-05-17 7:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20180516214750.82710e21075ad1461dd4c04b@linux-foundation.org>
2018-05-17 7:51 ` Alexey Dobriyan [this message]
2018-05-17 17:01 ` Fw: [PATCHSET] workqueue: Show the latest workqueue name in /proc/PID/{comm,stat,status} Linus Torvalds
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=20180517075124.GA2057@avx2 \
--to=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tj@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