From: Alexander Potapenko <glider@google.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Paul McKenney <paulmck@linux.ibm.com>,
"H. Peter Anvin" <hpa@zytor.com>,
LKML <linux-kernel@vger.kernel.org>,
Dmitriy Vyukov <dvyukov@google.com>,
James Y Knight <jyknight@google.com>,
x86@kernel.org, Ingo Molnar <mingo@redhat.com>
Subject: Re: [PATCH] x86/asm: use memory clobber in bitops that touch arbitrary memory
Date: Tue, 2 Apr 2019 10:59:05 +0200 [thread overview]
Message-ID: <CAG_fn=UJD=j1nNpq9qp9tr8J2ru4KaoPofk71XJjUW0=qcVTSA@mail.gmail.com> (raw)
In-Reply-To: <20190402072659.GH12232@hirez.programming.kicks-ass.net>
On Tue, Apr 2, 2019 at 9:27 AM Peter Zijlstra <peterz@infradead.org> wrote:
>
>
>
> On Mon, Apr 01, 2019 at 06:24:08PM +0200, Alexander Potapenko wrote:
> > diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
> > index d153d570bb04..20e4950827d9 100644
> > --- a/arch/x86/include/asm/bitops.h
> > +++ b/arch/x86/include/asm/bitops.h
> > @@ -111,7 +111,7 @@ clear_bit(long nr, volatile unsigned long *addr)
> > } else {
> > asm volatile(LOCK_PREFIX __ASM_SIZE(btr) " %1,%0"
> > : BITOP_ADDR(addr)
> > - : "Ir" (nr));
> > + : "Ir" (nr) : "memory");
> > }
> > }
>
> clear_bit() doesn't have a return value, so why are we now still using
> "+m" output ?
You're right, "m" should suffice. I'll update the patch.
By the way, now that we've added the memory barriers we can probably
remove the barrier() call from __clear_bit_unlock() and update the
comment accordingly.
For clear_bit() the memory barrier is missing on the IS_IMMEDIATE(nr)
path, so this one should be kept as is.
> AFAICT the only reason we did that was to clobber the variable, which
> you've (afaiu correctly) argued to be incorrect.
>
> So whould we not write this as:
>
> asm volatile (LOCK_PREFIX __ASM_SIZE(btr) " %[nr], %[addr]"
> : : [addr] "m" (*addr), [nr] "Ir" (nr)
> : "memory");
>
> ?
>
> And the very same for _all_ other sites touched in this patch.
--
Alexander Potapenko
Software Engineer
Google Germany GmbH
Erika-Mann-Straße, 33
80636 München
Geschäftsführer: Paul Manicle, Halimah DeLaine Prado
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
next prev parent reply other threads:[~2019-04-02 8:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-01 16:24 [PATCH] x86/asm: use memory clobber in bitops that touch arbitrary memory Alexander Potapenko
2019-04-01 19:12 ` Paul E. McKenney
2019-04-02 7:26 ` Peter Zijlstra
2019-04-02 8:59 ` Alexander Potapenko [this message]
2019-04-02 11:31 ` Alexander Potapenko
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='CAG_fn=UJD=j1nNpq9qp9tr8J2ru4KaoPofk71XJjUW0=qcVTSA@mail.gmail.com' \
--to=glider@google.com \
--cc=dvyukov@google.com \
--cc=hpa@zytor.com \
--cc=jyknight@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=paulmck@linux.ibm.com \
--cc=peterz@infradead.org \
--cc=x86@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).