public inbox for linux-erofs@ozlabs.org
 help / color / mirror / Atom feed
* [PATCH] erofs-utils: lib: name worker threads erofs_compress
@ 2026-03-16 15:13 Nithurshen
  2026-03-16 16:49 ` Gao Xiang
  0 siblings, 1 reply; 11+ messages in thread
From: Nithurshen @ 2026-03-16 15:13 UTC (permalink / raw)
  To: linux-erofs; +Cc: xiang, hsiangkao, Nithurshen

Set a specific thread name for the multi-threaded workqueue workers
to make debugging, profiling, and process monitoring significantly
easier.

Previously, worker threads inherited the name of the parent process
(e.g., mkfs.erofs), making it difficult to distinguish them from the
main thread in tools like \`top\`, \`htop\`, or \`ps\`.

This utilizes \`prctl(PR_SET_NAME)\` on Linux and \`pthread_setname_np\`
on macOS to explicitly label these threads as \"erofs_compress\" upon
initialization.

Signed-off-by: Nithurshen <nithurshen.dev@gmail.com>
---
 lib/workqueue.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/lib/workqueue.c b/lib/workqueue.c
index 18ee0f9..860e403 100644
--- a/lib/workqueue.c
+++ b/lib/workqueue.c
@@ -2,6 +2,9 @@
 #include <pthread.h>
 #include <stdlib.h>
 #include "erofs/workqueue.h"
+#if defined(__linux__)
+#include <sys/prctl.h>
+#endif
 
 static void *worker_thread(void *arg)
 {
@@ -9,6 +12,12 @@ static void *worker_thread(void *arg)
 	struct erofs_work *work;
 	void *tlsp = NULL;
 
+#if defined(__linux__)
+	prctl(PR_SET_NAME, "erofs_compress");
+#elif defined(__APPLE__)
+	pthread_setname_np("erofs_compress");
+#endif
+
 	if (wq->on_start)
 		tlsp = (wq->on_start)(wq, NULL);
 
-- 
2.51.0



^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2026-03-16 18:01 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-16 15:13 [PATCH] erofs-utils: lib: name worker threads erofs_compress Nithurshen
2026-03-16 16:49 ` Gao Xiang
2026-03-16 16:54   ` [PATCH v2] " Nithurshen
2026-03-16 17:00     ` Gao Xiang
2026-03-16 17:02   ` [PATCH v3] " Nithurshen
2026-03-16 17:05     ` Gao Xiang
2026-03-16 17:11   ` [PATCH] " Nithurshen Karthikeyan
2026-03-16 17:15     ` Gao Xiang
2026-03-16 17:25   ` [PATCH v4] erofs-utils: lib: name worker threads erofscompressor Nithurshen
2026-03-16 17:58     ` Gao Xiang
2026-03-16 18:01   ` [PATCH v5] " Nithurshen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox