Opened 5 years ago
Closed 4 years ago
#15492 closed enhancement (no change required)
pthread_setname_np support
Reported by: | cocobean | Owned by: | nobody |
---|---|---|---|
Priority: | normal | Milestone: | Unscheduled |
Component: | System/libroot.so | Version: | R1/Development |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Platform: | All |
Description
Provide kernel support of pthread_setname_np and pthread_getname_np - set/get the name of a thread.
By default, all the threads created using pthread_create() inherit the program name. The pthread_setname_np() function can be used to set a unique name for a thread, which can be useful for debugging multithreaded applications. The thread name is a meaningful C language string, whose length is restricted to 16 characters, including the terminating null byte ('\0'). The thread argument specifies the thread whose name is to be changed; name specifies the new name.
The pthread_getname_np() function can be used to retrieve the name of the thread. The thread argument specifies the thread whose name is to be retrieved. The buffer name is used to return the thread name; len specifies the number of bytes available in name. The buffer specified by name should be at least 16 characters in length. The returned thread name in the output buffer will be null terminated.
RETURN VALUE
On success, these functions return 0; on error, they return a nonzero error number.
Change History (14)
comment:1 by , 5 years ago
comment:2 by , 5 years ago
The latest mesa uses the following:
static inline void u_thread_setname( const char *name ) { #if defined(HAVE_PTHREAD) #if DETECT_OS_LINUX || DETECT_OS_CYGWIN || DETECT_OS_SOLARIS pthread_setname_np(pthread_self(), name); #elif DETECT_OS_FREEBSD || DETECT_OS_OPENBSD pthread_set_name_np(pthread_self(), name); #elif DETECT_OS_NETBSD pthread_setname_np(pthread_self(), "%s", (void *)name); #elif DETECT_OS_APPLE pthread_setname_np(name); #else #error Not sure how to call pthread_setname_np #endif #endif (void)name; }
It doesn't matter which we implement.. but at least one needs implemented :-)
comment:3 by , 5 years ago
Milestone: | Unscheduled → R1 |
---|---|
Priority: | normal → high |
Bumping to high, setting to R1 milestone since future mesa updates will depend on this.
comment:4 by , 5 years ago
I created prototype recipe for mesa 19.2.8 that builds OSMesa interface (https://github.com/haikuports/haikuports/pull/4534). I used rename_thread from OS.h for this.
comment:5 by , 5 years ago
BTW it was rejected as a standard. http://austingroupbugs.net/view.php?id=1292 Important is the maximal length to be accepted, and whether it should be truncated.
Discussion about the same API: https://www.mail-archive.com/tech-userlevel@netbsd.org/msg02368.html
Thread names are all but useless, it's hard to believe that u_thread_setname() should error for this anyway. Bumping the priority to high doesn't seem right to me.
follow-ups: 7 10 comment:6 by , 5 years ago
Milestone: | R1 |
---|---|
Priority: | high → normal |
@X512 Ah. I didn't know about that PR. Thanks for the heads up on rename_thread.
I've integrated that into my patchset I was going to upstream (i'll mention credit for that part)
Your original patchset isn't correct, you disable HGL which is pretty integral to our Mesa port. (HGL == "Haiku GL" == libGL.so)
@korli If we have a viable alternative (rename_thread) then this is indeed not a high priority. The high priority reflected us missing something which Mesa deemed important.
comment:7 by , 5 years ago
Replying to kallisti5:
Your original patchset isn't correct, you disable HGL which is pretty integral to our Mesa port. (HGL == "Haiku GL" == libGL.so)
HGL doesn't compile on latest mesa and I don't tried to fix that. I use my libGL2 instead. I actually don't see meaning in HGL for software rendering as mesa provide platform independent OSMesa interface. I uploaded patchset for reference, not for actual usage.
comment:8 by , 5 years ago
It's fixed in my PR's :-)
https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3324
comment:9 by , 5 years ago
Also for me pthread_barrier_t was not working properly (caused freeze on glFinish), so I disabled it. ELF TLS should be disabled, because Haiku don't support it (#13294). I don't see this changes in your request. I tested my patches on Blender and other OpenGL apps.
comment:10 by , 5 years ago
Replying to kallisti5:
@korli The high priority reflected us missing something which Mesa deemed important.
Thread names are probably not critical for Mesa. The same feature in LLVM isn't with an #error handled.
comment:11 by , 4 years ago
Milestone: | → Unscheduled |
---|
comment:12 by , 4 years ago
Please close this ticket. We built Mesa 20.0.8 with current patches for both x86/x86_64 platforms with no major issues.
comment:13 by , 4 years ago
Please close this ticket.
I agree. pthread_setname_np
is unofficial extension, Mesa already use OS-dependent API for this and Haiku port already has working solution.
comment:14 by , 4 years ago
Resolution: | → no change required |
---|---|
Status: | new → closed |
Closing. No disagreements here.
These are non-standard POSIX functions, and you have pasted the definitions from the Linux manpage. I'm not sure whether we want to implement these, or their BSD equivalents...