mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nam Cao <namcao@linutronix.de>
To: Jisheng Zhang <jszhang@kernel.org>
Cc: Paul Walmsley <pjw@kernel.org>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	Alexandre Ghiti <alex@ghiti.fr>,
	linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] riscv: word-at-a-time: improve find_zero() for !RISCV_ISA_ZBB
Date: Thu, 03 Sep 2026 11:35:25 +0200	[thread overview]
Message-ID: <87a4py65k2.fsf@yellow.woof> (raw)
In-Reply-To: <apZVwzxBD8Ih493W@xhacker>

Jisheng Zhang <jszhang@kernel.org> writes:

> On Thu, Aug 20, 2026 at 10:31:49AM +0200, Nam Cao wrote:
>> Jisheng Zhang <jszhang@kernel.org> writes:
>> > +#if !(defined(CONFIG_RISCV_ISA_ZBB) && defined(CONFIG_TOOLCHAIN_HAS_ZBB))
>> > +#include <asm-generic/word-at-a-time.h>
>> > +#else
>> 
>> Instead of this #if, would it be better to do
>> 
>> static inline unsigned long find_zero(unsigned long mask)
>> {
>>         if (IS_ENABLED(CONFIG_RISCV_ISA_ZBB) && IS_ENABLED(CONFIG_TOOLCHAIN_HAS_ZBB) &&
>> 	    riscv_has_extension_likely(RISCV_ISA_EXT_ZBB))
>> 		return !mask ? 0 : ((__fls(mask) + 1) >> 3);
>> 
>> 	return count_masked_bytes(mask);
>> }
>> 
>> and let compiler's dead code elimination does its job?
>
> This is impossible because the generic word-at-a-time.h implements
> the generic find_zero() itself, so there will be compile error.

Don't include word-at-a-time.h then? It compiles fine for me (obviously
count_masked_bytes() from PATCH 2/3 needs to be added first).

Nam

  reply	other threads:[~2026-09-03  9:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-13 12:24 [PATCH 0/3] riscv: word-at-a-time: improve find_zero() Jisheng Zhang
2026-01-13 12:24 ` [PATCH 1/3] riscv: word-at-a-time: improve find_zero() for !RISCV_ISA_ZBB Jisheng Zhang
2026-08-20  8:31   ` Nam Cao
2026-09-01  4:34     ` Jisheng Zhang
2026-09-03  9:35       ` Nam Cao [this message]
2026-01-13 12:24 ` [PATCH 2/3] riscv: word-at-a-time: improve find_zero() without Zbb Jisheng Zhang
2026-01-13 12:24 ` [PATCH 3/3] riscv: word-at-a-time: improve find_zero() for Zbb Jisheng Zhang
2026-08-17 15:18 ` [PATCH 0/3] riscv: word-at-a-time: improve find_zero() Jisheng Zhang

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=87a4py65k2.fsf@yellow.woof \
    --to=namcao@linutronix.de \
    --cc=alex@ghiti.fr \
    --cc=aou@eecs.berkeley.edu \
    --cc=jszhang@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=pjw@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

all inboxes | Powered by JetHome®