From: Oleg Nesterov <oleg@redhat.com>
To: Andrea Calabrese <andrea.calabrese@amarulasolutions.com>
Cc: brauner@kernel.org, akpm@linux-foundation.org,
peterz@infradead.org, tglx@kernel.org, kexinsun@smail.nju.edu.cn,
adrianhuang0701@gmail.com, elver@google.com,
linux-kernel@vger.kernel.org, linux-amarula@amarulasolutions.com
Subject: Re: [PATCH v2] kernel: refactor: shorten has_pending_signals
Date: Thu, 21 May 2026 14:50:37 +0200 [thread overview]
Message-ID: <ag7_nc_CN3Bt6Urz@redhat.com> (raw)
In-Reply-To: <20260520062849.183621-2-andrea.calabrese@amarulasolutions.com>
On 05/20, Andrea Calabrese wrote:
>
> static inline bool has_pending_signals(sigset_t *signal, sigset_t *blocked)
> {
> - unsigned long ready;
> - long i;
> -
> - switch (_NSIG_WORDS) {
> - default:
> - for (i = _NSIG_WORDS, ready = 0; --i >= 0 ;)
> - ready |= signal->sig[i] &~ blocked->sig[i];
> - break;
> -
> - case 4: ready = signal->sig[3] &~ blocked->sig[3];
> - ready |= signal->sig[2] &~ blocked->sig[2];
> - ready |= signal->sig[1] &~ blocked->sig[1];
> - ready |= signal->sig[0] &~ blocked->sig[0];
> - break;
> -
> - case 2: ready = signal->sig[1] &~ blocked->sig[1];
> - ready |= signal->sig[0] &~ blocked->sig[0];
> - break;
> -
> - case 1: ready = signal->sig[0] &~ blocked->sig[0];
> - }
> - return ready != 0;
> + unsigned long ready = 0;
> + for (long i = 0; i < _NSIG_WORDS; i++)
> + ready |= signal->sig[i] & ~blocked->sig[i];
> + return ready != 0;
> }
Note that with your patch the main loop doesn't stop when ready
becomes != 0...
OK, I guess the modern compilers doesn't need this hint even if
_NSIG_WORDS > 1, so
Acked-by: Oleg Nesterov <oleg@redhat.com>
But since your patch is just a cleanup, you could do
for (int i = 0; i < _NSIG_WORDS; i++) {
if (signal->sig[i] & ~blocked->sig[i])
return true;
}
return false;
but this is subjective, I won't insist.
Oleg.
next prev parent reply other threads:[~2026-05-21 12:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-20 6:28 [PATCH v2] kernel: refactor: shorten has_pending_signals Andrea Calabrese
2026-05-21 12:50 ` Oleg Nesterov [this message]
2026-05-21 13:34 ` Andrea Calabrese
2026-05-21 14:35 ` Andrea Calabrese
2026-05-22 15:24 ` Oleg Nesterov
2026-05-22 17:24 ` Andrea Calabrese
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=ag7_nc_CN3Bt6Urz@redhat.com \
--to=oleg@redhat.com \
--cc=adrianhuang0701@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=andrea.calabrese@amarulasolutions.com \
--cc=brauner@kernel.org \
--cc=elver@google.com \
--cc=kexinsun@smail.nju.edu.cn \
--cc=linux-amarula@amarulasolutions.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@kernel.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