lkml.org 
[lkml]   [2018]   [May]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Fw: [PATCHSET] workqueue: Show the latest workqueue name in /proc/PID/{comm,stat,status}
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...

\
 
 \ /
  Last update: 2018-05-17 09:52    [W:0.102 / U:0.244 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site