mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-18 16:26:54 +07:00
0c44c2d0f4
Linus suggested using asm goto to get rid of the typical SETcc + TEST instruction pair -- which also clobbers an extra register -- for our typical modify_and_test() functions. Because asm goto doesn't allow output fields it has to include an unconditinal memory clobber when it changes a memory variable to force a reload. Luckily all atomic ops already imply a compiler barrier to go along with their memory barrier semantics. Suggested-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/n/tip-0mtn9siwbeo1d33bap1422se@git.kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
42 lines
1.0 KiB
C
42 lines
1.0 KiB
C
#ifndef _ASM_X86_RMWcc
|
|
#define _ASM_X86_RMWcc
|
|
|
|
#ifdef CC_HAVE_ASM_GOTO
|
|
|
|
#define __GEN_RMWcc(fullop, var, cc, ...) \
|
|
do { \
|
|
asm volatile goto (fullop "; j" cc " %l[cc_label]" \
|
|
: : "m" (var), ## __VA_ARGS__ \
|
|
: "memory" : cc_label); \
|
|
return 0; \
|
|
cc_label: \
|
|
return 1; \
|
|
} while (0)
|
|
|
|
#define GEN_UNARY_RMWcc(op, var, arg0, cc) \
|
|
__GEN_RMWcc(op " " arg0, var, cc)
|
|
|
|
#define GEN_BINARY_RMWcc(op, var, val, arg0, cc) \
|
|
__GEN_RMWcc(op " %1, " arg0, var, cc, "er" (val))
|
|
|
|
#else /* !CC_HAVE_ASM_GOTO */
|
|
|
|
#define __GEN_RMWcc(fullop, var, cc, ...) \
|
|
do { \
|
|
char c; \
|
|
asm volatile (fullop "; set" cc " %1" \
|
|
: "+m" (var), "=qm" (c) \
|
|
: __VA_ARGS__ : "memory"); \
|
|
return c != 0; \
|
|
} while (0)
|
|
|
|
#define GEN_UNARY_RMWcc(op, var, arg0, cc) \
|
|
__GEN_RMWcc(op " " arg0, var, cc)
|
|
|
|
#define GEN_BINARY_RMWcc(op, var, val, arg0, cc) \
|
|
__GEN_RMWcc(op " %2, " arg0, var, cc, "er" (val))
|
|
|
|
#endif /* CC_HAVE_ASM_GOTO */
|
|
|
|
#endif /* _ASM_X86_RMWcc */
|