public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [tip:locking/core 6/10] arch/x86/include/asm/rmwcc.h:23:17: error: jump into statement expression
@ 2018-10-20  3:05 kbuild test robot
  2018-10-22 10:08 ` Peter Zijlstra
  0 siblings, 1 reply; 3+ messages in thread
From: kbuild test robot @ 2018-10-20  3:05 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: kbuild-all, linux-kernel, tipbuild, Ingo Molnar, Will Deacon

[-- Attachment #1: Type: text/plain, Size: 14636 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git locking/core
head:   01a14bda11add9dcd4a59200f13834d634559935
commit: 7aa54be2976550f17c11a1c3e3630002dea39303 [6/10] locking/qspinlock, x86: Provide liveness guarantee
config: x86_64-randconfig-u0-10201040 (attached as .config)
compiler: gcc-5 (Debian 5.5.0-3) 5.4.1 20171010
reproduce:
        git checkout 7aa54be2976550f17c11a1c3e3630002dea39303
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

   In file included from arch/x86/include/asm/atomic.h:5:0,
                    from include/linux/atomic.h:7,
                    from include/linux/crypto.h:20,
                    from arch/x86/kernel/asm-offsets.c:9:
   arch/x86/include/asm/qspinlock.h: In function 'queued_fetch_set_pending_acquire':
>> arch/x86/include/asm/rmwcc.h:23:17: error: jump into statement expression
       : clobbers : cc_label);    \
                    ^
   include/linux/compiler.h:58:42: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                             ^
   arch/x86/include/asm/qspinlock.h:18:2: note: in expansion of macro 'if'
     if (GEN_BINARY_RMWcc(LOCK_PREFIX "btsl", lock->val.counter, c,
     ^
   arch/x86/include/asm/rmwcc.h:21:2: note: in expansion of macro 'asm_volatile_goto'
     asm_volatile_goto (fullop "; j" #cc " %l[cc_label]"  \
     ^
   arch/x86/include/asm/rmwcc.h:54:2: note: in expansion of macro '__GEN_RMWcc'
     __GEN_RMWcc(op " %[val], " arg0, var, cc,   \
     ^
   arch/x86/include/asm/rmwcc.h:58:2: note: in expansion of macro 'GEN_BINARY_RMWcc_6'
     GEN_BINARY_RMWcc_6(op, var, cc, vcon, val, "%[var]")
     ^
   arch/x86/include/asm/rmwcc.h:9:30: note: in expansion of macro 'GEN_BINARY_RMWcc_5'
    #define __RMWcc_CONCAT(a, b) a ## b
                                 ^
   arch/x86/include/asm/rmwcc.h:10:28: note: in expansion of macro '__RMWcc_CONCAT'
    #define RMWcc_CONCAT(a, b) __RMWcc_CONCAT(a, b)
                               ^
   arch/x86/include/asm/rmwcc.h:60:32: note: in expansion of macro 'RMWcc_CONCAT'
    #define GEN_BINARY_RMWcc(X...) RMWcc_CONCAT(GEN_BINARY_RMWcc_, RMWcc_ARGS(X))(X)
                                   ^
   arch/x86/include/asm/qspinlock.h:18:6: note: in expansion of macro 'GEN_BINARY_RMWcc'
     if (GEN_BINARY_RMWcc(LOCK_PREFIX "btsl", lock->val.counter, c,
         ^
   arch/x86/include/asm/rmwcc.h:25:1: note: label 'cc_label' defined here
    cc_label: c = true;      \
    ^
   include/linux/compiler.h:58:30: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                 ^
   arch/x86/include/asm/qspinlock.h:18:2: note: in expansion of macro 'if'
     if (GEN_BINARY_RMWcc(LOCK_PREFIX "btsl", lock->val.counter, c,
     ^
   arch/x86/include/asm/rmwcc.h:54:2: note: in expansion of macro '__GEN_RMWcc'
     __GEN_RMWcc(op " %[val], " arg0, var, cc,   \
     ^
   arch/x86/include/asm/rmwcc.h:58:2: note: in expansion of macro 'GEN_BINARY_RMWcc_6'
     GEN_BINARY_RMWcc_6(op, var, cc, vcon, val, "%[var]")
     ^
   arch/x86/include/asm/rmwcc.h:9:30: note: in expansion of macro 'GEN_BINARY_RMWcc_5'
    #define __RMWcc_CONCAT(a, b) a ## b
                                 ^
   arch/x86/include/asm/rmwcc.h:10:28: note: in expansion of macro '__RMWcc_CONCAT'
    #define RMWcc_CONCAT(a, b) __RMWcc_CONCAT(a, b)
                               ^
   arch/x86/include/asm/rmwcc.h:60:32: note: in expansion of macro 'RMWcc_CONCAT'
    #define GEN_BINARY_RMWcc(X...) RMWcc_CONCAT(GEN_BINARY_RMWcc_, RMWcc_ARGS(X))(X)
                                   ^
   arch/x86/include/asm/qspinlock.h:18:6: note: in expansion of macro 'GEN_BINARY_RMWcc'
     if (GEN_BINARY_RMWcc(LOCK_PREFIX "btsl", lock->val.counter, c,
         ^
>> arch/x86/include/asm/rmwcc.h:25:1: error: duplicate label 'cc_label'
    cc_label: c = true;      \
    ^
   include/linux/compiler.h:58:42: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                             ^
   arch/x86/include/asm/qspinlock.h:18:2: note: in expansion of macro 'if'
     if (GEN_BINARY_RMWcc(LOCK_PREFIX "btsl", lock->val.counter, c,
     ^
   arch/x86/include/asm/rmwcc.h:54:2: note: in expansion of macro '__GEN_RMWcc'
     __GEN_RMWcc(op " %[val], " arg0, var, cc,   \
     ^
   arch/x86/include/asm/rmwcc.h:58:2: note: in expansion of macro 'GEN_BINARY_RMWcc_6'
     GEN_BINARY_RMWcc_6(op, var, cc, vcon, val, "%[var]")
     ^
   arch/x86/include/asm/rmwcc.h:9:30: note: in expansion of macro 'GEN_BINARY_RMWcc_5'
    #define __RMWcc_CONCAT(a, b) a ## b
                                 ^
   arch/x86/include/asm/rmwcc.h:10:28: note: in expansion of macro '__RMWcc_CONCAT'
    #define RMWcc_CONCAT(a, b) __RMWcc_CONCAT(a, b)
                               ^
   arch/x86/include/asm/rmwcc.h:60:32: note: in expansion of macro 'RMWcc_CONCAT'
    #define GEN_BINARY_RMWcc(X...) RMWcc_CONCAT(GEN_BINARY_RMWcc_, RMWcc_ARGS(X))(X)
                                   ^
   arch/x86/include/asm/qspinlock.h:18:6: note: in expansion of macro 'GEN_BINARY_RMWcc'
     if (GEN_BINARY_RMWcc(LOCK_PREFIX "btsl", lock->val.counter, c,
         ^
   arch/x86/include/asm/rmwcc.h:25:1: note: previous definition of 'cc_label' was here
    cc_label: c = true;      \
    ^
   include/linux/compiler.h:58:30: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                 ^
   arch/x86/include/asm/qspinlock.h:18:2: note: in expansion of macro 'if'
     if (GEN_BINARY_RMWcc(LOCK_PREFIX "btsl", lock->val.counter, c,
     ^
   arch/x86/include/asm/rmwcc.h:54:2: note: in expansion of macro '__GEN_RMWcc'
     __GEN_RMWcc(op " %[val], " arg0, var, cc,   \
     ^
   arch/x86/include/asm/rmwcc.h:58:2: note: in expansion of macro 'GEN_BINARY_RMWcc_6'
     GEN_BINARY_RMWcc_6(op, var, cc, vcon, val, "%[var]")
     ^
   arch/x86/include/asm/rmwcc.h:9:30: note: in expansion of macro 'GEN_BINARY_RMWcc_5'
    #define __RMWcc_CONCAT(a, b) a ## b
                                 ^
   arch/x86/include/asm/rmwcc.h:10:28: note: in expansion of macro '__RMWcc_CONCAT'
    #define RMWcc_CONCAT(a, b) __RMWcc_CONCAT(a, b)
                               ^
   arch/x86/include/asm/rmwcc.h:60:32: note: in expansion of macro 'RMWcc_CONCAT'
    #define GEN_BINARY_RMWcc(X...) RMWcc_CONCAT(GEN_BINARY_RMWcc_, RMWcc_ARGS(X))(X)
                                   ^
   arch/x86/include/asm/qspinlock.h:18:6: note: in expansion of macro 'GEN_BINARY_RMWcc'
     if (GEN_BINARY_RMWcc(LOCK_PREFIX "btsl", lock->val.counter, c,
         ^
>> arch/x86/include/asm/rmwcc.h:23:17: error: jump into statement expression
       : clobbers : cc_label);    \
                    ^
   include/linux/compiler.h:69:16: note: in definition of macro '__trace_if'
      ______r = !!(cond);     \
                   ^
   arch/x86/include/asm/qspinlock.h:18:2: note: in expansion of macro 'if'
     if (GEN_BINARY_RMWcc(LOCK_PREFIX "btsl", lock->val.counter, c,
     ^
   arch/x86/include/asm/rmwcc.h:21:2: note: in expansion of macro 'asm_volatile_goto'
     asm_volatile_goto (fullop "; j" #cc " %l[cc_label]"  \
     ^
   arch/x86/include/asm/rmwcc.h:54:2: note: in expansion of macro '__GEN_RMWcc'
     __GEN_RMWcc(op " %[val], " arg0, var, cc,   \
     ^
   arch/x86/include/asm/rmwcc.h:58:2: note: in expansion of macro 'GEN_BINARY_RMWcc_6'
     GEN_BINARY_RMWcc_6(op, var, cc, vcon, val, "%[var]")
     ^
   arch/x86/include/asm/rmwcc.h:9:30: note: in expansion of macro 'GEN_BINARY_RMWcc_5'
    #define __RMWcc_CONCAT(a, b) a ## b
                                 ^
   arch/x86/include/asm/rmwcc.h:10:28: note: in expansion of macro '__RMWcc_CONCAT'
    #define RMWcc_CONCAT(a, b) __RMWcc_CONCAT(a, b)
                               ^
   arch/x86/include/asm/rmwcc.h:60:32: note: in expansion of macro 'RMWcc_CONCAT'
    #define GEN_BINARY_RMWcc(X...) RMWcc_CONCAT(GEN_BINARY_RMWcc_, RMWcc_ARGS(X))(X)
                                   ^
   arch/x86/include/asm/qspinlock.h:18:6: note: in expansion of macro 'GEN_BINARY_RMWcc'
     if (GEN_BINARY_RMWcc(LOCK_PREFIX "btsl", lock->val.counter, c,
         ^
   arch/x86/include/asm/rmwcc.h:25:1: note: label 'cc_label' defined here
    cc_label: c = true;      \
    ^
   include/linux/compiler.h:58:30: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                 ^
   arch/x86/include/asm/qspinlock.h:18:2: note: in expansion of macro 'if'
     if (GEN_BINARY_RMWcc(LOCK_PREFIX "btsl", lock->val.counter, c,
     ^
   arch/x86/include/asm/rmwcc.h:54:2: note: in expansion of macro '__GEN_RMWcc'
     __GEN_RMWcc(op " %[val], " arg0, var, cc,   \
     ^
   arch/x86/include/asm/rmwcc.h:58:2: note: in expansion of macro 'GEN_BINARY_RMWcc_6'
     GEN_BINARY_RMWcc_6(op, var, cc, vcon, val, "%[var]")
     ^
   arch/x86/include/asm/rmwcc.h:9:30: note: in expansion of macro 'GEN_BINARY_RMWcc_5'
    #define __RMWcc_CONCAT(a, b) a ## b
                                 ^
   arch/x86/include/asm/rmwcc.h:10:28: note: in expansion of macro '__RMWcc_CONCAT'
    #define RMWcc_CONCAT(a, b) __RMWcc_CONCAT(a, b)
                               ^
   arch/x86/include/asm/rmwcc.h:60:32: note: in expansion of macro 'RMWcc_CONCAT'
    #define GEN_BINARY_RMWcc(X...) RMWcc_CONCAT(GEN_BINARY_RMWcc_, RMWcc_ARGS(X))(X)
                                   ^
   arch/x86/include/asm/qspinlock.h:18:6: note: in expansion of macro 'GEN_BINARY_RMWcc'
     if (GEN_BINARY_RMWcc(LOCK_PREFIX "btsl", lock->val.counter, c,
         ^
>> arch/x86/include/asm/rmwcc.h:25:1: error: duplicate label 'cc_label'
    cc_label: c = true;      \
    ^
   include/linux/compiler.h:69:16: note: in definition of macro '__trace_if'
      ______r = !!(cond);     \
                   ^
   arch/x86/include/asm/qspinlock.h:18:2: note: in expansion of macro 'if'
     if (GEN_BINARY_RMWcc(LOCK_PREFIX "btsl", lock->val.counter, c,
     ^
   arch/x86/include/asm/rmwcc.h:54:2: note: in expansion of macro '__GEN_RMWcc'
     __GEN_RMWcc(op " %[val], " arg0, var, cc,   \
     ^
   arch/x86/include/asm/rmwcc.h:58:2: note: in expansion of macro 'GEN_BINARY_RMWcc_6'
     GEN_BINARY_RMWcc_6(op, var, cc, vcon, val, "%[var]")
     ^
   arch/x86/include/asm/rmwcc.h:9:30: note: in expansion of macro 'GEN_BINARY_RMWcc_5'
    #define __RMWcc_CONCAT(a, b) a ## b
                                 ^
   arch/x86/include/asm/rmwcc.h:10:28: note: in expansion of macro '__RMWcc_CONCAT'
    #define RMWcc_CONCAT(a, b) __RMWcc_CONCAT(a, b)
                               ^
   arch/x86/include/asm/rmwcc.h:60:32: note: in expansion of macro 'RMWcc_CONCAT'
    #define GEN_BINARY_RMWcc(X...) RMWcc_CONCAT(GEN_BINARY_RMWcc_, RMWcc_ARGS(X))(X)
                                   ^
   arch/x86/include/asm/qspinlock.h:18:6: note: in expansion of macro 'GEN_BINARY_RMWcc'
     if (GEN_BINARY_RMWcc(LOCK_PREFIX "btsl", lock->val.counter, c,
         ^
   arch/x86/include/asm/rmwcc.h:25:1: note: previous definition of 'cc_label' was here
    cc_label: c = true;      \
    ^
   include/linux/compiler.h:58:30: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                 ^
   arch/x86/include/asm/qspinlock.h:18:2: note: in expansion of macro 'if'
     if (GEN_BINARY_RMWcc(LOCK_PREFIX "btsl", lock->val.counter, c,
     ^
   arch/x86/include/asm/rmwcc.h:54:2: note: in expansion of macro '__GEN_RMWcc'
     __GEN_RMWcc(op " %[val], " arg0, var, cc,   \
     ^
   arch/x86/include/asm/rmwcc.h:58:2: note: in expansion of macro 'GEN_BINARY_RMWcc_6'
     GEN_BINARY_RMWcc_6(op, var, cc, vcon, val, "%[var]")
     ^
   arch/x86/include/asm/rmwcc.h:9:30: note: in expansion of macro 'GEN_BINARY_RMWcc_5'
    #define __RMWcc_CONCAT(a, b) a ## b
                                 ^
   arch/x86/include/asm/rmwcc.h:10:28: note: in expansion of macro '__RMWcc_CONCAT'
    #define RMWcc_CONCAT(a, b) __RMWcc_CONCAT(a, b)
                               ^
   arch/x86/include/asm/rmwcc.h:60:32: note: in expansion of macro 'RMWcc_CONCAT'
    #define GEN_BINARY_RMWcc(X...) RMWcc_CONCAT(GEN_BINARY_RMWcc_, RMWcc_ARGS(X))(X)
                                   ^
   arch/x86/include/asm/qspinlock.h:18:6: note: in expansion of macro 'GEN_BINARY_RMWcc'
     if (GEN_BINARY_RMWcc(LOCK_PREFIX "btsl", lock->val.counter, c,
         ^
   make[2]: *** [arch/x86/kernel/asm-offsets.s] Error 1
   make[2]: Target '__build' not remade because of errors.
   make[1]: *** [prepare0] Error 2
   make[1]: Target 'prepare' not remade because of errors.
   make: *** [sub-make] Error 2

vim +23 arch/x86/include/asm/rmwcc.h

288e4521 Peter Zijlstra 2018-10-03   8  
288e4521 Peter Zijlstra 2018-10-03   9  #define __RMWcc_CONCAT(a, b) a ## b
288e4521 Peter Zijlstra 2018-10-03 @10  #define RMWcc_CONCAT(a, b) __RMWcc_CONCAT(a, b)
288e4521 Peter Zijlstra 2018-10-03  11  
700b7c54 Jan Beulich    2018-02-19  12  #define __CLOBBERS_MEM(clb...)	"memory", ## clb
df340524 Kees Cook      2017-07-24  13  
ba741e35 H. Peter Anvin 2016-06-08  14  #if !defined(__GCC_ASM_FLAG_OUTPUTS__) && defined(CC_HAVE_ASM_GOTO)
ba741e35 H. Peter Anvin 2016-06-08  15  
ba741e35 H. Peter Anvin 2016-06-08  16  /* Use asm goto */
0c44c2d0 Peter Zijlstra 2013-09-11  17  
288e4521 Peter Zijlstra 2018-10-03  18  #define __GEN_RMWcc(fullop, _var, cc, clobbers, ...)			\
288e4521 Peter Zijlstra 2018-10-03  19  ({									\
288e4521 Peter Zijlstra 2018-10-03  20  	bool c = false;							\
18fe5822 H. Peter Anvin 2016-06-08  21  	asm_volatile_goto (fullop "; j" #cc " %l[cc_label]"		\
288e4521 Peter Zijlstra 2018-10-03  22  			: : [var] "m" (_var), ## __VA_ARGS__		\
df340524 Kees Cook      2017-07-24 @23  			: clobbers : cc_label);				\
288e4521 Peter Zijlstra 2018-10-03  24  	if (0) {							\
288e4521 Peter Zijlstra 2018-10-03 @25  cc_label:	c = true;						\
288e4521 Peter Zijlstra 2018-10-03  26  	}								\
288e4521 Peter Zijlstra 2018-10-03  27  	c;								\
288e4521 Peter Zijlstra 2018-10-03  28  })
0c44c2d0 Peter Zijlstra 2013-09-11  29  

:::::: The code at line 23 was first introduced by commit
:::::: df3405245a8535d2f20bcbdbb615385671cd0792 x86/asm: Add suffix macro for GEN_*_RMWcc()

:::::: TO: Kees Cook <keescook@chromium.org>
:::::: CC: Ingo Molnar <mingo@kernel.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 24934 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [tip:locking/core 6/10] arch/x86/include/asm/rmwcc.h:23:17: error: jump into statement expression
  2018-10-20  3:05 [tip:locking/core 6/10] arch/x86/include/asm/rmwcc.h:23:17: error: jump into statement expression kbuild test robot
@ 2018-10-22 10:08 ` Peter Zijlstra
  2018-10-22 10:22   ` Will Deacon
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Zijlstra @ 2018-10-22 10:08 UTC (permalink / raw)
  To: kbuild test robot
  Cc: kbuild-all, linux-kernel, tipbuild, Ingo Molnar, Will Deacon,
	Steven Rostedt

On Sat, Oct 20, 2018 at 11:05:11AM +0800, kbuild test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git locking/core
> head:   01a14bda11add9dcd4a59200f13834d634559935
> commit: 7aa54be2976550f17c11a1c3e3630002dea39303 [6/10] locking/qspinlock, x86: Provide liveness guarantee
> config: x86_64-randconfig-u0-10201040 (attached as .config)
> compiler: gcc-5 (Debian 5.5.0-3) 5.4.1 20171010
> reproduce:
>         git checkout 7aa54be2976550f17c11a1c3e3630002dea39303
>         # save the attached .config to linux build tree
>         make ARCH=x86_64 
> 
> All errors (new ones prefixed by >>):
> 
>    In file included from arch/x86/include/asm/atomic.h:5:0,
>                     from include/linux/atomic.h:7,
>                     from include/linux/crypto.h:20,
>                     from arch/x86/kernel/asm-offsets.c:9:
>    arch/x86/include/asm/qspinlock.h: In function 'queued_fetch_set_pending_acquire':
> >> arch/x86/include/asm/rmwcc.h:23:17: error: jump into statement expression
>        : clobbers : cc_label);    \
>                     ^
>    include/linux/compiler.h:58:42: note: in definition of macro '__trace_if'
>      if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
>                                              ^

ARGH; so, this:

#define __GEN_RMWcc(fullop, _var, cc, clobbers, ...)			\
({									\
	bool c = false;							\
	asm_volatile_goto (fullop "; j" #cc " %l[cc_label]"		\
			: : [var] "m" (_var), ## __VA_ARGS__		\
			: clobbers : cc_label);				\
	if (0) {							\
cc_label:	c = true;						\
	}								\
	c;								\
})

static __always_inline u32 queued_fetch_set_pending_acquire(struct qspinlock *lock)
{
	u32 val = 0;

	if (GEN_BINARY_RMWcc(LOCK_PREFIX "btsl", lock->val.counter, c,
			     "I", _Q_PENDING_OFFSET))
		val |= _Q_PENDING_VAL;

	val |= atomic_read(&lock->val) & ~_Q_PENDING_MASK;

	return val;
}

fails to compile when combined with this:

#define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
#define __trace_if(cond) \
	if (__builtin_constant_p(!!(cond)) ? !!(cond) :			\
	({								\
		int ______r;						\
		static struct ftrace_branch_data			\
			__attribute__((__aligned__(4)))			\
			__attribute__((section("_ftrace_branch")))	\
			______f = {					\
				.func = __func__,			\
				.file = __FILE__,			\
				.line = __LINE__,			\
			};						\
		______r = !!(cond);					\
		______f.miss_hit[______r]++;				\
		______r;						\
	}))

Because that moves the __GEN_RMWcc into a statement expression and GCC
apparently doesn't like labels inside statement expressions.

If we avoid if() and rewrite queued_fetch_set_pending_acquire() like so:

static __always_inline u32 queued_fetch_set_pending_acquire(struct qspinlock *lock)
{
	bool pending;
	u32 val;

	pending = GEN_BINARY_RMWcc(LOCK_PREFIX "btsl", lock->val.counter, c,
				   "I", _Q_PENDING_OFFSET);

	val = pending * _Q_PENDING_VAL;
	val |= atomic_read(&lock->val) & ~_Q_PENDING_MASK;

	return val;
}

then it compiles again; but urgh.

Anybody see a better solution?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [tip:locking/core 6/10] arch/x86/include/asm/rmwcc.h:23:17: error: jump into statement expression
  2018-10-22 10:08 ` Peter Zijlstra
