From: Will Deacon <will.deacon@arm.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: kbuild test robot <lkp@intel.com>,
kbuild-all@01.org, linux-kernel@vger.kernel.org,
tipbuild@zytor.com, Ingo Molnar <mingo@kernel.org>,
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 11:22:55 +0100 [thread overview]
Message-ID: <20181022102254.GA5999@brain-police> (raw)
In-Reply-To: <20181022100830.GK4931@worktop.programming.kicks-ass.net>
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
prev parent reply other threads:[~2018-10-22 10:23 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
2018-10-22 10:22 ` Will Deacon [this message]
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=20181022102254.GA5999@brain-police \
--to=will.deacon@arm.com \
--cc=kbuild-all@01.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tipbuild@zytor.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox