From patchwork Mon Mar 31 12:18:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupesh X-Patchwork-Id: 14033740 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 455D9C3600C for ; Mon, 31 Mar 2025 15:54:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CDAA7280009; Mon, 31 Mar 2025 11:54:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C89EF280002; Mon, 31 Mar 2025 11:54:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B29FB280009; Mon, 31 Mar 2025 11:54:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 8E3DE280002 for ; Mon, 31 Mar 2025 11:54:04 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id E923BBA51E for ; Mon, 31 Mar 2025 12:18:53 +0000 (UTC) X-FDA: 83281750146.23.68571AD Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf15.hostedemail.com (Postfix) with ESMTP id 332D8A0011 for ; Mon, 31 Mar 2025 12:18:51 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=GLoQ8Gs7; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf15.hostedemail.com: domain of bhupesh@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=bhupesh@igalia.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743423532; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=m2o+Mi9B+LLlSr1F+IZ6AiiYjWbrFv3KIUCOssd5KE4=; b=UNbi2EdKzYIzUJ6A1ZuSqNI5I3QhSO4L3CfZqncc++Z6xFp3K5x14tQ/uQ/yxrQ556v4AV qnPO4ANWEITzISEVBW9Ni481XCkV7vHplV1ayxWKzbEhqXKF+Fg3G1HkTLJFgpKSdn5bP4 WrhIREt8wFHyaRNX/94qMsX+C8jfKuw= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=GLoQ8Gs7; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf15.hostedemail.com: domain of bhupesh@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=bhupesh@igalia.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743423532; a=rsa-sha256; cv=none; b=vjp5pKokA5SZOSESXXzyEn5jGiCmEavg+5jfTXvV5tlq6BBzi/GJRYOUf6srmcsmwoxiRo ph1a3Bb0HuiZeKNofrE2tl4Bpoth129YBtyRto5o9TiwCvfR8VDDgjHg1CtNzBwEegrmdd uc4aI0RDY+P42v25ewW666xFbPT/kbM= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=m2o+Mi9B+LLlSr1F+IZ6AiiYjWbrFv3KIUCOssd5KE4=; b=GLoQ8Gs7Pv63GbZtpCeznhHQZD uGrw3V2kkzc05t3W9WL4nTZX5nrNHWFnf2oI+TulxjbbjiBuH13I6FIwJmAxh+qaikLRf3yKZ9e0z HD2HPTVbcLIBMPpKCCNDYZNLYwDAMk5n0eNwKKqtHRFqZkh5X0CfkPs48QBJytxuJywPJmCPFb4Ib u9XW3oOch4MwZynhdtcLpW7cqx8XuMgcjx6Yf01DOmYLiIcDbPGgJ9AAt1oCmCpLswGouy5i/3ZQ0 76c3H2ssIWvhu42wYkEIJ+CiP9csFpnYwT9QyddFHdCDAOMxhAdUHpNDFggAQynJsn7TfsVUjmVv4 e7mlHXnw==; Received: from [223.233.69.2] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1tzE6G-009Btr-G1; Mon, 31 Mar 2025 14:18:44 +0200 From: Bhupesh To: akpm@linux-foundation.org Cc: bhupesh@igalia.com, kernel-dev@igalia.com, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, oliver.sang@intel.com, lkp@intel.com, laoar.shao@gmail.com, pmladek@suse.com, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, arnaldo.melo@gmail.com, alexei.starovoitov@gmail.com, andrii.nakryiko@gmail.com, mirq-linux@rere.qmqm.pl, peterz@infradead.org, willy@infradead.org, david@redhat.com, viro@zeniv.linux.org.uk, keescook@chromium.org, ebiederm@xmission.com, brauner@kernel.org, jack@suse.cz, mingo@redhat.com, juri.lelli@redhat.com, bsegall@google.com, mgorman@suse.de, vschneid@redhat.com Subject: [PATCH v2 1/3] exec: Dynamically allocate memory to store task's full name Date: Mon, 31 Mar 2025 17:48:18 +0530 Message-Id: <20250331121820.455916-2-bhupesh@igalia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20250331121820.455916-1-bhupesh@igalia.com> References: <20250331121820.455916-1-bhupesh@igalia.com> MIME-Version: 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jk7Tk9ISOhrvhu1zVqgUDfJV t5Jn7Yq+ W5JxkEMNKiX1BJU+D9PFzlGCHGpn1My1UgKoL/YiTeYiIm9foT3lkz98CXU9lGuBeK4pjE77QolBDslyECJHz62Ce2oAh4wc0VBzOeffUYudJwAYPqtYIoJlCEtIaJJfwPU4XnTIj1QM7lH8dU8XZavs0dQB7MCm3qGXinIuNK+R4Eron2yYgWwQnODFfo9D3Ko+EUfqPnrVK3SjxeClBXHdFX2+2pUxZekhX9RBjWgHuQxsdBNYB7z8KTx3s/3opA1Bnu0TIHkJhszUe0HIFClykllybSv8WIF64FTHBeARg4s2tiDI0Kn90cfc/ph4woStZm+0XqimBqZ5FcpjAXyGEEw== 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: List-Subscribe: List-Unsubscribe: Provide a parallel implementation for get_task_comm() called get_task_full_name() which allows the dynamically allocated and filled-in task's full name to be passed to interested users such as 'gdb'. Currently while running 'gdb', the 'task->comm' value of a long task name is truncated due to the limitation of TASK_COMM_LEN. For example using gdb to debug a simple app currently which generate threads with long task names: # gdb ./threadnames -ex "run info thread" -ex "detach" -ex "quit" > log # cat log NameThatIsTooLo This patch does not touch 'TASK_COMM_LEN' at all, i.e. 'TASK_COMM_LEN' and the 16-byte design remains untouched. Which means that all the legacy / existing ABI, continue to work as before using '/proc/$pid/task/$tid/comm'. This patch only adds a parallel, dynamically-allocated 'task->full_name' which can be used by interested users via '/proc/$pid/task/$tid/full_name'. After this change, gdb is able to show full name of the task: # gdb ./threadnames -ex "run info thread" -ex "detach" -ex "quit" > log # cat log NameThatIsTooLongForComm[4662] Signed-off-by: Bhupesh --- fs/exec.c | 21 ++++++++++++++++++--- include/linux/sched.h | 9 +++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/fs/exec.c b/fs/exec.c index f45859ad13ac..4219d77a519c 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1208,6 +1208,9 @@ int begin_new_exec(struct linux_binprm * bprm) { struct task_struct *me = current; int retval; + va_list args; + char *name; + const char *fmt; /* Once we are committed compute the creds */ retval = bprm_creds_from_file(bprm); @@ -1348,11 +1351,22 @@ int begin_new_exec(struct linux_binprm * bprm) * detecting a concurrent rename and just want a terminated name. */ rcu_read_lock(); - __set_task_comm(me, smp_load_acquire(&bprm->file->f_path.dentry->d_name.name), - true); + fmt = smp_load_acquire(&bprm->file->f_path.dentry->d_name.name); + name = kvasprintf(GFP_KERNEL, fmt, args); + if (!name) + return -ENOMEM; + + me->full_name = name; + __set_task_comm(me, fmt, true); rcu_read_unlock(); } else { - __set_task_comm(me, kbasename(bprm->filename), true); + fmt = kbasename(bprm->filename); + name = kvasprintf(GFP_KERNEL, fmt, args); + if (!name) + return -ENOMEM; + + me->full_name = name; + __set_task_comm(me, fmt, true); } /* An exec changes our domain. We are no longer part of the thread @@ -1399,6 +1413,7 @@ int begin_new_exec(struct linux_binprm * bprm) return 0; out_unlock: + kfree(me->full_name); up_write(&me->signal->exec_update_lock); if (!bprm->cred) mutex_unlock(&me->signal->cred_guard_mutex); diff --git a/include/linux/sched.h b/include/linux/sched.h index 56ddeb37b5cd..053b52606652 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1166,6 +1166,9 @@ struct task_struct { */ char comm[TASK_COMM_LEN]; + /* To store the full name if task comm is truncated. */ + char *full_name; + struct nameidata *nameidata; #ifdef CONFIG_SYSVIPC @@ -2007,6 +2010,12 @@ extern void __set_task_comm(struct task_struct *tsk, const char *from, bool exec buf; \ }) +#define get_task_full_name(buf, buf_size, tsk) ({ \ + BUILD_BUG_ON(sizeof(buf) < TASK_COMM_LEN); \ + strscpy_pad(buf, (tsk)->full_name, buf_size); \ + buf; \ +}) + #ifdef CONFIG_SMP static __always_inline void scheduler_ipi(void) { From patchwork Mon Mar 31 12:18:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupesh X-Patchwork-Id: 14033751 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 975FBC3600B for ; Mon, 31 Mar 2025 15:58:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B9565280003; Mon, 31 Mar 2025 11:58:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B449F280001; Mon, 31 Mar 2025 11:58:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A0D5E280003; Mon, 31 Mar 2025 11:58:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 86999280001 for ; Mon, 31 Mar 2025 11:58:48 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id BDEC1A8C49 for ; Mon, 31 Mar 2025 12:18:56 +0000 (UTC) X-FDA: 83281750272.23.331A58F Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf22.hostedemail.com (Postfix) with ESMTP id 22701C0013 for ; Mon, 31 Mar 2025 12:18:54 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=TqEYOS1L; spf=pass (imf22.hostedemail.com: domain of bhupesh@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=bhupesh@igalia.com; dmarc=pass (policy=none) header.from=igalia.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743423535; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=1vPxYQklOIhLFkReMGUcHBCTjGCn9JiiqKZjhqBdRYE=; b=bRUq8TVEXuVAiFQ9foRThBjXuJy0lyMcrLvBR4mIF0DjQWVjO8p+7Oy4Dhbol71eVhXK+p nueFnWk7qWwVGkX1o2p731OiCQpbBH3rlFkuvmLKkZ7hQMoFuUklnitMrYEcTaK9C8gArD /Q+e2OzwckZ0Qz/SpH4K2gam91cP+nU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743423535; a=rsa-sha256; cv=none; b=tqMlSX6EHdefuNy+xjkteCznVihRZeVf4ZXMPDoOPvYH8SFohe/D9aaV/iFmkPrRr7Ibuw FY0eDOSQl/Lkb0Iaf/15OMcC/ey5VDs9uyCDhlSKfAjxp9bpGelnEzAxfQWB3CXORqwlFA cM2mbPcOMpwFBInr0d/12QkyDOxoEi0= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=TqEYOS1L; spf=pass (imf22.hostedemail.com: domain of bhupesh@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=bhupesh@igalia.com; dmarc=pass (policy=none) header.from=igalia.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=1vPxYQklOIhLFkReMGUcHBCTjGCn9JiiqKZjhqBdRYE=; b=TqEYOS1L0FuyNPN6TTGJbIhjWh Wv6kmaGcSFWdzjyJpWyzinSSBVAvoahZ250TPc1+V1nKbFfVCBHv+FvFswD5tjZsh2dAkXqtnmTqn 5zHVmbIIPu8Jo0kw6gSUSxx9FqGex6HFS2inBsaidT5/qFyGPtuKfYSej51pL3w2heC79jIeihsYX Bv+yr86mXTMVr04VBnoEKyF1IRgG84bZ0qFmsuV2jRLOhgTfXlx/Z4jwy4Sbkd/l9Rbs805RMbwSk em+a+oZX74gkW+JRxRK6rA1gPrTj5zz4XLyDTiurr4h06HWLoQEhfwFblTMYFQEazwBPiYZg7S4O1 pmUfRABg==; Received: from [223.233.69.2] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1tzE6M-009Btr-UZ; Mon, 31 Mar 2025 14:18:51 +0200 From: Bhupesh To: akpm@linux-foundation.org Cc: bhupesh@igalia.com, kernel-dev@igalia.com, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, oliver.sang@intel.com, lkp@intel.com, laoar.shao@gmail.com, pmladek@suse.com, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, arnaldo.melo@gmail.com, alexei.starovoitov@gmail.com, andrii.nakryiko@gmail.com, mirq-linux@rere.qmqm.pl, peterz@infradead.org, willy@infradead.org, david@redhat.com, viro@zeniv.linux.org.uk, keescook@chromium.org, ebiederm@xmission.com, brauner@kernel.org, jack@suse.cz, mingo@redhat.com, juri.lelli@redhat.com, bsegall@google.com, mgorman@suse.de, vschneid@redhat.com Subject: [PATCH v2 2/3] fs/proc: Pass 'task->full_name' via 'proc_task_name()' Date: Mon, 31 Mar 2025 17:48:19 +0530 Message-Id: <20250331121820.455916-3-bhupesh@igalia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20250331121820.455916-1-bhupesh@igalia.com> References: <20250331121820.455916-1-bhupesh@igalia.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 22701C0013 X-Stat-Signature: q9aprw51f6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FyW5pHE+JFaPtawjCgNI5y3hTn/IdUg3Tf0iU4RmRAf2d7nPfhcH7cOwDv3VKb21FVbXiEyUDJGDb48Zh4qhqDfZrnhvz0ZZfVy1QNodYO5odl+EvoF+A0V0/hfpmQBFGij9iOJUfGZ/RkSeN3barh4Vouxz5XFDEs3MpHzAA5qX+Ti7e6K6GvFDgYxuqXDzfzhXZs0x3DIT5qomo2REvml/LBLy4IJI6Ze+dx6oADD0qgIfEhOEjYMM9e02b5/q4Y2GiHi0ZE6VYbjVnjJXvRWlLND0Ji+QsUWFwdJIKcAWhzKcGjLLhNcE/R79w7dmIl1xjdLMv9CUDxvJ4stwmlWsDVQIV0X6W7we43C1Ejnv4/oyLF9xAe0= 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: List-Subscribe: List-Unsubscribe: Now that we have the get_task_full_name() implementation which allows the dynamically allocated and filled in task's full name to be passed to interested users, use it in proc_task_name() by default for task names so that user-land can see them through appropriate tools (such as 'ps'). Signed-off-by: Bhupesh --- fs/proc/array.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/proc/array.c b/fs/proc/array.c index d6a0369caa93..2cbeb1584f8a 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c @@ -109,7 +109,7 @@ void proc_task_name(struct seq_file *m, struct task_struct *p, bool escape) else if (p->flags & PF_KTHREAD) get_kthread_comm(tcomm, sizeof(tcomm), p); else - get_task_comm(tcomm, p); + get_task_full_name(tcomm, sizeof(tcomm), p); if (escape) seq_escape_str(m, tcomm, ESCAPE_SPACE | ESCAPE_SPECIAL, "\n\\"); From patchwork Mon Mar 31 12:18:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupesh X-Patchwork-Id: 14033741 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 3313FC3600B for ; Mon, 31 Mar 2025 15:54:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A4DEE28000B; Mon, 31 Mar 2025 11:54:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9F9A2280002; Mon, 31 Mar 2025 11:54:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 847A328000B; Mon, 31 Mar 2025 11:54:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 61CD2280002 for ; Mon, 31 Mar 2025 11:54:44 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 7BF771C7D9C for ; Mon, 31 Mar 2025 12:19:03 +0000 (UTC) X-FDA: 83281750566.11.27BF1BE Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf26.hostedemail.com (Postfix) with ESMTP id D7072140010 for ; Mon, 31 Mar 2025 12:19:01 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b="L+o/M001"; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf26.hostedemail.com: domain of bhupesh@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=bhupesh@igalia.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743423542; a=rsa-sha256; cv=none; b=L6Tpbj1Wd2c9CjoxXenRpz6TEsG4mm64M9DxAEac62xGpqy+iUN+9Vvib6NwPhfZAMgval 0WcdnVPCTZMJBrM4urt3mZJjf5ZUg+XiqJGGRHQkdcf2l502FIlMHovBRlYBgHbnhAsHJP 1DdNAvGKVp3KjvpDOlwkAr9RYLIEY5E= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b="L+o/M001"; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf26.hostedemail.com: domain of bhupesh@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=bhupesh@igalia.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743423541; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=1MkSIgjVP+CNberSoyFKkoWthULoTCREbX6XMJGd8lA=; b=iphuzDU7xIUOOpoLu+xlavtf7t6zf402BYf1h1VXx4vR+CxYWeSil8vU7vumlM2rcaqf1q mlY0Fv/cWZumDg69iiY7ltQ5CY8SvNL9xOMszu2gxA/R9dZXLSiCJMMxMaVfLTWXf3NCAN TrONfsDxd+X6zMXq1snNeNl7NIChHRY= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=1MkSIgjVP+CNberSoyFKkoWthULoTCREbX6XMJGd8lA=; b=L+o/M001kDp9zhtwVq6l7nKazt X33DiETYaftD/OyEKT64sHULD1LqxAwwGVw2p50uEMaK8Qxw903OL83zpimWSnT/AHZUoHF86VBDT icgPE3a6B0BK5o0wn1dBYthmgxXQyzbDDZq1kMesB+zKwc85ztragw76N+q/2nRszAE1/kYMvEZdA gs+dsWb+iugK2xp8P6uKnQMf9F1HBIzIcT9OOqwqnFbHCzaIy6x4thyVVAfgzGoM2ve5QKQo15BI1 KnWXeXxsk2+zHZljLGAKzCB7cD/Wxt1H3wBSb9Hfk8+ifIoOJoYdN3Q3YToOJG3eC8hGhbtDze8ai 5mrotbzg==; Received: from [223.233.69.2] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1tzE6T-009Btr-M7; Mon, 31 Mar 2025 14:18:58 +0200 From: Bhupesh To: akpm@linux-foundation.org Cc: bhupesh@igalia.com, kernel-dev@igalia.com, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, oliver.sang@intel.com, lkp@intel.com, laoar.shao@gmail.com, pmladek@suse.com, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, arnaldo.melo@gmail.com, alexei.starovoitov@gmail.com, andrii.nakryiko@gmail.com, mirq-linux@rere.qmqm.pl, peterz@infradead.org, willy@infradead.org, david@redhat.com, viro@zeniv.linux.org.uk, keescook@chromium.org, ebiederm@xmission.com, brauner@kernel.org, jack@suse.cz, mingo@redhat.com, juri.lelli@redhat.com, bsegall@google.com, mgorman@suse.de, vschneid@redhat.com Subject: [PATCH v2 3/3] kthread: Use 'task_struct->full_name' to store kthread's full name Date: Mon, 31 Mar 2025 17:48:20 +0530 Message-Id: <20250331121820.455916-4-bhupesh@igalia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20250331121820.455916-1-bhupesh@igalia.com> References: <20250331121820.455916-1-bhupesh@igalia.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: D7072140010 X-Stat-Signature: jq39trndq35nuku6qn98coku4rnwpyeo X-Rspam-User: X-Rspamd-Server: rspam06 X-HE-Tag: 1743423541-711548 X-HE-Meta: U2FsdGVkX190aoqFd+KZ4molRoNPrTOYnHqcvz6ciH2VMg8AHUW5otpEoHMP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mW6aY5oyW4t3LmC2cWmKF6CMlCCZIfZqyntJNgJndZL7wvJO3S7/ZVNKXz0rU/XhYovacnv43otBOqBYSj4pg4nvYwsfvv6GA0ne5082tnWXXUTEBDjHeasyPJoeJq0mJiQogv/ho3PcwodeHx2yycaBgRmiALjbpqAZMiquvx+0ao0zKcYftXGmFYDsLOzLNjnmWcLhTYqnoDAOsF2iBPMsLaPjA00GLFGFk41lNiLqByAPxkB2yU= 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: List-Subscribe: List-Unsubscribe: Commit 6986ce24fc00 ("kthread: dynamically allocate memory to store kthread's full name"), added 'full_name' in parallel to 'comm' for kthread names. Now that we have added 'full_name' added to 'task_struct' itself, drop the additional 'full_name' entry from 'struct kthread' and also its usage. Signed-off-by: Bhupesh --- kernel/kthread.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/kernel/kthread.c b/kernel/kthread.c index 5dc5b0d7238e..46fe19b7ef76 100644 --- a/kernel/kthread.c +++ b/kernel/kthread.c @@ -66,8 +66,6 @@ struct kthread { #ifdef CONFIG_BLK_CGROUP struct cgroup_subsys_state *blkcg_css; #endif - /* To store the full name if task comm is truncated. */ - char *full_name; struct task_struct *task; struct list_head hotplug_node; struct cpumask *preferred_affinity; @@ -108,12 +106,12 @@ void get_kthread_comm(char *buf, size_t buf_size, struct task_struct *tsk) { struct kthread *kthread = to_kthread(tsk); - if (!kthread || !kthread->full_name) { + if (!kthread || !tsk->full_name) { strscpy(buf, tsk->comm, buf_size); return; } - strscpy_pad(buf, kthread->full_name, buf_size); + strscpy_pad(buf, tsk->full_name, buf_size); } bool set_kthread_struct(struct task_struct *p) @@ -153,7 +151,6 @@ void free_kthread_struct(struct task_struct *k) WARN_ON_ONCE(kthread->blkcg_css); #endif k->worker_private = NULL; - kfree(kthread->full_name); kfree(kthread); } @@ -430,7 +427,7 @@ static int kthread(void *_create) kthread_exit(-EINTR); } - self->full_name = create->full_name; + self->task->full_name = create->full_name; self->threadfn = threadfn; self->data = data;