[PATCH v2 0/6] sched: Add support for long task name

André Almeida posted 6 patches 7 hours ago
drivers/connector/cn_proc.c                        |  2 +-
drivers/dma-buf/sw_sync.c                          |  2 +-
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_fence.c   |  2 +-
drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c |  2 +-
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c            |  2 +-
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c    |  2 +-
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c             |  4 +--
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c       |  2 +-
drivers/gpu/drm/lima/lima_ctx.c                    |  2 +-
drivers/gpu/drm/panfrost/panfrost_gem.c            |  2 +-
drivers/gpu/drm/panthor/panthor_gem.c              |  2 +-
drivers/gpu/drm/panthor/panthor_sched.c            |  2 +-
drivers/gpu/drm/virtio/virtgpu_ioctl.c             |  2 +-
drivers/hwtracing/stm/core.c                       |  2 +-
drivers/tty/tty_audit.c                            |  2 +-
fs/binfmt_elf.c                                    |  2 +-
fs/binfmt_elf_fdpic.c                              |  2 +-
fs/proc/array.c                                    |  2 +-
include/linux/coredump.h                           |  2 +-
include/linux/sched.h                              | 24 ++-------------
include/linux/tracepoint.h                         |  4 +--
include/trace/events/block.h                       | 10 +++---
include/trace/events/coredump.h                    |  2 +-
include/trace/events/f2fs.h                        |  4 +--
include/trace/events/oom.h                         |  2 +-
include/trace/events/osnoise.h                     |  2 +-
include/trace/events/sched.h                       | 10 +++---
include/trace/events/signal.h                      |  2 +-
include/trace/events/task.h                        |  4 +--
include/uapi/linux/prctl.h                         |  3 ++
kernel/audit.c                                     |  6 ++--
kernel/auditsc.c                                   |  6 ++--
kernel/printk/nbcon.c                              |  2 +-
kernel/printk/printk.c                             |  4 +--
kernel/sys.c                                       | 23 +++++++++++---
net/bluetooth/hci_sock.c                           |  2 +-
net/netfilter/nf_tables_api.c                      |  4 ++-
security/integrity/integrity_audit.c               |  3 +-
security/ipe/audit.c                               |  3 +-
security/landlock/domain.c                         |  2 +-
security/lsm_audit.c                               |  7 +++--
tools/testing/selftests/prctl/set-process-name.c   | 36 ++++++++++++++++++++++
42 files changed, 124 insertions(+), 81 deletions(-)
[PATCH v2 0/6] sched: Add support for long task name
Posted by André Almeida 7 hours ago
* Use case

When debugging and tracing complex programs with hundreds of threads, 16
long thread names are not enough anymore. cmd_line can show a lot of
characters, but it's not affected by pthread_setname_np() or
prctl(PR_SET_NAME), so let's give the same love kthreads got with commit
6b59808bfe48 ("workqueue: Show the latest workqueue name in 
/proc/PID/{comm,stat,status}"). This work creates a new
PR_{SET,GET}_EXT_NAME that supports 64 byte long names.

* Patchset

Patch 1 is just a minor comment update.

Patch 2 and 3 do some prep work in order to avoid buffer overflows around
the kernel, now that current->comm is bigger. It also make sure that if
the destination buffer is smaller than TASK_COMM_EXT_LEN, it will
be NUL-terminated.

Patch 4 sets current->comm length to TASK_COMM_EXT_LEN and take care of
making sure that current userspace APIs gets only TASK_COMM_LEN.

Patch 5 creates new prctl() to set and get all the TASK_COMM_EXT_LEN bytes.

Patch 6 adapts the existing selftest for this new interface.

* Testing

selftests/prctl/set-process-name.c survives this patchset, and it was extended
to the new interface. Care was taken to make sure the old interfaces still
return 16 bytes, to avoid buffer overflow.

This patchset also survived some basic trace-cmd tests, but any advise or
how to stress even more all those string copies is very welcomed.

* Changes

Since v1:
 - Replace new strtostr() with strscpy()
 - Don't replace memcpy in tools/
 - Link to v1: https://patch.msgid.link/20260517-tonyk-long_name-v1-0-3c282eaa91e2@igalia.com

Since Bhupesh's v8:
 - Truncate userspace return to 16 bytes for old interfaces (PR_GET_NAME,
   /proc/PID/comm/)
 - Replace __cstr_array_copy() with new strtostr()
 - Add new interface prctl(PR_{SET,GET}_EXT_NAME)
 - Adapt selftest to this patchset
 - https://lore.kernel.org/lkml/20250821102152.323367-1-bhupesh@igalia.com/

---
André Almeida (6):
      sched: Update get_task_comm() comment
      treewide: Get rid of get_task_comm()
      treewide: Replace memcpy(..., current->comm) with strscpy()
      sched: Extend task command name to 64 bytes
      prctl: Add support for long user thread names
      selftests: prctl: Add test for long thread names

 drivers/connector/cn_proc.c                        |  2 +-
 drivers/dma-buf/sw_sync.c                          |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_fence.c   |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c            |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c    |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c             |  4 +--
 drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c       |  2 +-
 drivers/gpu/drm/lima/lima_ctx.c                    |  2 +-
 drivers/gpu/drm/panfrost/panfrost_gem.c            |  2 +-
 drivers/gpu/drm/panthor/panthor_gem.c              |  2 +-
 drivers/gpu/drm/panthor/panthor_sched.c            |  2 +-
 drivers/gpu/drm/virtio/virtgpu_ioctl.c             |  2 +-
 drivers/hwtracing/stm/core.c                       |  2 +-
 drivers/tty/tty_audit.c                            |  2 +-
 fs/binfmt_elf.c                                    |  2 +-
 fs/binfmt_elf_fdpic.c                              |  2 +-
 fs/proc/array.c                                    |  2 +-
 include/linux/coredump.h                           |  2 +-
 include/linux/sched.h                              | 24 ++-------------
 include/linux/tracepoint.h                         |  4 +--
 include/trace/events/block.h                       | 10 +++---
 include/trace/events/coredump.h                    |  2 +-
 include/trace/events/f2fs.h                        |  4 +--
 include/trace/events/oom.h                         |  2 +-
 include/trace/events/osnoise.h                     |  2 +-
 include/trace/events/sched.h                       | 10 +++---
 include/trace/events/signal.h                      |  2 +-
 include/trace/events/task.h                        |  4 +--
 include/uapi/linux/prctl.h                         |  3 ++
 kernel/audit.c                                     |  6 ++--
 kernel/auditsc.c                                   |  6 ++--
 kernel/printk/nbcon.c                              |  2 +-
 kernel/printk/printk.c                             |  4 +--
 kernel/sys.c                                       | 23 +++++++++++---
 net/bluetooth/hci_sock.c                           |  2 +-
 net/netfilter/nf_tables_api.c                      |  4 ++-
 security/integrity/integrity_audit.c               |  3 +-
 security/ipe/audit.c                               |  3 +-
 security/landlock/domain.c                         |  2 +-
 security/lsm_audit.c                               |  7 +++--
 tools/testing/selftests/prctl/set-process-name.c   | 36 ++++++++++++++++++++++
 42 files changed, 124 insertions(+), 81 deletions(-)
---
base-commit: 5d6919055dec134de3c40167a490f33c74c12581
change-id: 20260516-tonyk-long_name-b9f345aeb041

Best regards,
--  
André Almeida <andrealmeid@igalia.com>