summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2025-02-08 21:25:55 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2025-02-08 21:25:55 +0100
commit883af6aa527c4d0b43adc99c19e1cbb53153a7a0 (patch)
treeab4170eae8919f11855e3b8a69f13457b4fa601d
parent7ac18bc84ae7c5a5f2f255b6d5337eb085bb86cd (diff)
Add names to threads
-rw-r--r--boot/boot.c1
-rw-r--r--console-client/ncursesw.c2
-rw-r--r--console-client/pc-kbd.c2
-rw-r--r--console-client/pc-mouse.c4
-rw-r--r--console-client/timer.c2
-rw-r--r--console-client/trans.c2
-rw-r--r--console/display.c2
-rw-r--r--eth-multiplexer/multiplexer.c2
-rw-r--r--libcons/init-loop.c3
-rw-r--r--libdiskfs/init-first.c3
-rw-r--r--libdiskfs/sync-interval.c3
-rw-r--r--libirqhelp/irqhelp.c2
-rw-r--r--libmachdev/ds_routines.c3
-rw-r--r--libmachdev/trivfs_server.c3
-rw-r--r--libnetfs/init-loop.c3
-rw-r--r--libpager/demuxer.c2
-rw-r--r--lwip/port/netif/hurdethif.c2
-rw-r--r--mach-defpager/default_pager.c2
-rw-r--r--nfs/cache.c2
-rw-r--r--nfs/rpc.c5
-rw-r--r--nfsd/loop.c2
-rw-r--r--pfinet/ethernet.c2
-rw-r--r--pfinet/sched.c3
-rw-r--r--pfinet/timer-emul.c3
-rw-r--r--pflocal/sserver.c2
-rw-r--r--proc/msg.c10
-rw-r--r--proc/stubs.c2
-rw-r--r--rumpdisk/main.c2
-rw-r--r--term/hurdio.c4
-rw-r--r--tmpfs/tmpfs.c3
-rw-r--r--trans/random.c2
-rw-r--r--utils/fakeauth.c3
32 files changed, 83 insertions, 5 deletions
diff --git a/boot/boot.c b/boot/boot.c
index d773bd1f..6ba0a736 100644
--- a/boot/boot.c
+++ b/boot/boot.c
@@ -778,6 +778,7 @@ main (int argc, char **argv, char **envp)
void * __attribute__ ((noreturn))
msg_thread (void *arg)
{
+ pthread_setname_np (pthread_self (), "msg");
while (1)
mach_msg_server (boot_demuxer, 0, receive_set);
}
diff --git a/console-client/ncursesw.c b/console-client/ncursesw.c
index 8e8962fd..ce62660c 100644
--- a/console-client/ncursesw.c
+++ b/console-client/ncursesw.c
@@ -293,6 +293,8 @@ input_loop (void *unused)
fd_set rfds;
int w_escaped = 0;
+ pthread_setname_np (pthread_self (), "input");
+
FD_ZERO (&rfds);
FD_SET (fd, &rfds);
diff --git a/console-client/pc-kbd.c b/console-client/pc-kbd.c
index 9e03cff8..a637205f 100644
--- a/console-client/pc-kbd.c
+++ b/console-client/pc-kbd.c
@@ -785,6 +785,8 @@ read_keycode (void)
static void *
input_loop (void *unused)
{
+ pthread_setname_np (pthread_self (), "kbd_input");
+
#ifdef XKB_SUPPORT
/* XXX: until conversion from scancode to keycode is properly implemented
XKB won't work on anything but scancode set 1.
diff --git a/console-client/pc-mouse.c b/console-client/pc-mouse.c
index 40a569d0..e6e8970d 100644
--- a/console-client/pc-mouse.c
+++ b/console-client/pc-mouse.c
@@ -246,7 +246,9 @@ input_loop (void *unused)
kd_event *ev;
vm_offset_t buf;
mach_msg_type_number_t buf_size;
-
+
+ pthread_setname_np (pthread_self (), "mouse_input");
+
while (1)
{
struct mouse_event evt = { 0 };
diff --git a/console-client/timer.c b/console-client/timer.c
index 69cc643d..4abe1321 100644
--- a/console-client/timer.c
+++ b/console-client/timer.c
@@ -91,6 +91,8 @@ timer_function (void *this_is_a_pointless_variable_with_a_rather_long_name)
mach_port_t recv = mach_reply_port ();
int wait = 0;
+ pthread_setname_np (pthread_self (), "timer");
+
timer_thread = mach_thread_self ();
pthread_mutex_lock (&timer_lock);
diff --git a/console-client/trans.c b/console-client/trans.c
index b7d56cb0..afdf5acd 100644
--- a/console-client/trans.c
+++ b/console-client/trans.c
@@ -784,6 +784,8 @@ console_client_translator (void *unused)
{
error_t err;
+ pthread_setname_np (pthread_self (), "netfs");
+
do
{
ports_manage_port_operations_multithread (netfs_port_bucket,
diff --git a/console/display.c b/console/display.c
index e4e3fcae..76a0f735 100644
--- a/console/display.c
+++ b/console/display.c
@@ -471,6 +471,8 @@ service_notifications (void *arg)
struct port_bucket *notify_bucket = arg;
extern int notify_server (mach_msg_header_t *inp, mach_msg_header_t *outp);
+ pthread_setname_np (pthread_self (), "notifications");
+
for (;;)
ports_manage_port_operations_one_thread (notify_bucket,
notify_server,
diff --git a/eth-multiplexer/multiplexer.c b/eth-multiplexer/multiplexer.c
index adac2b9c..ca674b48 100644
--- a/eth-multiplexer/multiplexer.c
+++ b/eth-multiplexer/multiplexer.c
@@ -95,6 +95,8 @@ multiplexer_demuxer (mach_msg_header_t *inp,
static void *
multiplexer_thread (void *arg)
{
+ pthread_setname_np (pthread_self (), "demuxer");
+
ports_manage_port_operations_one_thread (port_bucket,
multiplexer_demuxer,
0);
diff --git a/libcons/init-loop.c b/libcons/init-loop.c
index 987754df..fbd720b0 100644
--- a/libcons/init-loop.c
+++ b/libcons/init-loop.c
@@ -19,12 +19,15 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
#include <hurd/ports.h>
+#include <pthread.h>
#include "cons.h"
void
cons_server_loop (void)
{
+ pthread_setname_np (pthread_self (), "cons_demuxer");
+
ports_manage_port_operations_one_thread (cons_port_bucket,
cons_demuxer, 0);
/* Not reached. */
diff --git a/libdiskfs/init-first.c b/libdiskfs/init-first.c
index 8f27eff8..0683552d 100644
--- a/libdiskfs/init-first.c
+++ b/libdiskfs/init-first.c
@@ -21,6 +21,7 @@
#include "priv.h"
#include <stdlib.h>
+#include <pthread.h>
#include <hurd/ports.h>
static int thread_timeout = 1000 * 60 * 2; /* two minutes */
@@ -32,6 +33,8 @@ master_thread_function (void *demuxer)
{
error_t err;
+ pthread_setname_np (pthread_self (), "diskfs");
+
do
{
ports_manage_port_operations_multithread (diskfs_port_bucket,
diff --git a/libdiskfs/sync-interval.c b/libdiskfs/sync-interval.c
index 3a09e868..a9fc0f60 100644
--- a/libdiskfs/sync-interval.c
+++ b/libdiskfs/sync-interval.c
@@ -94,6 +94,9 @@ static void *
periodic_sync (void *arg)
{
int interval = (int)(uintptr_t) arg;
+
+ pthread_setname_np (pthread_self (), "sync");
+
for (;;)
{
error_t err;
diff --git a/libirqhelp/irqhelp.c b/libirqhelp/irqhelp.c
index febf2a0c..5a563a19 100644
--- a/libirqhelp/irqhelp.c
+++ b/libirqhelp/irqhelp.c
@@ -178,6 +178,8 @@ irqhelp_server_loop(void *arg)
mach_port_t pset, psetcntl;
error_t err;
+ pthread_setname_np (pthread_self (), "irqhelp_server");
+
if (!irq)
{
log_error("cannot start this irq thread\n");
diff --git a/libmachdev/ds_routines.c b/libmachdev/ds_routines.c
index aeb7f5af..cdb820fb 100644
--- a/libmachdev/ds_routines.c
+++ b/libmachdev/ds_routines.c
@@ -62,6 +62,7 @@
#include <string.h>
#include <error.h>
#include <assert.h>
+#include <pthread.h>
#include <hurd.h>
#include <mach.h>
@@ -367,6 +368,8 @@ machdev_register (struct machdev_device_emulation_ops *ops)
void *
machdev_server(void *arg)
{
+ pthread_setname_np (pthread_self (), "machdev_server");
+
/* Launch. */
do
{
diff --git a/libmachdev/trivfs_server.c b/libmachdev/trivfs_server.c
index d2031974..2c905a63 100644
--- a/libmachdev/trivfs_server.c
+++ b/libmachdev/trivfs_server.c
@@ -26,6 +26,7 @@
#include <fcntl.h>
#include <error.h>
#include <sys/mman.h>
+#include <pthread.h>
#include <hurd/ports.h>
#include <hurd/trivfs.h>
#include <hurd/fsys.h>
@@ -554,6 +555,7 @@ machdev_trivfs_server_startup(mach_port_t bootstrap)
void *
machdev_trivfs_server_loop(void *arg)
{
+ pthread_setname_np (pthread_self (), "machdev_trivfs");
/* Launch. */
do
{
@@ -566,6 +568,7 @@ machdev_trivfs_server_loop(void *arg)
void *
machdev_trivfs_server_loop_forever(void *arg)
{
+ pthread_setname_np (pthread_self (), "machdev_trivfs");
/* Launch. */
do
{
diff --git a/libnetfs/init-loop.c b/libnetfs/init-loop.c
index c6ca5387..00f0fa46 100644
--- a/libnetfs/init-loop.c
+++ b/libnetfs/init-loop.c
@@ -19,6 +19,7 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
#include "netfs.h"
+#include <pthread.h>
static int thread_timeout = 1000 * 60 * 2; /* two minutes */
static int server_timeout = 1000 * 60 * 10; /* ten minutes */
@@ -28,6 +29,8 @@ netfs_server_loop (void)
{
error_t err;
+ pthread_setname_np (pthread_self (), "netfs");
+
do
{
ports_manage_port_operations_multithread (netfs_port_bucket,
diff --git a/libpager/demuxer.c b/libpager/demuxer.c
index dfdda104..4c406602 100644
--- a/libpager/demuxer.c
+++ b/libpager/demuxer.c
@@ -292,6 +292,8 @@ service_paging_requests (void *arg)
{
struct pager_requests *requests = arg;
+ pthread_setname_np (pthread_self (), "paging_requests");
+
int demuxer (mach_msg_header_t *inp,
mach_msg_header_t *outp)
{
diff --git a/lwip/port/netif/hurdethif.c b/lwip/port/netif/hurdethif.c
index f2103566..84eb7db7 100644
--- a/lwip/port/netif/hurdethif.c
+++ b/lwip/port/netif/hurdethif.c
@@ -544,6 +544,8 @@ hurdethif_device_init (struct netif *netif)
static void *
hurdethif_input_thread (void *arg)
{
+ pthread_setname_np (pthread_self (), "input");
+
ports_manage_port_operations_one_thread (etherport_bucket,
hurdethif_demuxer, 0);
diff --git a/mach-defpager/default_pager.c b/mach-defpager/default_pager.c
index 9a477615..e55fa642 100644
--- a/mach-defpager/default_pager.c
+++ b/mach-defpager/default_pager.c
@@ -2956,6 +2956,8 @@ default_pager_thread(void *arg)
mach_port_t pset;
kern_return_t kr;
+ pthread_setname_np (pthread_self (), "default_pager");
+
dpt = (default_pager_thread_t *) arg;
/*
diff --git a/nfs/cache.c b/nfs/cache.c
index 883cb966..a1661b80 100644
--- a/nfs/cache.c
+++ b/nfs/cache.c
@@ -106,6 +106,8 @@ void *
forked_node_delete (void *arg)
{
struct fnd *args = arg;
+
+ pthread_setname_np (pthread_self (), "node_delete");
pthread_mutex_lock (&args->dir->lock);
netfs_attempt_unlink ((struct iouser *)-1, args->dir, args->name);
diff --git a/nfs/rpc.c b/nfs/rpc.c
index 2a74094a..ebd7bd1d 100644
--- a/nfs/rpc.c
+++ b/nfs/rpc.c
@@ -36,6 +36,7 @@
#include <error.h>
#include <unistd.h>
#include <stdio.h>
+#include <pthread.h>
/* One of these exists for each pending RPC. */
struct rpc_list
@@ -354,6 +355,8 @@ timeout_service_thread (void *arg)
{
(void) arg;
+ pthread_setname_np (pthread_self (), "timeout");
+
while (1)
{
sleep (1);
@@ -374,6 +377,8 @@ rpc_receive_thread (void *arg)
(void) arg;
+ pthread_setname_np (pthread_self (), "rpc_receive");
+
/* Allocate a receive buffer. */
buf = malloc (1024 + read_size);
assert_backtrace (buf);
diff --git a/nfsd/loop.c b/nfsd/loop.c
index d94c5d10..e04446e2 100644
--- a/nfsd/loop.c
+++ b/nfsd/loop.c
@@ -56,6 +56,8 @@ server_loop (void *arg)
socklen_t addrlen;
int cc;
+ pthread_setname_np (pthread_self (), "server_loop");
+
memset (&fakec, 0, sizeof (struct cache_handle));
for (;;)
diff --git a/pfinet/ethernet.c b/pfinet/ethernet.c
index ae738de5..234e9007 100644
--- a/pfinet/ethernet.c
+++ b/pfinet/ethernet.c
@@ -102,6 +102,8 @@ static struct port_bucket *etherport_bucket;
static void *
ethernet_thread (void *arg)
{
+ pthread_setname_np (pthread_self (), "ethernet");
+
ports_manage_port_operations_one_thread (etherport_bucket,
ethernet_demuxer,
0);
diff --git a/pfinet/sched.c b/pfinet/sched.c
index af03ab49..5a3dd3ed 100644
--- a/pfinet/sched.c
+++ b/pfinet/sched.c
@@ -19,6 +19,7 @@
#include "pfinet.h"
+#include <pthread.h>
#include <asm/system.h>
#include <linux/sched.h>
#include <linux/interrupt.h>
@@ -59,6 +60,8 @@ sock_wake_async (struct socket *sock, int how)
void *
net_bh_worker (void *arg)
{
+ pthread_setname_np (pthread_self (), "net_bh");
+
pthread_mutex_lock (&net_bh_lock);
while (1)
{
diff --git a/pfinet/timer-emul.c b/pfinet/timer-emul.c
index f1686741..701a4164 100644
--- a/pfinet/timer-emul.c
+++ b/pfinet/timer-emul.c
@@ -26,6 +26,7 @@
#include <linux/sched.h>
#include <error.h>
#include <string.h>
+#include <pthread.h>
#include "pfinet.h"
long long root_jiffies;
@@ -40,6 +41,8 @@ timer_function (void *this_is_a_pointless_variable_with_a_rather_long_name)
mach_port_t recv;
int wait = 0;
+ pthread_setname_np (pthread_self (), "timer");
+
recv = mach_reply_port ();
timer_thread = mach_thread_self ();
diff --git a/pflocal/sserver.c b/pflocal/sserver.c
index 55d2d188..9ea7c970 100644
--- a/pflocal/sserver.c
+++ b/pflocal/sserver.c
@@ -60,6 +60,8 @@ sock_demuxer (mach_msg_header_t *inp, mach_msg_header_t *outp)
static void *
handle_sock_requests (void *unused)
{
+ pthread_setname_np (pthread_self (), "sock_requests");
+
while (ports_count_bucket (sock_port_bucket) > 0)
{
ports_enable_bucket (sock_port_bucket);
diff --git a/proc/msg.c b/proc/msg.c
index 93ad995b..200c92c7 100644
--- a/proc/msg.c
+++ b/proc/msg.c
@@ -35,11 +35,13 @@ check_message_return (struct proc *p, void *availpaddr)
}
}
-/* Register ourselves with statup. */
+/* Register ourselves with startup. */
static void *
-tickle_statup (void *statupport)
+tickle_startup (void *startupport)
{
- startup_essential_task ((mach_port_t) (uintptr_t) statupport,
+ pthread_setname_np (pthread_self (), "startup");
+
+ startup_essential_task ((mach_port_t) (uintptr_t) startupport,
mach_task_self (), MACH_PORT_NULL,
"proc", _hurd_host_priv);
return NULL;
@@ -70,7 +72,7 @@ S_proc_setmsgport (struct proc *p,
the essential task RPC; spawn a thread to do it. */
pthread_t thread;
error_t err;
- err = pthread_create (&thread, NULL, tickle_statup,
+ err = pthread_create (&thread, NULL, tickle_startup,
(void*) (uintptr_t) msgport);
if (!err)
pthread_detach (thread);
diff --git a/proc/stubs.c b/proc/stubs.c
index 0b4a2cea..318dc0ba 100644
--- a/proc/stubs.c
+++ b/proc/stubs.c
@@ -47,6 +47,8 @@ blocking_message_send (void *arg)
struct msg_sig_post_request *const req = arg;
error_t err;
+ pthread_setname_np (pthread_self (), "message_send");
+
err = mach_msg (&req->head, MACH_SEND_MSG, sizeof *req, 0,
MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
diff --git a/rumpdisk/main.c b/rumpdisk/main.c
index 0de01312..3676b472 100644
--- a/rumpdisk/main.c
+++ b/rumpdisk/main.c
@@ -117,6 +117,8 @@ static int rumpdisk_demuxer (mach_msg_header_t *inp, mach_msg_header_t *outp)
static void *
rumpdisk_multithread_server(void *arg)
{
+ pthread_setname_np (pthread_self (), "server");
+
do
{
ports_manage_port_operations_multithread (machdev_device_bucket,
diff --git a/term/hurdio.c b/term/hurdio.c
index eab59b72..acabe122 100644
--- a/term/hurdio.c
+++ b/term/hurdio.c
@@ -200,6 +200,8 @@ hurdio_reader_loop (void *arg)
mach_msg_type_number_t datalen;
error_t err;
+ pthread_setname_np (pthread_self (), "reader");
+
pthread_mutex_lock (&global_lock);
reader_thread = mach_thread_self ();
@@ -254,6 +256,8 @@ hurdio_writer_loop (void *arg)
int npending_output_copy;
mach_port_t ioport_copy;
+ pthread_setname_np (pthread_self (), "writer");
+
pthread_mutex_lock (&global_lock);
writer_thread = mach_thread_self ();
diff --git a/tmpfs/tmpfs.c b/tmpfs/tmpfs.c
index d28806a3..08356803 100644
--- a/tmpfs/tmpfs.c
+++ b/tmpfs/tmpfs.c
@@ -22,6 +22,7 @@
#include <string.h>
#include <inttypes.h>
#include <error.h>
+#include <pthread.h>
#include "tmpfs.h"
#include <limits.h>
@@ -297,6 +298,8 @@ diskfs_thread_function (void *demuxer)
static int thread_timeout = 1000 * 60 * 2; /* two minutes */
error_t err;
+ pthread_setname_np (pthread_self (), "diskfs");
+
do
{
ports_manage_port_operations_multithread (diskfs_port_bucket,
diff --git a/trans/random.c b/trans/random.c
index 7e3d3eba..5142cb15 100644
--- a/trans/random.c
+++ b/trans/random.c
@@ -248,6 +248,8 @@ gather_vm_cache_statistics (void)
static void *
gather_thread (void *args)
{
+ pthread_setname_np (pthread_self (), "gather");
+
while (1)
{
gather_slab_info ();
diff --git a/utils/fakeauth.c b/utils/fakeauth.c
index cd4ad565..7180bb3c 100644
--- a/utils/fakeauth.c
+++ b/utils/fakeauth.c
@@ -26,6 +26,7 @@
#include <assert-backtrace.h>
#include <argp.h>
#include <error.h>
+#include <pthread.h>
#include "auth_S.h"
#include "auth_request_U.h"
#include "interrupt_S.h"
@@ -320,6 +321,8 @@ auth_demuxer (mach_msg_header_t *inp, mach_msg_header_t *outp)
static void *
handle_auth_requests (void *ignored)
{
+ pthread_setname_np (pthread_self (), "auth");
+
while (1)
ports_manage_port_operations_multithread (auth_bucket, auth_demuxer,
30 * 1000, 0, 0);