* [PATCH] LoongArch: Mark __xchg() and __cmpxchg() as __always_inline
@ 2022-10-10 11:56 Huacai Chen
2022-10-10 12:04 ` Arnd Bergmann
0 siblings, 1 reply; 2+ messages in thread
From: Huacai Chen @ 2022-10-10 11:56 UTC (permalink / raw)
To: Arnd Bergmann, Huacai Chen
Cc: loongarch, linux-arch, Xuefeng Li, Guo Ren, Xuerui Wang,
Jiaxun Yang, linux-kernel, Huacai Chen
Commit ac7c3e4ff401 ("compiler: enable CONFIG_OPTIMIZE_INLINING
forcibly") allows compiler to uninline functions marked as 'inline'.
In case of __xchg()/__cmpxchg() this would cause to reference
BUILD_BUG(), which is an error case for catching bugs and will not
happen for correct code, if __xchg()/__cmpxchg() is inlined.
This bug can be produced with CONFIG_DEBUG_SECTION_MISMATCH enabled,
and the solution is similar to below commits:
46f1619500d0225 ("MIPS: include: Mark __xchg as __always_inline"),
88356d09904bc60 ("MIPS: include: Mark __cmpxchg as __always_inline").
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
---
arch/loongarch/include/asm/cmpxchg.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/loongarch/include/asm/cmpxchg.h b/arch/loongarch/include/asm/cmpxchg.h
index ae19e33c7754..ecfa6cf79806 100644
--- a/arch/loongarch/include/asm/cmpxchg.h
+++ b/arch/loongarch/include/asm/cmpxchg.h
@@ -61,8 +61,8 @@ static inline unsigned int __xchg_small(volatile void *ptr, unsigned int val,
return (old32 & mask) >> shift;
}
-static inline unsigned long __xchg(volatile void *ptr, unsigned long x,
- int size)
+static __always_inline unsigned long
+__xchg(volatile void *ptr, unsigned long x, int size)
{
switch (size) {
case 1:
@@ -159,8 +159,8 @@ static inline unsigned int __cmpxchg_small(volatile void *ptr, unsigned int old,
return (old32 & mask) >> shift;
}
-static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
- unsigned long new, unsigned int size)
+static __always_inline unsigned long
+__cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, unsigned int size)
{
switch (size) {
case 1:
--
2.31.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] LoongArch: Mark __xchg() and __cmpxchg() as __always_inline
2022-10-10 11:56 [PATCH] LoongArch: Mark __xchg() and __cmpxchg() as __always_inline Huacai Chen
@ 2022-10-10 12:04 ` Arnd Bergmann
0 siblings, 0 replies; 2+ messages in thread
From: Arnd Bergmann @ 2022-10-10 12:04 UTC (permalink / raw)
To: Huacai Chen, Huacai Chen
Cc: loongarch, Linux-Arch, Xuefeng Li, guoren, WANG Xuerui,
Jiaxun Yang, linux-kernel
On Mon, Oct 10, 2022, at 1:56 PM, Huacai Chen wrote:
> Commit ac7c3e4ff401 ("compiler: enable CONFIG_OPTIMIZE_INLINING
> forcibly") allows compiler to uninline functions marked as 'inline'.
> In case of __xchg()/__cmpxchg() this would cause to reference
> BUILD_BUG(), which is an error case for catching bugs and will not
> happen for correct code, if __xchg()/__cmpxchg() is inlined.
>
> This bug can be produced with CONFIG_DEBUG_SECTION_MISMATCH enabled,
> and the solution is similar to below commits:
> 46f1619500d0225 ("MIPS: include: Mark __xchg as __always_inline"),
> 88356d09904bc60 ("MIPS: include: Mark __cmpxchg as __always_inline").
>
> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Looks good to me,
Acked-by: Arnd Bergmann <arnd@arndb.de>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-10-10 12:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-10 11:56 [PATCH] LoongArch: Mark __xchg() and __cmpxchg() as __always_inline Huacai Chen
2022-10-10 12:04 ` Arnd Bergmann
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®