From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-110.freemail.mail.aliyun.com (out30-110.freemail.mail.aliyun.com [115.124.30.110]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 636B039D6E9 for ; Fri, 10 Apr 2026 11:36:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.110 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775821016; cv=none; b=qw1tX4543184TKB44XeOKjeoqbLwuqlS9zpdfjUOe1bjwOwQ+Gq/rOY40500Z5Jc5es/1uY3Q3We+j9ZfS1E6UCx2P0RvvR0AgZADodmmG641MOR23j8Pi6/cTS68I+nsyALi6uVsO2n6dUFY6HuwRHXEORGmSyM8gofG9YxUgk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775821016; c=relaxed/simple; bh=3Cnlm5srbNoVb/O2/CtPP+M2xvIGy7mu/NKH5jrS7Ww=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uNKXmJQOwTF2aylRn+PlCVKP+U98DR129IiSuBL6KluxLzGBpk5TE5CZLiQ6ruMpyDf1hivZTf2CNZRbpD9kyF6H83yLLRZT1vKR/E1cD+J96bzPXvLSMq7RwDfUCp1heOB/nnDaGEqO7Lz3xjlTH/2FB4hjH5RFpiMnZ+viJOg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=C3cwMTWS; arc=none smtp.client-ip=115.124.30.110 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="C3cwMTWS" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1775821010; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=i14BS7GrqYV7Zzk+pfr2uQL5MKpn/DMYLWddS0YiJzY=; b=C3cwMTWSzw8h0qVOc9UyijEv+xqr/K4NoDd2qLqzXRzlWSGEH9f1uu+/YxgQ6tYp5YouKGr/93rcYKEjs+e6DlaoI9KuMjnovHhRuy/qWZmlXAORKMItvhQA6j7UFSrqEQtKPnvKBJ/s0BdKrAjliBDFgS6c5tV3THIgXkKuec8= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R191e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037026112;MF=cp0613@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0X0l8ghE_1775821001; Received: from DESKTOP-S9E58SO.localdomain(mailfrom:cp0613@linux.alibaba.com fp:SMTPD_---0X0l8ghE_1775821001 cluster:ay36) by smtp.aliyun-inc.com; Fri, 10 Apr 2026 19:36:50 +0800 From: cp0613@linux.alibaba.com To: ruanjinjie@huawei.com Cc: akpm@linux-foundation.org, alex@ghiti.fr, aou@eecs.berkeley.edu, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, palmer@dabbelt.com, pjw@kernel.org Subject: Re: [PATCH] arch/riscv: Add bitrev.h file to support rev8 and brev8 Date: Fri, 10 Apr 2026 19:36:40 +0800 Message-ID: <20260410113640.106730-1-cp0613@linux.alibaba.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260311071344.3305640-1-ruanjinjie@huawei.com> References: <20260311071344.3305640-1-ruanjinjie@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Wed, 11 Mar 2026 15:13:44 +0800, ruanjinjie@huawei.com wrote: > +#include > +#include > +#include > + > +extern u8 const byte_rev_table[256]; > +static __always_inline __attribute_const__ u32 __arch_bitrev32(u32 x) > +{ > + if (IS_ENABLED(CONFIG_RISCV_ISA_ZBKB) && > + riscv_has_extension_likely(RISCV_ISA_EXT_ZBKB)) { > + unsigned long result = x; > + > + asm volatile( > + ".option push\n" > + ".option arch,+zbkb\n" > + "rev8 %0, %0\n" > + "brev8 %0, %0\n" > + ".option pop" > + : "+r" (result) > + ); > + > + if (__riscv_xlen == 64) > + return (u32)(result >> 32); > + > + return (u32)result; > + } > + > + return (u32)byte_rev_table[x & 0xff] << 24 | > + (u32)byte_rev_table[(x >> 8) & 0xff] << 16 | > + (u32)byte_rev_table[(x >> 16) & 0xff] << 8 | > + (u32)byte_rev_table[x >> 24]; > +} Hi Jinjie, Thanks for your patch. I have two suggestions. 1. When ZBKB is not supported, is it simpler to directly use the generic implementation __bitrev32 in . 2. Could you please provide a benchmark test case to illustrate the performance comparison with and without this extension (refer to test_bitops.c) and also provide the results by bloat-o-meter. Thanks, Pei