public inbox for linux-erofs@ozlabs.org
 help / color / mirror / Atom feed
From: Nithurshen <nithurshen.dev@gmail.com>
To: linux-erofs@lists.ozlabs.org
Cc: xiang@kernel.org, hsiangkao@linux.alibaba.com,
	Nithurshen <nithurshen.dev@gmail.com>
Subject: [PATCH v3] erofs-utils: lib: name worker threads erofs_compress
Date: Mon, 16 Mar 2026 22:32:33 +0530	[thread overview]
Message-ID: <20260316170233.30662-1-nithurshen.dev@gmail.com> (raw)
In-Reply-To: <6edda81f-5d2e-49d0-9b31-181e3fdf0b18@linux.alibaba.com>

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_compressor" upon
initialization in the workqueue's .on_start() callback.

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

diff --git a/lib/compress.c b/lib/compress.c
index 4a0d890..66b3b8b 100644
--- a/lib/compress.c
+++ b/lib/compress.c
@@ -26,6 +26,9 @@
 #include "liberofs_compress.h"
 #include "liberofs_fragments.h"
 #include "liberofs_metabox.h"
+#if defined(__linux__)
+#include <sys/prctl.h>
+#endif
 
 #define Z_EROFS_DESTBUF_SZ	(Z_EROFS_PCLUSTER_MAX_SIZE + EROFS_MAX_BLOCK_SIZE * 2)
 
@@ -1427,6 +1430,12 @@ void *z_erofs_mt_wq_tls_alloc(struct erofs_workqueue *wq, void *ptr)
 {
 	struct erofs_compress_wq_tls *tls;
 
+#if defined(__linux__)
+	prctl(PR_SET_NAME, "erofs_compress");
+#elif defined(__APPLE__)
+	pthread_setname_np("erofs_compress");
+#endif
+
 	tls = calloc(1, sizeof(*tls));
 	if (!tls)
 		return NULL;
-- 
2.51.0



  parent reply	other threads:[~2026-03-16 17:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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   ` Nithurshen [this message]
2026-03-16 17:05     ` [PATCH v3] " 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260316170233.30662-1-nithurshen.dev@gmail.com \
    --to=nithurshen.dev@gmail.com \
    --cc=hsiangkao@linux.alibaba.com \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=xiang@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox