]> www.infradead.org Git - users/willy/pagecache.git/commitdiff
riscv: Implement xor_unlock_is_negative_byte
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Thu, 20 Jul 2023 03:10:28 +0000 (23:10 -0400)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Wed, 4 Oct 2023 01:18:59 +0000 (21:18 -0400)
Inspired by the riscv clear_bit_unlock(), this will surely be
more efficient than the generic one defined in filemap.c.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
arch/riscv/include/asm/bitops.h

index 3540b690944bee8d5309a3d43346e3ecea47c361..15e3044298a2723ba1578d6ef68b1d17e1acf9d9 100644 (file)
@@ -191,6 +191,19 @@ static inline void __clear_bit_unlock(
        clear_bit_unlock(nr, addr);
 }
 
+static inline bool xor_unlock_is_negative_byte(unsigned long mask,
+               volatile unsigned long *addr)
+{
+       unsigned long res;
+       __asm__ __volatile__ (
+               __AMO(xor) ".rl %0, %2, %1"
+               : "=r" (res), "+A" (*addr)
+               : "r" (__NOP(mask))
+               : "memory");
+       return (res & BIT(7)) != 0;
+}
+#define xor_unlock_is_negative_byte xor_unlock_is_negative_byte
+
 #undef __test_and_op_bit
 #undef __op_bit
 #undef __NOP