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

x86/qspinlock: Fix compile error

With a compiler that has asm-goto but not asm-cc-output and
CONFIG_PROFILE_ALL_BRANCHES=y we get a compiler error:

arch/x86/include/asm/rmwcc.h:23:17: error: jump into statement expression

Fix this by writing the if() as a boolean multiplication instead.

Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Deacon <will.deacon@arm.com>
Cc: linux-kernel@vger.kernel.org
Fixes: 7aa54be29765 ("locking/qspinlock, x86: Provide liveness guarantee")
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Peter Zijlstra and committed by
Ingo Molnar
b987ffc1 5b744981

+8 -5
+8 -5
arch/x86/include/asm/qspinlock.h
··· 13 13 #define queued_fetch_set_pending_acquire queued_fetch_set_pending_acquire 14 14 static __always_inline u32 queued_fetch_set_pending_acquire(struct qspinlock *lock) 15 15 { 16 - u32 val = 0; 16 + u32 val; 17 17 18 - if (GEN_BINARY_RMWcc(LOCK_PREFIX "btsl", lock->val.counter, c, 19 - "I", _Q_PENDING_OFFSET)) 20 - val |= _Q_PENDING_VAL; 21 - 18 + /* 19 + * We can't use GEN_BINARY_RMWcc() inside an if() stmt because asm goto 20 + * and CONFIG_PROFILE_ALL_BRANCHES=y results in a label inside a 21 + * statement expression, which GCC doesn't like. 22 + */ 23 + val = GEN_BINARY_RMWcc(LOCK_PREFIX "btsl", lock->val.counter, c, 24 + "I", _Q_PENDING_OFFSET) * _Q_PENDING_VAL; 22 25 val |= atomic_read(&lock->val) & ~_Q_PENDING_MASK; 23 26 24 27 return val;