Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp2303758pxb; Fri, 8 Oct 2021 05:18:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdlKWxkgCuvj+N/VvsuGywLUDe/8FhnkdT1yQtVhFYewQE1MOSlR+4w5UEz8jT8F6AH5we X-Received: by 2002:a17:90b:3588:: with SMTP id mm8mr11839149pjb.238.1633695489561; Fri, 08 Oct 2021 05:18:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633695489; cv=none; d=google.com; s=arc-20160816; b=jRB/Yx6h3vDO0vaGlRHxxaPaiwe7e4NGSS0meO7ivKL0RzEZ5FcZUO4C/JUmVQ/2OV ibTU46JHkonNYhaQUr2C0HJkaNoVs5A+f8d0jgQViuZ2xVVn13tF3HJcLM8lVgpPS+08 3Eg9DwKGUnuwIruAZND4lulmkXks2tOmdPZaac9sIpUe4rWLrIo76cHWCPEPMywo5hYZ CCSN2V+Hqf2NJnB+tKeglXKdAnixjeighhcdlwa8KiljK+6TpZ/7fBC7s3wuVwzwTuT6 AOYH8mI9Rpneg+5Px5kZFZZEKcol7jq+/y0ZymgbIiYyIRemPAxBxPkCqYUsr2lYZvhs zLzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=s7RegfCL6tH5xSc5mxPpRRtzBps25gyk/r/PHLPNIRI=; b=OUyfQqUWCSzVTsOGh6M1RLvWnH7i73C6cmZe41rdll3hTCggkXxFTNI/7b3Mm9okgA 6XNoCciLmrQ9gvXArsGCHksaqe/EuXAZ3RxqLL+JMw6wkKYkaCWXAoY0z1BmF8UuEVS8 TjkNOvQFnLMRGksxJbWB0OuIomEMS2vmcreS0M8/fy0ZTRrUPsowpAf9OM38B7zOAEPo G8bXkTJWxWBmXds3nbALHAEiTg5BfZDVl1Wg0+5VzxsPEMg99d4yCq6wMFyVrFtBfhEi dpZCLoDJ+jk4oWo76T4AmkaeOkVc40PXqXUOlTjsMBCAJaK1/Bi2XDw+cHpxiGvdw+06 38NQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=qfd5lSqN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k189si2721552pgd.496.2021.10.08.05.17.45; Fri, 08 Oct 2021 05:18:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=qfd5lSqN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240468AbhJHMQy (ORCPT + 99 others); Fri, 8 Oct 2021 08:16:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240615AbhJHMQx (ORCPT ); Fri, 8 Oct 2021 08:16:53 -0400 Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0945DC061570 for ; Fri, 8 Oct 2021 05:14:58 -0700 (PDT) Received: by mail-io1-xd2f.google.com with SMTP id 134so10407883iou.12 for ; Fri, 08 Oct 2021 05:14:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=s7RegfCL6tH5xSc5mxPpRRtzBps25gyk/r/PHLPNIRI=; b=qfd5lSqN8VBkxT53NtRve3pCi+plrXhIjPrXRHmFD9lIzJmXldDE+i/ZsTKJ+IFq/h 8/WuVfcpqHaCWNP/5UEY50mAqI97dxdwVucEK7kLF96OHlteQKbt+SapG8cuYy4Cp4tz 02SkFpEeSBffhsfSQoAT1Pb70855JKggCOJd7GwDScWU8bxEUiFJzTafaW6UcUFLRS6A ahsTxc1HChkio+3cla20TjboSMvHbT9mY5OVvKEGrZXX3QRZfa2NlrBctwTnbco1wR34 NPJr6Aa6XKHi+8M4QRhiDQYRbdtlZC9kbjXiVsLdpHzNNreZDuvmtmgMFxDMK4Nh0HVO 5uCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=s7RegfCL6tH5xSc5mxPpRRtzBps25gyk/r/PHLPNIRI=; b=hcdAn7HXtocXzarNA+cIEs+jELnHy/ANKtNodA3GRGCbhrLsRQKAqh6YApU3zwKTGH PuAQIhuUFGV2g17GGBP6cboT/jyRwfXho2iGTkcoY677zIKj3o027Yt3M+RjfNeScVL9 JlWXB2dc+XKLtKG7DKJUPOe0d6JVIOcRn1iUStw6+0mCMy7xoHzo1jLZtUGXyrRGyMP1 ryHKAcyUn1OKw4pqxOuRSpFsfH112rgAdgtJVzeGhGB/XkvJ4lZpZgSOt3v51JMfGfiJ qPnXXnY/RkpN5hO7ZX6H0icv2pRWXX1XdeErp1Yud+gwpBcCeNDrvKI3QyNuhhjxvO7F bEpw== X-Gm-Message-State: AOAM531lMeLmmqApzH0Ej1k+RDCtO/OfAQqhK4I/vPz+w+9T3y6gb9LV LbMx5gLLACshmX5YF93fJO/jWzd7T5eMtY/SFzE= X-Received: by 2002:a05:6638:d0e:: with SMTP id q14mr7207579jaj.139.1633695297388; Fri, 08 Oct 2021 05:14:57 -0700 (PDT) MIME-Version: 1.0 References: <20211007120752.5195-1-laoar.shao@gmail.com> <20211007120752.5195-5-laoar.shao@gmail.com> <20211007134103.4da8a8ab@gandalf.local.home> In-Reply-To: <20211007134103.4da8a8ab@gandalf.local.home> From: Yafang Shao Date: Fri, 8 Oct 2021 20:14:21 +0800 Message-ID: Subject: Re: [PATCH v2 4/4] kernel/kthread: show a warning if kthread's comm is truncated To: Steven Rostedt Cc: Petr Mladek , Kees Cook , Al Viro , Andrew Morton , Peter Zijlstra , Valentin Schneider , Mathieu Desnoyers , qiang.zhang@windriver.com, robdclark@chromium.org, christian@brauner.io, Dietmar Eggemann , Ingo Molnar , Juri Lelli , Vincent Guittot , Benjamin Segall , Mel Gorman , Daniel Bristot de Oliveira , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 8, 2021 at 1:41 AM Steven Rostedt wrote: > > On Thu, 7 Oct 2021 12:07:52 +0000 > Yafang Shao 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