After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 611911 - Set thread names on pipeline threads
Set thread names on pipeline threads
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
git master
Other All
: Normal enhancement
: 0.10.29
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2010-03-05 15:18 UTC by Alessandro Decina
Modified: 2010-04-25 18:41 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Alessandro Decina 2010-03-05 15:18:31 UTC
Some operating systems support assigning names to threads. Giving a name to a
thread can be useful for debugging.

Under linux this is supported with the prctl(PR_SET_NAME, ...) call. When you
call that, you then get a nice thread name in /proc/ and in the output of
ps.

In gst, for threads created by GstTasks, we could set the thread name based on
the GstObject name. For example, we could set the name of a thread started by a
pad task to something like GST_DEBUG_PAD_NAME(), i.e. elementname:padname. This
could be easily done by modifying GstPad and GstTask, without having to change
the elements.

For threads started by tasks, but not owned by a pad (see rtspsrc for example),
we could modify the elements to explicitly set a name on the task. In the case
of rtspsrc, we could call the task GST_OBJECT_NAME(rtspsrc):loop or something
like that.
Comment 1 David Schleef 2010-03-06 00:34:12 UTC
Sounds like something that should be in glib.
Comment 2 Alessandro Decina 2010-03-06 10:10:44 UTC
We need two things here. A cross platform API to set thread names and to actually set names on pipeline threads.

This bug is about naming pipeline threads. As for the low level API to do that, I think we could have something very simple working in gstreamer and then maybe move it to glib.
Comment 3 Stefan Sauer (gstreamer, gtkdoc dev) 2010-03-15 09:48:01 UTC

*** This bug has been marked as a duplicate of bug 580505 ***
Comment 4 Stefan Sauer (gstreamer, gtkdoc dev) 2010-03-15 09:50:22 UTC
Alessandro, where do you need to see the names? We could maybe do something like GST_FUNCPTR_NAME for GstTasks and then use that from gst-debug logging. We could name the threads by the object/pad where they are started.
Comment 5 Tim-Philipp Müller 2010-03-15 10:06:18 UTC
I don't think we want or need to wait until (a) GLib adds API for that, and (b) we can then rely on a recent-enough GLib. I think it's fine to add something linux-specific locally as a start and then use the GLib API when it gets added if it ever gets added.
Comment 6 Stefan Sauer (gstreamer, gtkdoc dev) 2010-03-15 10:34:26 UTC
Set to NEEDINFO regarding questions in comment #4.
Comment 7 Wim Taymans 2010-03-15 13:55:55 UTC
commit f9c74afe62516cad710067de9db2e1a38fb186f4
Author: Wim Taymans <wim.taymans@collabora.co.uk>
Date:   Mon Mar 15 14:48:19 2010 +0100

    task: configure the object name as thread name
    
    When we have prctl available, use it to set the configured object name as the
    thread name for better debugging.
    
    Based on patch by Robert Swain.

commit f089c3cceb3e4dee038991e6db4274cb251b4108
Author: Wim Taymans <wim.taymans@collabora.co.uk>
Date:   Mon Mar 15 13:48:30 2010 +0100

    pad: set a good name on the task of the pad
    
    Use the element:pad names to configure a good name for the pad task.
Comment 8 Wim Taymans 2010-03-15 14:18:04 UTC
Something else that can be done?
Comment 9 Benjamin Gaignard 2010-03-15 15:55:18 UTC
Could you use "if (prctl (PR_SET_NAME, (unsigned long int) thread_name,0,0,0))" instead of "if (prctl (PR_SET_NAME, (unsigned long int) thread_name))" ?
bionic/libc doesn't accept prctl without 5 arguments.
Comment 10 Tim-Philipp Müller 2010-04-25 18:41:00 UTC
(In reply to comment #9)
> Could you use "if (prctl (PR_SET_NAME, (unsigned long int) thread_name,0,0,0))"
> instead of "if (prctl (PR_SET_NAME, (unsigned long int) thread_name))" ?
> bionic/libc doesn't accept prctl without 5 arguments.

This was taken care of:

commit c78c637a771fef7236bd559a42d18d8b5fc370da
Author: Wim Taymans <wim.taymans@collabora.co.uk>
Date:   Mon Mar 15 17:07:59 2010 +0100

    task: use bionic/libc friendly arguments to prctl
    
    prctl is supposed to take 5 arguments. It used to work with 2 arguments on some
    versions of libc because it is defined as a varags function there.
    
    See #611911

Closing this bug, since we've implemented this now. Lots more can be done, but I don't think we need to keep this bug open for that, and it's probably more productive to file new bugs for specific requests (like showign the thread-name in GST_DEBUG output etc.).