[PATCH] erofs-utils: optimize pthread_cond_signal calling

Noboru Asai asai at sijam.com
Wed May 1 12:24:20 AEST 2024


Call pthread_cond_signal once per file.

Signed-off-by: Noboru Asai <asai at sijam.com>
---
 lib/compress.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/compress.c b/lib/compress.c
index 7fef698..5c25ca8 100644
--- a/lib/compress.c
+++ b/lib/compress.c
@@ -1261,8 +1261,8 @@ void z_erofs_mt_workfn(struct erofs_work *work, void *tlsp)
 out:
 	cwork->errcode = ret;
 	pthread_mutex_lock(&ictx->mutex);
-	++ictx->nfini;
-	pthread_cond_signal(&ictx->cond);
+	if (++ictx->nfini == ictx->seg_num)
+		pthread_cond_signal(&ictx->cond);
 	pthread_mutex_unlock(&ictx->mutex);
 }
 
-- 
2.44.0



More information about the Linux-erofs mailing list