From: Ian Campbell <ian.campbell@citrix.com>
To: Rob Herring <robherring2@gmail.com>
Cc: "xen-devel@lists.xen.org" <xen-devel@lists.xen.org>,
"Keir (Xen.org)" <keir@xen.org>,
Stefano Stabellini <Stefano.Stabellini@eu.citrix.com>,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
"Tim (Xen.org)" <tim@xen.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Jan Beulich <JBeulich@suse.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
Nicolas Pitre <nico@fluxnic.net>,
Will Deacon <will.deacon@arm.com>
Subject: Re: [PATCH LINUX v5] xen: event channel arrays are xen_ulong_t and not unsigned long
Date: Tue, 5 Mar 2013 03:56:41 +0000 [thread overview]
Message-ID: <1362455801.8941.24.camel@hastur.hellion.org.uk> (raw)
In-Reply-To: <51340ACD.70904@gmail.com>
> > diff --git a/arch/arm/include/asm/xen/events.h b/arch/arm/include/asm/xen/events.h
> > index 94b4e90..5c27696 100644
> > --- a/arch/arm/include/asm/xen/events.h
> > +++ b/arch/arm/include/asm/xen/events.h
> > @@ -15,4 +15,26 @@ static inline int xen_irqs_disabled(struct pt_regs *regs)
> > return raw_irqs_disabled_flags(regs->ARM_cpsr);
> > }
> >
> > +/*
> > + * We cannot use xchg because it does not support 8-byte
> > + * values. However it is safe to use {ldr,dtd}exd directly because all
> > + * platforms which Xen can run on support those instructions.
>
> Why does atomic64_cmpxchg not work here?
Just that we don't want/need the cmp aspect, we don't mind if an extra
bit gets set as we read the value, so long as we atomically read and set
to zero.
> > + */
> > +static inline xen_ulong_t xchg_xen_ulong(xen_ulong_t *ptr, xen_ulong_t val)
> > +{
> > + xen_ulong_t oldval;
> > + unsigned int tmp;
> > +
> > + wmb();
>
> Based on atomic64_cmpxchg implementation, you could use smp_mb here
> which avoids an outer cache flush.
Good point.
> > + asm volatile("@ xchg_xen_ulong\n"
> > + "1: ldrexd %0, %H0, [%3]\n"
> > + " strexd %1, %2, %H2, [%3]\n"
> > + " teq %1, #0\n"
> > + " bne 1b"
> > + : "=&r" (oldval), "=&r" (tmp)
> > + : "r" (val), "r" (ptr)
> > + : "memory", "cc");
>
> And a smp_mb is needed here.
I think for the specific caller which we have here it isn't strictly
necessary, but for generic correctness I think you are right.
Thanks for reviewing.
Konrad, IIRC you have already picked this up (and sent to Linus?) so an
incremental fix is required? See below.
Ian.
8<------------------------------------
>From 4ed928274dad4c3ed610e769b2ae11eb2d1ea433 Mon Sep 17 00:00:00 2001
From: Ian Campbell <ijc@hellion.org.uk>
Date: Tue, 5 Mar 2013 03:37:23 +0000
Subject: [PATCH] arm: xen: correct barriers in xchg_xen_ulong
We can use an smp_wmb rather than a wmb here and we also need one after the
exchange. Spotted by Rob Herring.
Signed-off-by: Ian Campbell <ijc@hellion.org.uk>
---
arch/arm/include/asm/xen/events.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/arm/include/asm/xen/events.h b/arch/arm/include/asm/xen/events.h
index 5c27696..0e1f59e 100644
--- a/arch/arm/include/asm/xen/events.h
+++ b/arch/arm/include/asm/xen/events.h
@@ -25,7 +25,7 @@ static inline xen_ulong_t xchg_xen_ulong(xen_ulong_t *ptr, xen_ulong_t val)
xen_ulong_t oldval;
unsigned int tmp;
- wmb();
+ smp_wmb();
asm volatile("@ xchg_xen_ulong\n"
"1: ldrexd %0, %H0, [%3]\n"
" strexd %1, %2, %H2, [%3]\n"
@@ -34,6 +34,7 @@ static inline xen_ulong_t xchg_xen_ulong(xen_ulong_t *ptr, xen_ulong_t val)
: "=&r" (oldval), "=&r" (tmp)
: "r" (val), "r" (ptr)
: "memory", "cc");
+ smp_wmb();
return oldval;
}
--
1.7.10.4
next prev parent reply other threads:[~2013-03-05 3:59 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-19 14:48 [PATCH V2] " Ian Campbell
2013-02-19 14:49 ` [PATCH LINUX] " Ian Campbell
2013-02-19 17:11 ` Stefano Stabellini
2013-02-19 17:17 ` Ian Campbell
2013-02-19 17:26 ` Tim Deegan
2013-02-19 17:28 ` Ian Campbell
2013-02-19 14:49 ` [PATCH XEN] " Ian Campbell
2013-02-19 16:42 ` Stefano Stabellini
2013-02-21 17:16 ` Ian Campbell
2013-02-21 18:43 ` Keir Fraser
2013-02-22 8:28 ` Ian Campbell
2013-02-22 8:12 ` Jan Beulich
2013-02-22 8:28 ` Ian Campbell
2013-02-22 8:48 ` Jan Beulich
2013-02-22 8:55 ` Ian Campbell
2013-02-22 9:05 ` Jan Beulich
2013-02-19 17:27 ` [PATCH LINUX v3] " Ian Campbell
2013-02-19 17:29 ` [PATCH LINUX v4] " Ian Campbell
2013-02-19 18:12 ` Stefano Stabellini
2013-02-19 18:43 ` Konrad Rzeszutek Wilk
2013-02-20 2:07 ` Konrad Rzeszutek Wilk
2013-02-20 3:09 ` Konrad Rzeszutek Wilk
2013-02-20 9:13 ` Ian Campbell
2013-02-20 11:48 ` [PATCH LINUX v5] " Ian Campbell
2013-02-21 17:11 ` Stefano Stabellini
2013-03-04 2:45 ` Rob Herring
2013-03-05 3:04 ` Will Deacon
2013-03-05 3:45 ` Ian Campbell
2013-03-05 6:55 ` Rob Herring
2013-03-05 7:03 ` Ian Campbell
2013-03-05 8:08 ` Will Deacon
2013-03-05 9:29 ` Ian Campbell
2013-03-07 3:17 ` Will Deacon
2013-03-07 7:17 ` Ian Campbell
2013-03-05 3:56 ` Ian Campbell [this message]
2013-03-05 14:04 ` Konrad Rzeszutek Wilk
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=1362455801.8941.24.camel@hastur.hellion.org.uk \
--to=ian.campbell@citrix.com \
--cc=JBeulich@suse.com \
--cc=Stefano.Stabellini@eu.citrix.com \
--cc=keir@xen.org \
--cc=konrad.wilk@oracle.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nico@fluxnic.net \
--cc=robherring2@gmail.com \
--cc=tim@xen.org \
--cc=will.deacon@arm.com \
--cc=xen-devel@lists.xen.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
Powered by JetHome