public inbox for linux-riscv@lists.infradead.org
 help / color / mirror / Atom feed
From: Jinjie Ruan <ruanjinjie@huawei.com>
To: David Laight <david.laight.linux@gmail.com>,
	Yury Norov <ynorov@nvidia.com>
Cc: <pjw@kernel.org>, <palmer@dabbelt.com>, <aou@eecs.berkeley.edu>,
	<alex@ghiti.fr>, <yury.norov@gmail.com>,
	<linux@rasmusvillemoes.dk>, <arnd@arndb.de>,
	<akpm@linux-foundation.org>, <linux-riscv@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>, <linux-arch@vger.kernel.org>,
	<nathan@kernel.org>
Subject: Re: [PATCH v3 0/2] arch/riscv: Add bitrev.h file to support rev8 and brev8
Date: Mon, 20 Apr 2026 20:31:01 +0800	[thread overview]
Message-ID: <08481a75-c294-4558-93d5-00a013f07010@huawei.com> (raw)
In-Reply-To: <20260417194259.0c48d7ef@pumpkin>



On 4/18/2026 2:42 AM, David Laight wrote:
> On Fri, 17 Apr 2026 12:09:03 -0400
> Yury Norov <ynorov@nvidia.com> wrote:
> 
>> On Fri, Apr 17, 2026 at 05:31:00PM +0800, Jinjie Ruan wrote:
>>> Add bitrev.h file to support rev8 and brev8 for riscv.
>>>
>>> Tested functionally on riscv64 QEMU with:
>>> 	"-M virt,acpi=on,zbkb=true,zbb=true"
>>>
>>> Changes in v3:
>>> - Fix the build issue by remving the CONFIG_HAVE_ARCH_BITREVERSE macro
>>>   for byte_rev_table.  
>>
>> No arch needs byte_rev_table, except risc-v under a very certain
>> configuration. Please find a better approach that wouldn't bloat
>> random victims' .data section.
> 
> Eh?
> x86 doesn't have a bit-reverse instruction.
> The only arch that 'select HAVE_ARCH_BITREVERSE' are arm64, arm32 (some cpu),
> loongarch and mips (for CPU_MIPSR6).
> 
> I think you mean that no arch that sets CONFIG_HAVE_ARCH_BITREVERSE needs it
> except riscv.
> 
> Could you globally have:
> 	select NEED_BYTE_REV_TABLE if !HAVE_ARCH_BITREVERSE
> and then riscv could also select it?

Thanks, David. I will follow your suggestion to introduce a
NEED_BYTE_REVERSE_TABLE Kconfig option.

This way, byte_rev_table is only compiled when !HAVE_ARCH_BITREVERSE or
when an architecture (like RISC-V) explicitly selects it as a fallback.
This avoids bloating the .data section for architectures that have full
hardware bit-reverse support and don't need the table."

> (And isn't there a method of including files in the build based on
> kconfig options rather than unconditionally compiling it and getting cpp
> to throw the contents away?)

> 
> 	David
> 
>>
>>> - Update the riscv implementation as David suggested.
>>> - Add Reviwed-by.
>>>
>>> Changes in v2:
>>> - Define generic __bitrev8/16/32 for reuse in riscv.
>>>
>>> Jinjie Ruan (2):
>>>   bitops: Define generic __bitrev8/16/32 for reuse
>>>   arch/riscv: Add bitrev.h file to support rev8 and brev8
>>>
>>>  arch/riscv/Kconfig                    |  1 +
>>>  arch/riscv/include/asm/bitrev.h       | 55 +++++++++++++++++++++++++++
>>>  include/asm-generic/bitops/__bitrev.h | 22 +++++++++++
>>>  include/linux/bitrev.h                | 20 ++--------
>>>  lib/bitrev.c                          |  3 --
>>>  5 files changed, 82 insertions(+), 19 deletions(-)
>>>  create mode 100644 arch/riscv/include/asm/bitrev.h
>>>  create mode 100644 include/asm-generic/bitops/__bitrev.h
>>>
>>> -- 
>>> 2.34.1  
> 


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

      reply	other threads:[~2026-04-20 12:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-17  9:31 [PATCH v3 0/2] arch/riscv: Add bitrev.h file to support rev8 and brev8 Jinjie Ruan
2026-04-17  9:31 ` [PATCH v3 1/2] bitops: Define generic __bitrev8/16/32 for reuse Jinjie Ruan
2026-04-17  9:31 ` [PATCH v3 2/2] arch/riscv: Add bitrev.h file to support rev8 and brev8 Jinjie Ruan
2026-04-17 13:17   ` David Laight
2026-04-17 16:09 ` [PATCH v3 0/2] " Yury Norov
2026-04-17 18:42   ` David Laight
2026-04-20 12:31     ` Jinjie Ruan [this message]

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=08481a75-c294-4558-93d5-00a013f07010@huawei.com \
    --to=ruanjinjie@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=alex@ghiti.fr \
    --cc=aou@eecs.berkeley.edu \
    --cc=arnd@arndb.de \
    --cc=david.laight.linux@gmail.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=nathan@kernel.org \
    --cc=palmer@dabbelt.com \
    --cc=pjw@kernel.org \
    --cc=ynorov@nvidia.com \
    --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