[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CALOAHbDW4KnHndEXFVs-teQy6EQWuSi7thjkp7Ye8kboUGgvKg@mail.gmail.com>
Date: Fri, 8 Oct 2021 20:14:21 +0800
From: Yafang Shao <laoar.shao@...il.com>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: Petr Mladek <pmladek@...e.com>, Kees Cook <keescook@...omium.org>,
Al Viro <viro@...iv.linux.org.uk>,
Andrew Morton <akpm@...ux-foundation.org>,
Peter Zijlstra <peterz@...radead.org>,
Valentin Schneider <valentin.schneider@....com>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
qiang.zhang@...driver.com, robdclark@...omium.org,
christian@...uner.io, Dietmar Eggemann <dietmar.eggemann@....com>,
Ingo Molnar <mingo@...hat.com>,
Juri Lelli <juri.lelli@...hat.com>,
Vincent Guittot <vincent.guittot@...aro.org>,
Benjamin Segall <bsegall@...gle.com>,
Mel Gorman <mgorman@...e.de>,
Daniel Bristot de Oliveira <bristot@...hat.com>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 4/4] kernel/kthread: show a warning if kthread's comm
is truncated
On Fri, Oct 8, 2021 at 1:41 AM Steven Rostedt <rostedt@...dmis.org> wrote:
>
> On Thu, 7 Oct 2021 12:07:52 +0000
> Yafang Shao <laoar.shao@...il.com> 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);
>
> ?
>
The 'name' is the truncated one. So it will be printed like,
[ 0.222126] truncated kthread comm from:rcu_tasks_kthre
to:rcu_tasks_kthre for pid:10
If we want to show the full name, we have to use the namefmt, which
is not suggested to use by Petr.
See also https://lore.kernel.org/lkml/YVXVBXSZ1m4ScvbX@alley/
Or we can do it as follows,
- char name[TASK_COMM_LEN];
+ /* To show the full name if it will be truncated. */
+ char name[TASK_COMM_LEN + 8];
Then the full name will be printed:
[ 0.222587] truncated kthread comm from:rcu_tasks_kthread
to:rcu_tasks_kthre for pid:10
But that seems a little overkill ?
--
Thanks
Yafang
Powered by blists - more mailing lists