[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <361bf35ccf308d2fbce14f69f156cb42eef0f095.camel@xry111.site>
Date: Thu, 05 Sep 2024 20:09:35 +0800
From: Xi Ruoyao <xry111@...111.site>
To: Uros Bizjak <ubizjak@...il.com>, Huacai Chen <chenhuacai@...nel.org>
Cc: loongarch@...ts.linux.dev, linux-kernel@...r.kernel.org, WANG Xuerui
<kernel@...0n.name>, Thomas Gleixner <tglx@...utronix.de>
Subject: Re: [PATCH v3] LoongArch/percpu: Simplify _percpu_read() and
_percpu_write()
On Thu, 2024-09-05 at 14:02 +0200, Uros Bizjak wrote:
> > If the input value is less than 0xff, then "& 0xff" is meaningless, if
> > the input value is more than 0xff, this conversion still cannot give a
> > correct result for the caller. So I think for all sizes it is enough
> > to just use "((unsigned long) val)".
>
> This part is used to force unsigned extension, otherwise the compiler
> will use sign-extension of the possibly signed variable.
It's not relevant. For example when size is 2 __pcpu_op_##size("stx")
is expanded to stx.h, and stx.h only stores the lower 16 bits of a
register into MEM[r21 + ptr], the high bits are ignored anyway.
Thus we can just have
+#define _percpu_write(size, _pcp, _val) \
+do { \
+ if (0) { \
+ typeof(_pcp) pto_tmp__; \
+ pto_tmp__ = (_val); \
+ (void)pto_tmp__; \
+ } \
+ __asm__ __volatile__( \
+ __pcpu_op_##size("stx") "%[val], $r21, %[ptr] \n" \
+ : \
+ : [val] "r"(_val), [ptr] "r"(&(_pcp)) \
+ : "memory"); \
+} while (0)
--
Xi Ruoyao <xry111@...111.site>
School of Aerospace Science and Technology, Xidian University
Powered by blists - more mailing lists