]> git.ipfire.org Git - thirdparty/linux.git/commit - kernel/workqueue.c
workqueue: Show the latest workqueue name in /proc/PID/{comm,stat,status}
authorTejun Heo <tj@kernel.org>
Fri, 18 May 2018 15:47:13 +0000 (08:47 -0700)
committerTejun Heo <tj@kernel.org>
Fri, 18 May 2018 15:47:13 +0000 (08:47 -0700)
commit6b59808bfe482642287ddf3fe9d4cccb10756652
treed97243a24dfec6ade0560190709f94101d06bcd1
parent88b72b31e15f9dfed069ede5416bb71040e0d299
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 patch 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

Unfortunately, ps(1) truncates comm to 15 characters,

  # ps 25
    PID TTY      STAT   TIME COMMAND
     25 ?        I      0:00 [kworker/2:0-eve]

making it a lot less useful; however, this should be an easy fix from
ps(1) side.

Signed-off-by: Tejun Heo <tj@kernel.org>
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Craig Small <csmall@enc.com.au>
fs/proc/array.c
include/linux/workqueue.h
kernel/workqueue.c