[PATCH] erofs-utils: lib: name worker threads erofs_compress
Gao Xiang
hsiangkao at linux.alibaba.com
Tue Mar 17 03:49:33 AEDT 2026
On 2026/3/16 23:13, Nithurshen wrote:
> 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\`.
Please just use `top`, `htop`, or `ps` here.
>
> This utilizes \`prctl(PR_SET_NAME)\` on Linux and \`pthread_setname_np\`
> on macOS to explicitly label these threads as \"erofs_compress\" upon
> initialization.
Why not just calling erofs_compressor, since those worker are really
compressor.
>
> Signed-off-by: Nithurshen <nithurshen.dev at 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
I don't think they should be added here, you could
add in .on_start() of lib/compress.c instead.
Thanks,
Gao Xiang
> +
> if (wq->on_start)
> tlsp = (wq->on_start)(wq, NULL);
>
More information about the Linux-erofs
mailing list