LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 0/5] kthread: increase the size of kthread's comm
@ 2021-09-29 11:50 Yafang Shao
  2021-09-29 11:50 ` [PATCH 1/5] kernel: replace sizeof(task->comm) with TASK_COMM_LEN Yafang Shao
                   ` (5 more replies)
  0 siblings, 6 replies; 25+ messages in thread
From: Yafang Shao @ 2021-09-29 11:50 UTC (permalink / raw)
  To: akpm, pmladek, peterz, valentin.schneider, keescook,
	mathieu.desnoyers, qiang.zhang, robdclark, viro, christian,
	dietmar.eggemann
  Cc: linux-kernel, Yafang Shao

When I was implementing a new kthread cfs_migration [1], I found the
comm of it is trucated due to the limitation of TASK_COMM_LEN. After I
checked the other kthreads, I found some of them are also truncated, for
example,

    rcu_tasks_kthre
    rcu_tasks_rude_
    rcu_tasks_trace
    ecryptfs-kthrea
    vfio-irqfd-clea
    ext4-rsv-conver
    jbd2/nvme0n1p2-
    ...
    
Besides the in-tree kthreads listed above, the out-of-tree kthreads may
also be trucated, for example,
    
    rtase_work_queu
    nvidia-modeset/
    UVM global queu
    UVM deferred re
    ...
    
That motivates me to do this improvement.

This patch increases the size of ktread's comm from 16 to 24, which is
the same with workqueue's. After this change, the name of kthread can be
fully displayed in /proc/[pid]/comm, for example,
    
    rcu_tasks_kthread
    rcu_tasks_rude_kthread
    rcu_tasks_trace_kthread
    ecryptfs-kthread
    vfio-irqfd-cleanup
    ext4-rsv-conversion
    jbd2/nvme0n1p2-8
    ...
    
Because there're only a few of kthreads, so it won't increase too much
memory consumption.

After this improvement, if the comm of a kthread is still trucated, a
warning will be displayed. Below is the result of my test case -

__kthread_create_on_node:410: comm of pid 14 is truncated from "I-am-a-kthread-with-long-name" to "I-am-a-kthread-with-lon"

[1]. https://lore.kernel.org/lkml/YMmlAP%2FQhE6SWhCF@hirez.programming.kicks-ass.net/

Yafang Shao (5):
  kernel: replace sizeof(task->comm) with TASK_COMM_LEN
  kernel/fork: allocate task->comm dynamicly
  kernel/sched: improve the BUILD_BUG_ON() in get_task_comm()
  kernel: increase the size of kthread's comm
  kernel/kthread: show a warning if kthread's comm is still trucated

 arch/ia64/kernel/mca.c         |  6 +++---
 drivers/block/drbd/drbd_main.c |  2 +-
 drivers/hwtracing/stm/core.c   |  2 +-
 drivers/tty/tty_audit.c        |  2 +-
 fs/exec.c                      |  5 ++++-
 include/linux/sched.h          |  6 ++++--
 kernel/audit.c                 |  4 ++--
 kernel/auditsc.c               |  4 ++--
 kernel/capability.c            |  4 ++--
 kernel/fork.c                  | 26 ++++++++++++++++++++++++++
 kernel/futex.c                 |  2 +-
 kernel/kthread.c               |  8 ++++++--
 kernel/sys.c                   |  2 +-
 kernel/trace/blktrace.c        |  2 +-
 security/lsm_audit.c           |  4 ++--
 security/selinux/selinuxfs.c   |  2 +-
 security/yama/yama_lsm.c       |  2 +-
 sound/core/oss/pcm_oss.c       |  2 +-
 18 files changed, 60 insertions(+), 25 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2021-10-03 14:21 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-29 11:50 [PATCH 0/5] kthread: increase the size of kthread's comm Yafang Shao
2021-09-29 11:50 ` [PATCH 1/5] kernel: replace sizeof(task->comm) with TASK_COMM_LEN Yafang Shao
2021-09-29 18:09   ` Kees Cook
2021-09-30 12:27     ` Yafang Shao
2021-10-03  3:31   ` Al Viro
2021-10-03 14:14     ` Yafang Shao
2021-09-29 11:50 ` [PATCH 2/5] kernel/fork: allocate task->comm dynamicly Yafang Shao
2021-09-29 13:08   ` Yafang Shao
2021-09-29 18:11   ` Kees Cook
2021-09-30 12:41     ` Yafang Shao
2021-09-30 14:51       ` Petr Mladek
2021-10-01 11:58         ` Yafang Shao
2021-09-29 11:50 ` [PATCH 3/5] kernel/sched: improve the BUILD_BUG_ON() in get_task_comm() Yafang Shao
2021-09-29 18:12   ` Kees Cook
2021-09-30 12:43     ` Yafang Shao
2021-09-29 11:50 ` [PATCH 4/5] kernel: increase the size of kthread's comm Yafang Shao
2021-09-29 18:19   ` Kees Cook
2021-09-30 12:53     ` Yafang Shao
2021-09-29 11:50 ` [PATCH 5/5] kernel/kthread: show a warning if kthread's comm is still trucated Yafang Shao
2021-09-29 18:20   ` Kees Cook
2021-09-30 12:54     ` Yafang Shao
2021-09-30 15:17   ` Petr Mladek
2021-10-01 11:59     ` Yafang Shao
2021-10-03  3:41 ` [PATCH 0/5] kthread: increase the size of kthread's comm Al Viro
2021-10-03 14:20   ` Yafang Shao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).