Re: [PATCH v2 4/4] kernel/kthread: show a warning if kthread's comm is truncated

From: Steven Rostedt
Date: Thu Oct 07 2021 - 13:41:11 EST


On Thu, 7 Oct 2021 12:07:52 +0000
Yafang Shao <laoar.shao@xxxxxxxxx> wrote:

> - vsnprintf(name, sizeof(name), namefmt, args);
> + len = vsnprintf(name, sizeof(name), namefmt, args);
> + if (len >= TASK_COMM_LEN) {
> + pr_warn("truncated kthread comm:%s, pid:%d by %d characters\n",
> + name, task->pid, len - TASK_COMM_LEN + 1);

Instead of saying how many characters it is truncated to, what about just
showing what it was truncated to?

pr_warn("truncated kthread comm from:%s to:%.*s for pid:%d\n",
name, TASK_COMM_LEN - 1, name, task->pid);

?

-- Steve

> + }