Skip to content

Commit 2a66728

Browse files
Matthew Wilcox (Oracle)akpm00
authored andcommitted
riscv: implement xor_unlock_is_negative_byte
Inspired by the riscv clear_bit_unlock(), this will surely be more efficient than the generic one defined in filemap.c. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Cc: Albert Ou <[email protected]> Cc: Alexander Gordeev <[email protected]> Cc: Andreas Dilger <[email protected]> Cc: Christian Borntraeger <[email protected]> Cc: Christophe Leroy <[email protected]> Cc: Geert Uytterhoeven <[email protected]> Cc: Heiko Carstens <[email protected]> Cc: Ivan Kokshaysky <[email protected]> Cc: Matt Turner <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Nicholas Piggin <[email protected]> Cc: Palmer Dabbelt <[email protected]> Cc: Paul Walmsley <[email protected]> Cc: Richard Henderson <[email protected]> Cc: Sven Schnelle <[email protected]> Cc: "Theodore Ts'o" <[email protected]> Cc: Thomas Bogendoerfer <[email protected]> Cc: Vasily Gorbik <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 51a752c commit 2a66728

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

arch/riscv/include/asm/bitops.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,19 @@ static inline void __clear_bit_unlock(
191191
clear_bit_unlock(nr, addr);
192192
}
193193

194+
static inline bool xor_unlock_is_negative_byte(unsigned long mask,
195+
volatile unsigned long *addr)
196+
{
197+
unsigned long res;
198+
__asm__ __volatile__ (
199+
__AMO(xor) ".rl %0, %2, %1"
200+
: "=r" (res), "+A" (*addr)
201+
: "r" (__NOP(mask))
202+
: "memory");
203+
return (res & BIT(7)) != 0;
204+
}
205+
#define xor_unlock_is_negative_byte xor_unlock_is_negative_byte
206+
194207
#undef __test_and_op_bit
195208
#undef __op_bit
196209
#undef __NOP

0 commit comments

Comments
 (0)