lkml.org 
[lkml]   [2021]   [Sep]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 5/5] kernel/kthread: show a warning if kthread's comm is still trucated
Date
Show a warning if the ktrhead's comm is still trucated. 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"

Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
kernel/kthread.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/kernel/kthread.c b/kernel/kthread.c
index 6def951c605a..aa093f1f423a 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -404,7 +404,11 @@ struct task_struct *__kthread_create_on_node(int (*threadfn)(void *data),
* task is already visible to other tasks, so updating
* COMM must be protected.
*/
- vsnprintf(name, sizeof(name), namefmt, args);
+ if (vsnprintf(name, KTHREAD_COMM_LEN, namefmt, args) >=
+ KTHREAD_COMM_LEN)
+ pr_warn("%s:%d: comm of pid %d is truncated from \"%s\" to \"%s\"\n",
+ __func__, __LINE__, task->pid, namefmt, name);
+
set_task_comm(task, name);
/*
* root may have changed our (kthreadd's) priority or CPU mask.
--
2.17.1
\
 
 \ /
  Last update: 2021-09-29 13:53    [W:0.179 / U:1.248 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site