From: Andrew Cooper <andrew.cooper3@citrix.com>
To: ptesarik@suse.com
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
agordeev@linux.ibm.com, airlied@gmail.com,
akpm@linux-foundation.org, andrew+netdev@lunn.ch, arnd@arndb.de,
chris@zankel.net, davem@davemloft.net, edumazet@google.com,
fw@strlen.de, geert@linux-m68k.org, gor@linux.ibm.com,
hca@linux.ibm.com, jcmvbkbc@gmail.com, johan.hedberg@gmail.com,
joro@8bytes.org, kuba@kernel.org, linmag7@gmail.com,
linux-kernel@vger.kernel.org, linux@rasmusvillemoes.dk,
luiz.dentz@gmail.com, maarten.lankhorst@linux.intel.com,
macro@orcam.me.uk, maddy@linux.ibm.com, marcel@holtmann.org,
mattst88@gmail.com, mpe@ellerman.id.au, mripard@kernel.org,
oliver@neukum.org, pabeni@redhat.com, pablo@netfilter.org,
patrik.r.jakobsson@gmail.com, richard.henderson@linaro.org,
robin.murphy@arm.com, simona@ffwll.ch, tsbogend@alpha.franken.de,
tzimmermann@suse.de, vgupta@kernel.org, visitorckw@gmail.com,
will@kernel.org, yury.norov@gmail.com
Subject: Re: [RFC PATCH 0/2] Helper to isolate least-significant bit
Date: Fri, 9 Jan 2026 19:26:13 +0000 [thread overview]
Message-ID: <b47b02cc-642b-4a21-a932-25bca8352ae3@citrix.com> (raw)
In-Reply-To: <cover.1767975412.git.ptesarik@suse.com>
> diff --git a/arch/alpha/kernel/core_cia.c b/arch/alpha/kernel/core_cia.c
> index 6e577228e175d..b3c273c13c104 100644
> --- a/arch/alpha/kernel/core_cia.c
> +++ b/arch/alpha/kernel/core_cia.c
> @@ -1035,7 +1035,7 @@ cia_decode_ecc_error(struct el_CIA_sysdata_mcheck *cia, const char *msg)
> cia_decode_mem_error(cia, msg);
>
> syn = cia->cia_syn & 0xff;
> - if (syn == (syn & -syn)) {
> + if (syn == ffs_val(syn)) {
> fmt = KERN_CRIT " ECC syndrome %#x -- check bit %d\n";
> i = ffs(syn) - 1;
> } else {
This is a check for multiple bits set, which has a simpler expression to
calculate. (the ffs() in context shows that syn isn't expected to be 0.)
In Xen I added this helper while tiding things up, and it's applicable
to the more common pattern of checking hweight() of a bitmap against 1.
/*
* Calculate if a value has two or more bits set. Always use this in
* preference to an expression of the form 'hweight(x) > 1'.
*/
#define multiple_bits_set(x) \
({ \
typeof(x) _v = (x); \
(_v & (_v - 1)) != 0; \
})
~Andrew
next prev parent reply other threads:[~2026-01-09 19:26 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-09 16:41 Petr Tesarik
2026-01-09 16:37 ` [RFC PATCH 1/2] bits: introduce ffs_val() Petr Tesarik
2026-01-09 17:01 ` Arnd Bergmann
2026-01-09 23:54 ` David Laight
2026-01-09 17:16 ` Yury Norov
2026-01-09 17:46 ` Petr Tesarik
2026-01-09 18:26 ` Yury Norov
2026-01-09 19:27 ` Petr Tesarik
2026-01-09 19:44 ` Yury Norov
2026-01-09 18:50 ` Arnd Bergmann
2026-01-10 10:50 ` David Laight
2026-01-12 8:15 ` Thomas Zimmermann
2026-01-12 8:58 ` Petr Tesarik
2026-01-12 11:22 ` David Laight
2026-01-13 1:40 ` Maciej W. Rozycki
2026-01-09 16:37 ` [RFC PATCH 2/2] treewide, bits: use ffs_val() where it is open-coded Petr Tesarik
2026-01-09 18:19 ` Yury Norov
2026-01-09 19:32 ` Petr Tesarik
2026-01-09 20:19 ` Yury Norov
2026-01-10 10:36 ` Maciej W. Rozycki
2026-01-10 11:54 ` David Laight
2026-01-11 3:15 ` Maciej W. Rozycki
2026-01-11 10:40 ` David Laight
2026-01-11 21:22 ` Maciej W. Rozycki
2026-01-11 23:57 ` David Laight
2026-01-12 11:21 ` Maciej W. Rozycki
2026-01-12 13:23 ` David Laight
2026-01-10 16:42 ` Kuan-Wei Chiu
2026-01-10 22:23 ` David Laight
2026-01-11 14:41 ` Kuan-Wei Chiu
2026-01-11 21:22 ` Maciej W. Rozycki
2026-01-09 17:20 ` [RFC PATCH 0/2] Helper to isolate least-significant bit Kuan-Wei Chiu
2026-01-09 18:59 ` Petr Tesarik
2026-01-09 19:26 ` Andrew Cooper [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-01-09 16:37 Petr Tesarik
2026-01-09 19:11 ` Geert Uytterhoeven
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=b47b02cc-642b-4a21-a932-25bca8352ae3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=agordeev@linux.ibm.com \
--cc=airlied@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=andrew+netdev@lunn.ch \
--cc=arnd@arndb.de \
--cc=chris@zankel.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=geert@linux-m68k.org \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=jcmvbkbc@gmail.com \
--cc=johan.hedberg@gmail.com \
--cc=joro@8bytes.org \
--cc=kuba@kernel.org \
--cc=linmag7@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=luiz.dentz@gmail.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=macro@orcam.me.uk \
--cc=maddy@linux.ibm.com \
--cc=marcel@holtmann.org \
--cc=mattst88@gmail.com \
--cc=mpe@ellerman.id.au \
--cc=mripard@kernel.org \
--cc=oliver@neukum.org \
--cc=pabeni@redhat.com \
--cc=pablo@netfilter.org \
--cc=patrik.r.jakobsson@gmail.com \
--cc=ptesarik@suse.com \
--cc=richard.henderson@linaro.org \
--cc=robin.murphy@arm.com \
--cc=simona@ffwll.ch \
--cc=tsbogend@alpha.franken.de \
--cc=tzimmermann@suse.de \
--cc=vgupta@kernel.org \
--cc=visitorckw@gmail.com \
--cc=will@kernel.org \
--cc=yury.norov@gmail.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
all inboxes | Powered by JetHome®