Linux-EROFS Archive mirror
 help / color / mirror / Atom feed
* [PATCH] erofs-utils: optimize pthread_cond_signal calling
@ 2024-05-01  2:16 Noboru Asai
  0 siblings, 0 replies; 3+ messages in thread
From: Noboru Asai @ 2024-05-01  2:16 UTC (permalink / raw
  To: hsiangkao; +Cc: linux-erofs

Call pthread_cond_signal once per file.

Signed-off-by: Noboru Asai <asai@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


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

* [PATCH] erofs-utils: optimize pthread_cond_signal calling
@ 2024-05-01  2:24 Noboru Asai
  2024-05-01  4:32 ` Gao Xiang
  0 siblings, 1 reply; 3+ messages in thread
From: Noboru Asai @ 2024-05-01  2:24 UTC (permalink / raw
  To: hsiangkao; +Cc: linux-erofs

Call pthread_cond_signal once per file.

Signed-off-by: Noboru Asai <asai@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


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

* Re: [PATCH] erofs-utils: optimize pthread_cond_signal calling
  2024-05-01  2:24 Noboru Asai
@ 2024-05-01  4:32 ` Gao Xiang
  0 siblings, 0 replies; 3+ messages in thread
From: Gao Xiang @ 2024-05-01  4:32 UTC (permalink / raw
  To: Noboru Asai; +Cc: linux-erofs



On 2024/5/1 10:24, Noboru Asai wrote:
> Call pthread_cond_signal once per file.
> 
> Signed-off-by: Noboru Asai <asai@sijam.com>

Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>

Thanks,
Gao Xiang

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

end of thread, other threads:[~2024-05-01  4:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-01  2:16 [PATCH] erofs-utils: optimize pthread_cond_signal calling Noboru Asai
  -- strict thread matches above, loose matches on Subject: below --
2024-05-01  2:24 Noboru Asai
2024-05-01  4:32 ` Gao Xiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).