lkml.org 
[lkml]   [2021]   [Oct]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    Date
    SubjectRe: [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@goodmis.org> wrote:
    >
    > On Thu, 7 Oct 2021 12:07:52 +0000
    > Yafang Shao <laoar.shao@gmail.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

    \
     
     \ /
      Last update: 2021-10-08 14:15    [W:2.943 / U:0.016 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site