From: Bhupesh <bhupesh@igalia.com>
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,
linux-trace-kernel@vger.kernel.org
Subject: [PATCH v4 0/3] Add support for long task name
Date: Wed, 21 May 2025 11:53:34 +0530 [thread overview]
Message-ID: <20250521062337.53262-1-bhupesh@igalia.com> (raw)
Changes since v3:
================
- v3 can be seen here: https://lore.kernel.org/lkml/20250507110444.963779-1-bhupesh@igalia.com/
- As suggested by Petr and Steven, used 'comm_ext' name instead of
'real_comm'. Correspondingly the macro name is changed to 'TASK_COMM_EXT_LEN'
for the 64-byte extended comm.
- Rebased this patchset on linux-next/master, which contain the following patch from
Steven now:
155fd6c3e2f0 ("tracing/sched: Use __string() instead of fixed lengths for task->comm")
- Accordingly, v4 drops the changes done for 'trace/sched' events in v3,
but retains the 'safe' memcpy' changes for other kernel trace users.
Changes since v2:
================
- v2 can be seen here: https://lore.kernel.org/lkml/20250331121820.455916-1-bhupesh@igalia.com/
- As suggested by Yafang and Kees, picked Linus' suggested approach for
this version (see: <https://lore.kernel.org/all/CAHk-=wjAmmHUg6vho1KjzQi2=psR30+CogFd4aXrThr2gsiS4g@mail.gmail.com/>).
- Dropped kthreads patch from this version. It would be sent out
separately, if we have a consensus on this approach.
Changes since v1:
================
- v1 can be seen here: https://lore.kernel.org/lkml/20250314052715.610377-1-bhupesh@igalia.com/
- As suggested by Kees, added [PATCH 3/3] to have a consistent
'full_name' entry inside 'task_struct' which both tasks and
kthreads can use.
- Fixed the commit message to indicate that the existing ABI
'/proc/$pid/task/$tid/comm' remains untouched and a parallel
'/proc/$pid/task/$tid/full_name' ABI for new (interested) users.
While working with user-space debugging tools which work especially
on linux gaming platforms, I found that the task name is truncated due
to the limitation of TASK_COMM_LEN.
Now, during debug tracing, seeing truncated names is not very useful,
especially on gaming platforms where the number of tasks running can
be very high.
This patchset does not touch 'TASK_COMM_LEN' at all, i.e.
'TASK_COMM_LEN' and the 16-byte design remains untouched.
Via this patchset, as Linus suggested, we can add the
following union inside 'task_struct':
union {
char comm[TASK_COMM_LEN];
char comm_ext[TASK_COMM_EXT_LEN];
};
and then modify '__set_task_comm()' to pass 'tsk->comm_ext'
to the existing users.
So, eventually:
- users who want the existing 'TASK_COMM_LEN' behavior will get it
(existing ABIs would continue to work),
- users who just print out 'tsk->comm' as a string will get the longer
new "extended comm",
- users who do 'sizeof(->comm)' will continue to get the old value
because of the union.
After this change, gdb is able to show full name of the task, using a
simple app which generates threads with long names [see 1]:
# gdb ./threadnames -ex "run info thread" -ex "detach" -ex "quit" > log
# cat log
NameThatIsTooLongForComm[4662]
[1]. https://github.com/lostgoat/tasknames
Bhupesh (3):
exec: Remove obsolete comments
treewide: Switch memcpy() users of 'task->comm' to a more safer
implementation
exec: Add support for 64 byte 'tsk->comm_ext'
fs/exec.c | 6 +++---
include/linux/coredump.h | 3 ++-
include/linux/sched.h | 14 ++++++++------
include/trace/events/block.h | 5 +++++
include/trace/events/oom.h | 1 +
include/trace/events/osnoise.h | 1 +
include/trace/events/signal.h | 1 +
include/trace/events/task.h | 2 ++
8 files changed, 23 insertions(+), 10 deletions(-)
--
2.38.1
next reply other threads:[~2025-05-21 6:23 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-21 6:23 Bhupesh [this message]
2025-05-21 6:23 ` [PATCH v4 1/3] exec: Remove obsolete comments Bhupesh
2025-05-22 6:18 ` Yafang Shao
2025-05-21 6:23 ` [PATCH v4 2/3] treewide: Switch memcpy() users of 'task->comm' to a more safer implementation Bhupesh
2025-05-22 6:15 ` Yafang Shao
2025-05-22 6:27 ` Yafang Shao
2025-05-22 19:44 ` Bhupesh Sharma
2025-05-21 6:23 ` [PATCH v4 3/3] exec: Add support for 64 byte 'tsk->comm_ext' Bhupesh
2025-05-23 3:48 ` Kees Cook
2025-05-23 12:31 ` Bhupesh Sharma
2025-05-23 20:55 ` Kees Cook
2025-05-26 11:13 ` Bhupesh Sharma
2025-06-30 7:58 ` Bhupesh Sharma
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250521062337.53262-1-bhupesh@igalia.com \
--to=bhupesh@igalia.com \
--cc=akpm@linux-foundation.org \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii.nakryiko@gmail.com \
--cc=arnaldo.melo@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=brauner@kernel.org \
--cc=bsegall@google.com \
--cc=david@redhat.com \
--cc=ebiederm@xmission.com \
--cc=jack@suse.cz \
--cc=juri.lelli@redhat.com \
--cc=keescook@chromium.org \
--cc=kernel-dev@igalia.com \
--cc=laoar.shao@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=mathieu.desnoyers@efficios.com \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=mirq-linux@rere.qmqm.pl \
--cc=oliver.sang@intel.com \
--cc=peterz@infradead.org \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=viro@zeniv.linux.org.uk \
--cc=vschneid@redhat.com \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox