aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Schwidefsky <schwidefsky@de.ibm.com>2015-08-20 06:57:33 -0400
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2015-10-14 08:32:06 -0400
commitacdc9fc9a8121ce2ebcd7533bd72852c20b353f3 (patch)
treeb1d501fa146502365256a02ac6aa3352ced890fa
parent5614dd920a02a524c9abc9573374d81f0535f18a (diff)
s390/bitops: implement cache friendly test_and_set_bit_lock
The generic implementation for test_and_set_bit_lock in include/asm-generic uses the standard test_and_set_bit operation. This is done with either a 'csg' or a 'loag' instruction. For both version the cache line is fetched exclusively, even if the bit is already set. The result is an increase in cache traffic, for a contented lock this is a bad idea. Acked-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
-rw-r--r--arch/s390/include/asm/bitops.h23
1 files changed, 22 insertions, 1 deletions
diff --git a/arch/s390/include/asm/bitops.h b/arch/s390/include/asm/bitops.h
index 9b68e98a724f..66a1cff67353 100644
--- a/arch/s390/include/asm/bitops.h
+++ b/arch/s390/include/asm/bitops.h
@@ -276,6 +276,28 @@ static inline int test_bit(unsigned long nr, const volatile unsigned long *ptr)
276 return (*addr >> (nr & 7)) & 1; 276 return (*addr >> (nr & 7)) & 1;
277} 277}
278 278
279static inline int test_and_set_bit_lock(unsigned long nr,
280 volatile unsigned long *ptr)
281{
282 if (test_bit(nr, ptr))
283 return 1;
284 return test_and_set_bit(nr, ptr);
285}
286
287static inline void clear_bit_unlock(unsigned long nr,
288 volatile unsigned long *ptr)
289{
290 smp_mb__before_atomic();
291 clear_bit(nr, ptr);
292}
293
294static inline void __clear_bit_unlock(unsigned long nr,
295 volatile unsigned long *ptr)
296{
297 smp_mb();
298 __clear_bit(nr, ptr);
299}
300
279/* 301/*
280 * Functions which use MSB0 bit numbering. 302 * Functions which use MSB0 bit numbering.
281 * On an s390x system the bits are numbered: 303 * On an s390x system the bits are numbered:
@@ -446,7 +468,6 @@ static inline int fls(int word)
446#include <asm-generic/bitops/ffz.h> 468#include <asm-generic/bitops/ffz.h>
447#include <asm-generic/bitops/find.h> 469#include <asm-generic/bitops/find.h>
448#include <asm-generic/bitops/hweight.h> 470#include <asm-generic/bitops/hweight.h>
449#include <asm-generic/bitops/lock.h>
450#include <asm-generic/bitops/sched.h> 471#include <asm-generic/bitops/sched.h>
451#include <asm-generic/bitops/le.h> 472#include <asm-generic/bitops/le.h>
452#include <asm-generic/bitops/ext2-atomic-setbit.h> 473#include <asm-generic/bitops/ext2-atomic-setbit.h>