[PATCH] erofs-utils: optimize pthread_cond_signal calling

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


Call pthread_cond_signal once per file.

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

diff --git a/lib/compress.c b/lib/compress.c
index 7fef698..29307a1 100644
--- a/lib/compress.c
+++ b/lib/compress.c
@@ -1261,8 +1261,9 @@ 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