Project

General

Profile

Bug #8158

Want named threads API

Added by Alexander Pyhalov over 2 years ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
kernel
Start date:
2017-05-05
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
needs-triage

Description

Linux/BSDs and Solaris 11.3 provide pthread_setname_np() /pthread_getname_np() .
Some applications, for example, firefox, rely on this functionality.

http://man7.org/linux/man-pages/man3/pthread_setname_np.3.html
https://blogs.oracle.com/observatory/entry/named_threads .

History

#1

Updated by Jason King over 2 years ago

  • Assignee set to Jason King
  • Category set to kernel

It seems likely we'd want to present the thread names via /proc which would make it easy for existing utilities such as ps(1) or prstat(1m) to be able to see the thread names. It also seems useful to have the names included in any process core dumps for post-mortem debugging, though it'd be good to do it in a way that doesn't prevent any analysis of core files that predate this support.

How to implement setting the names (and where they are stored) is still under discussion.

Also need to investigate what way would be easiest if we want to be able to use it with dtrace.

For some datapoints,

Linux (or more precisely glibc on Linux) does this by (pseudo-code):

 if tid == self
    prctl(PR_SET_NAME, name)
else
   write(/proc/self/pid/tid/comm, name)

(Get follows a similar logic)

Freebsd uses a syscall to set the name.

Also worth noting, per the linux manpage, it silently discards characters longer than the max (16 characters) while fbsd will

#2

Updated by John Levon over 1 year ago

  • Assignee changed from Jason King to John Levon
#3

Updated by Electric Monk about 1 year ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100

git commit ab618543cc6fc4bc273c077ef5d247961cdb29d4

commit  ab618543cc6fc4bc273c077ef5d247961cdb29d4
Author: John Levon <john.levon@joyent.com>
Date:   2018-10-19T20:40:54.000Z

    8158 Want named threads API
    9857 proc manpages should have LIBRARY section
    Reviewed by: Andy Fiddaman <andy@omniosce.org>
    Reviewed by: Gordon Ross <gwr@nexenta.com>
    Approved by: Dan McDonald <danmcd@joyent.com>

Also available in: Atom PDF