Linux-EROFS Archive mirror
 help / color / mirror / Atom feed
From: Noboru Asai <asai@sijam.com>
To: hsiangkao@linux.alibaba.com
Cc: linux-erofs@lists.ozlabs.org
Subject: [PATCH] erofs-utils: optimize pthread_cond_signal calling
Date: Wed,  1 May 2024 11:24:20 +0900	[thread overview]
Message-ID: <20240501022420.1881305-1-asai@sijam.com> (raw)

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


             reply	other threads:[~2024-05-01  2:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-01  2:24 Noboru Asai [this message]
2024-05-01  4:32 ` [PATCH] erofs-utils: optimize pthread_cond_signal calling Gao Xiang
  -- strict thread matches above, loose matches on Subject: below --
2024-05-01  2:16 Noboru Asai

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=20240501022420.1881305-1-asai@sijam.com \
    --to=asai@sijam.com \
    --cc=hsiangkao@linux.alibaba.com \
    --cc=linux-erofs@lists.ozlabs.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).