[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250325121624.523258-7-guoren@kernel.org>
Date: Tue, 25 Mar 2025 08:15:47 -0400
From: guoren@...nel.org
To: arnd@...db.de,
gregkh@...uxfoundation.org,
torvalds@...ux-foundation.org,
paul.walmsley@...ive.com,
palmer@...belt.com,
anup@...infault.org,
atishp@...shpatra.org,
oleg@...hat.com,
kees@...nel.org,
tglx@...utronix.de,
will@...nel.org,
mark.rutland@....com,
brauner@...nel.org,
akpm@...ux-foundation.org,
rostedt@...dmis.org,
edumazet@...gle.com,
unicorn_wang@...look.com,
inochiama@...look.com,
gaohan@...as.ac.cn,
shihua@...as.ac.cn,
jiawei@...as.ac.cn,
wuwei2016@...as.ac.cn,
drew@...7.com,
prabhakar.mahadev-lad.rj@...renesas.com,
ctsai390@...estech.com,
wefu@...hat.com,
kuba@...nel.org,
pabeni@...hat.com,
josef@...icpanda.com,
dsterba@...e.com,
mingo@...hat.com,
peterz@...radead.org,
boqun.feng@...il.com,
guoren@...nel.org,
xiao.w.wang@...el.com,
qingfang.deng@...lower.com.cn,
leobras@...hat.com,
jszhang@...nel.org,
conor.dooley@...rochip.com,
samuel.holland@...ive.com,
yongxuan.wang@...ive.com,
luxu.kernel@...edance.com,
david@...hat.com,
ruanjinjie@...wei.com,
cuiyunhui@...edance.com,
wangkefeng.wang@...wei.com,
qiaozhe@...as.ac.cn
Cc: ardb@...nel.org,
ast@...nel.org,
linux-kernel@...r.kernel.org,
linux-riscv@...ts.infradead.org,
kvm@...r.kernel.org,
kvm-riscv@...ts.infradead.org,
linux-mm@...ck.org,
linux-crypto@...r.kernel.org,
bpf@...r.kernel.org,
linux-input@...r.kernel.org,
linux-perf-users@...r.kernel.org,
linux-serial@...r.kernel.org,
linux-fsdevel@...r.kernel.org,
linux-arch@...r.kernel.org,
maple-tree@...ts.infradead.org,
linux-trace-kernel@...r.kernel.org,
netdev@...r.kernel.org,
linux-atm-general@...ts.sourceforge.net,
linux-btrfs@...r.kernel.org,
netfilter-devel@...r.kernel.org,
coreteam@...filter.org,
linux-nfs@...r.kernel.org,
linux-sctp@...r.kernel.org,
linux-usb@...r.kernel.org,
linux-media@...r.kernel.org
Subject: [RFC PATCH V3 06/43] rv64ilp32_abi: riscv: csum: Utilize 64-bit width to improve the performance
From: "Guo Ren (Alibaba DAMO Academy)" <guoren@...nel.org>
The RV64ILP32 ABI, derived from a 64-bit ISA, uses 32-bit
BITS_PER_LONG. Therefore, checksum algorithm could utilize 64-bit
width to improve the performance.
Signed-off-by: Guo Ren (Alibaba DAMO Academy) <guoren@...nel.org>
---
arch/riscv/lib/csum.c | 48 +++++++++++++++++++++----------------------
1 file changed, 24 insertions(+), 24 deletions(-)
diff --git a/arch/riscv/lib/csum.c b/arch/riscv/lib/csum.c
index 7fb12c59e571..7139ab855349 100644
--- a/arch/riscv/lib/csum.c
+++ b/arch/riscv/lib/csum.c
@@ -22,17 +22,17 @@ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
__u32 len, __u8 proto, __wsum csum)
{
unsigned int ulen, uproto;
- unsigned long sum = (__force unsigned long)csum;
+ xlen_t sum = (__force xlen_t)csum;
- sum += (__force unsigned long)saddr->s6_addr32[0];
- sum += (__force unsigned long)saddr->s6_addr32[1];
- sum += (__force unsigned long)saddr->s6_addr32[2];
- sum += (__force unsigned long)saddr->s6_addr32[3];
+ sum += (__force xlen_t)saddr->s6_addr32[0];
+ sum += (__force xlen_t)saddr->s6_addr32[1];
+ sum += (__force xlen_t)saddr->s6_addr32[2];
+ sum += (__force xlen_t)saddr->s6_addr32[3];
- sum += (__force unsigned long)daddr->s6_addr32[0];
- sum += (__force unsigned long)daddr->s6_addr32[1];
- sum += (__force unsigned long)daddr->s6_addr32[2];
- sum += (__force unsigned long)daddr->s6_addr32[3];
+ sum += (__force xlen_t)daddr->s6_addr32[0];
+ sum += (__force xlen_t)daddr->s6_addr32[1];
+ sum += (__force xlen_t)daddr->s6_addr32[2];
+ sum += (__force xlen_t)daddr->s6_addr32[3];
ulen = (__force unsigned int)htonl((unsigned int)len);
sum += ulen;
@@ -46,7 +46,7 @@ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
*/
if (IS_ENABLED(CONFIG_RISCV_ISA_ZBB) &&
IS_ENABLED(CONFIG_RISCV_ALTERNATIVE)) {
- unsigned long fold_temp;
+ xlen_t fold_temp;
/*
* Zbb is likely available when the kernel is compiled with Zbb
@@ -85,12 +85,12 @@ EXPORT_SYMBOL(csum_ipv6_magic);
#define OFFSET_MASK 7
#endif
-static inline __no_sanitize_address unsigned long
-do_csum_common(const unsigned long *ptr, const unsigned long *end,
- unsigned long data)
+static inline __no_sanitize_address xlen_t
+do_csum_common(const xlen_t *ptr, const xlen_t *end,
+ xlen_t data)
{
unsigned int shift;
- unsigned long csum = 0, carry = 0;
+ xlen_t csum = 0, carry = 0;
/*
* Do 32-bit reads on RV32 and 64-bit reads otherwise. This should be
@@ -130,8 +130,8 @@ static inline __no_sanitize_address unsigned int
do_csum_with_alignment(const unsigned char *buff, int len)
{
unsigned int offset, shift;
- unsigned long csum, data;
- const unsigned long *ptr, *end;
+ xlen_t csum, data;
+ const xlen_t *ptr, *end;
/*
* Align address to closest word (double word on rv64) that comes before
@@ -140,7 +140,7 @@ do_csum_with_alignment(const unsigned char *buff, int len)
*/
offset = (unsigned long)buff & OFFSET_MASK;
kasan_check_read(buff, len);
- ptr = (const unsigned long *)(buff - offset);
+ ptr = (const xlen_t *)(buff - offset);
/*
* Clear the most significant bytes that were over-read if buff was not
@@ -153,7 +153,7 @@ do_csum_with_alignment(const unsigned char *buff, int len)
#else
data = (data << shift) >> shift;
#endif
- end = (const unsigned long *)(buff + len);
+ end = (const xlen_t *)(buff + len);
csum = do_csum_common(ptr, end, data);
#ifdef CC_HAS_ASM_GOTO_TIED_OUTPUT
@@ -163,7 +163,7 @@ do_csum_with_alignment(const unsigned char *buff, int len)
*/
if (IS_ENABLED(CONFIG_RISCV_ISA_ZBB) &&
IS_ENABLED(CONFIG_RISCV_ALTERNATIVE)) {
- unsigned long fold_temp;
+ xlen_t fold_temp;
/*
* Zbb is likely available when the kernel is compiled with Zbb
@@ -233,15 +233,15 @@ do_csum_with_alignment(const unsigned char *buff, int len)
static inline __no_sanitize_address unsigned int
do_csum_no_alignment(const unsigned char *buff, int len)
{
- unsigned long csum, data;
- const unsigned long *ptr, *end;
+ xlen_t csum, data;
+ const xlen_t *ptr, *end;
- ptr = (const unsigned long *)(buff);
+ ptr = (const xlen_t *)(buff);
data = *(ptr++);
kasan_check_read(buff, len);
- end = (const unsigned long *)(buff + len);
+ end = (const xlen_t *)(buff + len);
csum = do_csum_common(ptr, end, data);
/*
@@ -250,7 +250,7 @@ do_csum_no_alignment(const unsigned char *buff, int len)
*/
if (IS_ENABLED(CONFIG_RISCV_ISA_ZBB) &&
IS_ENABLED(CONFIG_RISCV_ALTERNATIVE)) {
- unsigned long fold_temp;
+ xlen_t fold_temp;
/*
* Zbb is likely available when the kernel is compiled with Zbb
--
2.40.1
Powered by blists - more mailing lists