All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: kbuild test robot <lkp@intel.com>
Cc: kbuild-all@01.org, linux-kernel@vger.kernel.org,
	tipbuild@zytor.com, Ingo Molnar <mingo@kernel.org>,
	Will Deacon <will.deacon@arm.com>,
	Steven Rostedt <rostedt@goodmis.org>
Subject: Re: [tip:locking/core 6/10] arch/x86/include/asm/rmwcc.h:23:17: error: jump into statement expression
Date: Mon, 22 Oct 2018 12:08:30 +0200	[thread overview]
Message-ID: <20181022100830.GK4931@worktop.programming.kicks-ass.net> (raw)
In-Reply-To: <201810201105.YsnXEXTU%fengguang.wu@intel.com>

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?

  reply	other threads:[~2018-10-22 10:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2018-10-22 10:22   ` Will Deacon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181022100830.GK4931@worktop.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=kbuild-all@01.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=mingo@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=tipbuild@zytor.com \
    --cc=will.deacon@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.