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

Configure Feed

Select the types of activity you want to include in your feed.

mips: implement xor_unlock_is_negative_byte

Inspired by the mips test_and_change_bit(), this will surely be more
efficient than the generic one defined in filemap.c

Link: https://lkml.kernel.org/r/20231004165317.1061855-11-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
8da36b26 ea845e31

+39 -1
+25 -1
arch/mips/include/asm/bitops.h
··· 73 73 volatile unsigned long *addr); 74 74 int __mips_test_and_change_bit(unsigned long nr, 75 75 volatile unsigned long *addr); 76 - 76 + bool __mips_xor_is_negative_byte(unsigned long mask, 77 + volatile unsigned long *addr); 77 78 78 79 /* 79 80 * set_bit - Atomically set a bit in memory ··· 279 278 280 279 return res; 281 280 } 281 + 282 + static inline bool xor_unlock_is_negative_byte(unsigned long mask, 283 + volatile unsigned long *p) 284 + { 285 + unsigned long orig; 286 + bool res; 287 + 288 + smp_mb__before_atomic(); 289 + 290 + if (!kernel_uses_llsc) { 291 + res = __mips_xor_is_negative_byte(mask, p); 292 + } else { 293 + orig = __test_bit_op(*p, "%0", 294 + "xor\t%1, %0, %3", 295 + "ir"(mask)); 296 + res = (orig & BIT(7)) != 0; 297 + } 298 + 299 + smp_llsc_mb(); 300 + 301 + return res; 302 + } 303 + #define xor_unlock_is_negative_byte xor_unlock_is_negative_byte 282 304 283 305 #undef __bit_op 284 306 #undef __test_bit_op
+14
arch/mips/lib/bitops.c
··· 146 146 return res; 147 147 } 148 148 EXPORT_SYMBOL(__mips_test_and_change_bit); 149 + 150 + bool __mips_xor_is_negative_byte(unsigned long mask, 151 + volatile unsigned long *addr) 152 + { 153 + unsigned long flags; 154 + unsigned long data; 155 + 156 + raw_local_irq_save(flags); 157 + data = *addr; 158 + *addr = data ^ mask; 159 + raw_local_irq_restore(flags); 160 + 161 + return (data & BIT(7)) != 0; 162 + }