@ 2018-10-22 10:22   ` Will Deacon
  0 siblings, 0 replies; 3+ messages in thread
From: Will Deacon @ 2018-10-22 10:22 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: kbuild test robot, kbuild-all, linux-kernel, tipbuild,
	Ingo Molnar, Steven Rostedt

On Mon, Oct 22, 2018 at 12:08:30PM +0200, Peter Zijlstra wrote:
> ARGH; so, this:
> 
> #define __GEN_RMWcc(fullop, _var, cc, clobbers, ...)			\
> ({									\
> 	bool c = false;							\
> 	asm_volatile_goto (fullop "; j" #cc " %l[cc_label]"		\
> 			: : [var] "m" (_var), ## __VA_ARGS__		\
> 			: clobbers : cc_label);				\
> 	if (0) {							\
> cc_label:	c = true;						\
> 	}								\
> 	c;								\
> })
> 
> static __always_inline u32 queued_fetch_set_pending_acquire(struct qspinlock *lock)
> {
> 	u32 val = 0;
> 
> 	if (GEN_BINARY_RMWcc(LOCK_PREFIX "btsl", lock->val.counter, c,
> 			     "I", _Q_PENDING_OFFSET))
> 		val |= _Q_PENDING_VAL;
> 
> 	val |= atomic_read(&lock->val) & ~_Q_PENDING_MASK;
> 
> 	return val;
> }
> 
> fails to compile when combined with this:
> 
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )

Rosteeeedt!

> #define __trace_if(cond) \
> 	if (__builtin_constant_p(!!(cond)) ? !!(cond) :			\
> 	({								\
> 		int ______r;						\
> 		static struct ftrace_branch_data			\
> 			__attribute__((__aligned__(4)))			\
> 			__attribute__((section("_ftrace_branch")))	\
> 			______f = {					\
> 				.func = __func__,			\
> 				.file = __FILE__,			\
> 				.line = __LINE__,			\
> 			};						\
> 		______r = !!(cond);					\
> 		______f.miss_hit[______r]++;				\
> 		______r;						\
> 	}))
> 
> Because that moves the __GEN_RMWcc into a statement expression and GCC
> apparently doesn't like labels inside statement expressions.
> 
> If we avoid if() and rewrite queued_fetch_set_pending_acquire() like so:
> 
> static __always_inline u32 queued_fetch_set_pending_acquire(struct qspinlock *lock)
> {
> 	bool pending;
> 	u32 val;
> 
> 	pending = GEN_BINARY_RMWcc(LOCK_PREFIX "btsl", lock->val.counter, c,
> 				   "I", _Q_PENDING_OFFSET);
> 
> 	val = pending * _Q_PENDING_VAL;
> 	val |= atomic_read(&lock->val) & ~_Q_PENDING_MASK;
> 
> 	return val;
> }
> 
> then it compiles again; but urgh.
> 
> Anybody see a better solution?

No, that looks about right to me, but please throw in a comment so that we
don't "fix" this in the future.

Will

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-10-22 10:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-20  3:05 [tip:locking/core 6/10] arch/x86/include/asm/rmwcc.h:23:17: error: jump into statement expression kbuild test robot
2018-10-22 10:08 ` Peter Zijlstra
2018-10-22 10:22   ` Will Deacon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox