Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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/20231004165317.1061855-13-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Andreas Dilger <adilger.kernel@dilger.ca>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Matthew Wilcox (Oracle) and committed by
Andrew Morton
2a667285 51a752c2

+13
+13
arch/riscv/include/asm/bitops.h
··· 191 191 clear_bit_unlock(nr, addr); 192 192 } 193 193 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 + 194 207 #undef __test_and_op_bit 195 208 #undef __op_bit 196 209 #undef __NOP