The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Mateusz Guzik <mjguzik@gmail.com>
Cc: oleg@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] signal: avoid clearing TIF_SIGPENDING in recalc_sigpending() if unset
Date: Mon, 3 Mar 2025 14:24:25 -0800	[thread overview]
Message-ID: <20250303142425.bf8668d1875aa47e0dadf6d6@linux-foundation.org> (raw)
In-Reply-To: <20250303134908.423242-1-mjguzik@gmail.com>

On Mon,  3 Mar 2025 14:49:08 +0100 Mateusz Guzik <mjguzik@gmail.com> wrote:

> Clearing is an atomic op and the flag is not set most of the time.
> 
> When creating and destroying threads in the same process with the
> pthread family, the primary bottleneck is calls to sigprocmask which
> take the process-wide sighand lock.
> 
> Avoiding the atomic gives me a 2% bump in start/teardown rate at 24-core
> scale.
> 

Neat.  Perhaps add an unlikely() also?

--- a/kernel/signal.c~signal-avoid-clearing-tif_sigpending-in-recalc_sigpending-if-unset-fix
+++ a/kernel/signal.c
@@ -177,7 +177,7 @@ static bool recalc_sigpending_tsk(struct
 void recalc_sigpending(void)
 {
 	if (!recalc_sigpending_tsk(current) && !freezing(current)) {
-		if (test_thread_flag(TIF_SIGPENDING))
+		if (unlikely(test_thread_flag(TIF_SIGPENDING)))
 			clear_thread_flag(TIF_SIGPENDING);
 	}
 }
_


  parent reply	other threads:[~2025-03-03 22:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-03 13:49 [PATCH] signal: avoid clearing TIF_SIGPENDING in recalc_sigpending() if unset Mateusz Guzik
2025-03-03 16:52 ` Oleg Nesterov
2025-03-03 22:24 ` Andrew Morton [this message]
2025-03-03 22:36   ` Mateusz Guzik

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=20250303142425.bf8668d1875aa47e0dadf6d6@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mjguzik@gmail.com \
    --cc=oleg@redhat.com \
    /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