From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D69AC433EF for ; Thu, 25 Nov 2021 09:37:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DA2226B007E; Thu, 25 Nov 2021 04:37:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D2B0F6B0080; Thu, 25 Nov 2021 04:37:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BA4F66B0081; Thu, 25 Nov 2021 04:37:07 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0145.hostedemail.com [216.40.44.145]) by kanga.kvack.org (Postfix) with ESMTP id A7D256B007E for ; Thu, 25 Nov 2021 04:37:07 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 679FF884BC for ; Thu, 25 Nov 2021 09:36:57 +0000 (UTC) X-FDA: 78846948432.07.92D42E5 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf06.hostedemail.com (Postfix) with ESMTP id 9EC67801AB27 for ; Thu, 25 Nov 2021 09:36:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637833016; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1j3sEyc7U5pLLP7CDKkBf36qc69o78zC3HxT76AE2R0=; b=PgaptNZxoGSJvXc3ppNyO7y21FcmhX9j29p3u1qynfv89of/u/EAtbqWCOgyAs295gBAff XAaATnIxc8NeYBKHe44tDMiIjxvvSea4tSP2GxaVA6iDMTM26osAsTtTC7l/kfP7a6F40Q kAXWf7R4f7q7YZlLEuYu0jb1nSs6pqg= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-232-nuJGZGDpNH-FOH_Sw4AO8Q-1; Thu, 25 Nov 2021 04:36:53 -0500 X-MC-Unique: nuJGZGDpNH-FOH_Sw4AO8Q-1 Received: by mail-wm1-f70.google.com with SMTP id a85-20020a1c7f58000000b0033ddc0eacc8so2754682wmd.9 for ; Thu, 25 Nov 2021 01:36:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=1j3sEyc7U5pLLP7CDKkBf36qc69o78zC3HxT76AE2R0=; b=45I6+PJIFBeWFWEKGuaNcoLeiBHlMoZ0x3sc9n1uwQW+PY4zVvMvKfJA+1KXOvj+qi aMuoo0CuTJw7QfJ9t2p1ua6dNyH/6+75jXK3tHgd2g5SMLssAu5gUAWkmI8WwNMeUi1m boAN6wZT/B0LE15klR8ZwdLBWi9g5FlvL7LLG09BWkDh+G10etbKW6Ej3T50e916Xea9 dMI6Y5qN5hQCRHBdnVmXU3JqueJyu0+H0XwC12Li4S4kEdaF40+JLmjZo/x6K5QGd64o rVSB4yuiDcc9IwpKOzXl61ePouME/FiJpqUpZMS2Era7QQxr2g8K+/V7ZtwLwtS/yPbf /PGw== X-Gm-Message-State: AOAM5323+72j7eTl3nihpKXC+PehwcybWlyhGe/N9RxNG//1TvCY6xCL akHKyXClIku8WYHe3gruv3w9TLQ+ulWMWrFQZM4WxK4odqHB4tSw99tGQF3Rpyn7SaMHGenaB3o uYDR3s6Y81As= X-Received: by 2002:a1c:4c19:: with SMTP id z25mr5259412wmf.177.1637833011777; Thu, 25 Nov 2021 01:36:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJxNT7yd66eB6qLpcYDn59R65nZF06/c+i4fTo/9h0VU3346D4G4ZX5Keq0oDymUbsMTzkxV8g== X-Received: by 2002:a1c:4c19:: with SMTP id z25mr5259366wmf.177.1637833011529; Thu, 25 Nov 2021 01:36:51 -0800 (PST) Received: from [192.168.3.132] (p5b0c679e.dip0.t-ipconnect.de. [91.12.103.158]) by smtp.gmail.com with ESMTPSA id d2sm2428646wmb.31.2021.11.25.01.36.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 25 Nov 2021 01:36:50 -0800 (PST) Message-ID: <435fab0b-d345-3698-79af-ff858181666a@redhat.com> Date: Thu, 25 Nov 2021 10:36:49 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: [PATCH v2] kthread: dynamically allocate memory to store kthread's full name To: Yafang Shao , akpm@linux-foundation.org Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, oliver.sang@intel.com, lkp@intel.com, Petr Mladek , Steven Rostedt , Mathieu Desnoyers , Arnaldo Carvalho de Melo , Alexei Starovoitov , Andrii Nakryiko , Michal Miroslaw , Peter Zijlstra , Matthew Wilcox , Al Viro , Kees Cook References: <20211120112850.46047-1-laoar.shao@gmail.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: <20211120112850.46047-1-laoar.shao@gmail.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 9EC67801AB27 X-Stat-Signature: kx9bdwqpo6m5rgn1q4yu9i5bsfa9iebr Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=PgaptNZx; spf=none (imf06.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-HE-Tag: 1637833015-617365 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 20.11.21 12:28, Yafang Shao wrote: > When I was implementing a new per-cpu kthread cfs_migration, I found the > comm of it "cfs_migration/%u" is truncated due to the limitation of > TASK_COMM_LEN. For example, the comm of the percpu thread on CPU10~19 are > all with the same name "cfs_migration/1", which will confuse the user. This > issue is not critical, because we can get the corresponding CPU from the > task's Cpus_allowed. But for kthreads correspoinding to other hardware > devices, it is not easy to get the detailed device info from task comm, > for example, > > jbd2/nvme0n1p2- > xfs-reclaim/sdf > > Currently there are so many truncated kthreads: > > rcu_tasks_kthre > rcu_tasks_rude_ > rcu_tasks_trace > poll_mpt3sas0_s > ext4-rsv-conver > xfs-reclaim/sd{a, b, c, ...} > xfs-blockgc/sd{a, b, c, ...} > xfs-inodegc/sd{a, b, c, ...} > audit_send_repl > ecryptfs-kthrea > vfio-irqfd-clea > jbd2/nvme0n1p2- > ... > > We can shorten these names to work around this problem, but it may be > not applied to all of the truncated kthreads. Take 'jbd2/nvme0n1p2-' for > example, it is a nice name, and it is not a good idea to shorten it. > > One possible way to fix this issue is extending the task comm size, but > as task->comm is used in lots of places, that may cause some potential > buffer overflows. Another more conservative approach is introducing a new > pointer to store kthread's full name if it is truncated, which won't > introduce too much overhead as it is in the non-critical path. Finally we > make a dicision to use the second approach. See also the discussions in > this thread: > https://lore.kernel.org/lkml/20211101060419.4682-1-laoar.shao@gmail.com/ > > After this change, the full name of these truncated kthreads will be > displayed via /proc/[pid]/comm: > > rcu_tasks_kthread > rcu_tasks_rude_kthread > rcu_tasks_trace_kthread > poll_mpt3sas0_statu > ext4-rsv-conversion > xfs-reclaim/sdf1 > xfs-blockgc/sdf1 > xfs-inodegc/sdf1 > audit_send_reply > ecryptfs-kthread > vfio-irqfd-cleanup > jbd2/nvme0n1p2-8 I do wonder if that could break some user space that assumes these names have maximum length .. But LGTM Reviewed-by: David Hildenbrand -- Thanks, David / dhildenb