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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1AB81C4332F for ; Thu, 25 Nov 2021 09:38:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354204AbhKYJmH (ORCPT ); Thu, 25 Nov 2021 04:42:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:34781 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353978AbhKYJkG (ORCPT ); Thu, 25 Nov 2021 04:40:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637833014; 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=bxRJ0cHsxVoxBs1osi2vNK1d6yKSDIANe8hUIprtvQXyQakPTxZj/SOPZ0+va5e/YNIpVY rb6YaaHCbSWIMMqm5xoBeS0xDjfGoN4HGNJ68DAsnEgQPNHKKOB+6LZ2myBieOASq1iAKG AdFkwIJTwM1ZAax1+w2bMmUp8/wOZhs= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-232-KhKOSsa5M168ht-8ySKzGQ-1; Thu, 25 Nov 2021 04:36:53 -0500 X-MC-Unique: KhKOSsa5M168ht-8ySKzGQ-1 Received: by mail-wm1-f69.google.com with SMTP id z138-20020a1c7e90000000b003319c5f9164so4629353wmc.7 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=mpBxGuPGvO26TdRWLMnm2r8Xesjh/KZaQQIZHuhJkBW0UGYfriX4VFnuZJXmpm6coT vRAuZgtYczauJnyQzwC7r6ParcsVOwXLuKHBcXK11iSGn+1H8E5f58Aerw65JMhsBvsR QiQGn0L4uUGHwSrBWq5wlMGGWNP9bQJqAGVkYXhdFHv8cfUg4pDzbb+YvCgFZ7AVLp3K 8uQqVcJmDmB2p2Hrg3BladZj8/CfIGU5Nz8J4d9rIDgFG567jot5NYJf1JntuxI8L+sl Vsy/a0c0N8lnujEnN3qGBz27DACkz8KYKzsC5urBPcNSX8Kzg8J8i8sN41j9I5pY6Hj5 y4pw== X-Gm-Message-State: AOAM533dGx1dmAIBfhLy5dzDalS2kplW4TdlMwRFs4j1m3W5zFZRyWex ZPaZc/eYPvL5Qs0gHc3wMbNKnNb92g12CV+7yj5uNZ6Rg625aPH4Tg3nrIiXgHDod9nsFRvUlfi Rm0L5aNxaOoREQ4IbXZu5JaT/ X-Received: by 2002:a1c:4c19:: with SMTP id z25mr5259398wmf.177.1637833011740; 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 Content-Language: en-US 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> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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