From: Ian Campbell <ian.campbell@citrix.com>
To: David Vrabel <david.vrabel@citrix.com>
Cc: xen-devel@lists.xenproject.org, Tim Deegan <tim@xen.org>,
Keir Fraser <keir@xen.org>, Jan Beulich <JBeulich@suse.com>,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: Re: [PATCHv2 3/6] xen: generic xadd() for ticket locks
Date: Fri, 17 Apr 2015 14:09:48 +0100 [thread overview]
Message-ID: <1429276188.25195.310.camel@citrix.com> (raw)
In-Reply-To: <5530FDCB.1040003@citrix.com>
On Fri, 2015-04-17 at 13:34 +0100, David Vrabel wrote:
> On 17/04/15 13:32, Ian Campbell wrote:
> > On Thu, 2015-04-16 at 16:28 +0100, Jan Beulich wrote:
> >>>>> On 10.04.15 at 16:19, <david.vrabel@citrix.com> wrote:
> >>> +#define xadd(ptr, v) generic_xaddl((ptr), (v))
> >>
> >> I think it is at least confusing to call the thing xadd (looking to be
> >> size generic) and then expand to generic_xaddl (only supporting
> >> 32-bit operations), yet subsequently implementing a size-generic
> >> xadd() for x86.
> >
> > Indeed, and I went to build on arm32 prior to hacking up a proper xadd
> > and:
> >
> > spinlock.c: In function ‘_spin_lock’:
> > spinlock.c:145:5: error: passing argument 1 of ‘generic_xaddl’ from incompatible pointer type [-Werror]
> > tickets.head_tail = xadd(&lock->tickets, tickets.head_tail);
> > ^
> > spinlock.c:15:12: note: expected ‘volatile u32 *’ but argument is of type ‘union spinlock_tickets_t *’
> > static u32 generic_xaddl(volatile u32 *ptr, u32 v)
> > ^
> >
> > (I hope to knock up the arm asm version in the next hour or so, so you
> > may not care...)
>
> Can you use
>
> git://xenbits.xen.org/people/dvrabel/xen.git ticketlocks-v3
>
> as a base instead?
I tried that and it built and booted just fine on both arm32 and arm64.
I eyeballed the assembly produced via the use of __sync_fetch_and_add
(for _spin_lock only) and it is exactly what I would have written in my
own versions.
I was using gcc 4.8.3 in both cases. For arm64 I'm pretty sure we don't
want to consider anything earlier.
For arm32 I have also tried gcc 4.6.3 (Debian Wheezy's compiler) and it
built and booted, and eyeballing shows the same asm. I think that's the
earliest we really need to worry about.
IOW I'm not going to bother with custom versions of these functions on
ARM. If you wanted you could drop the #ifndef xadd from
asm-arm/system.h.
Perhaps it would be useful to add some of the info from my tests
reported above, or a reference to this mail, to the commit log?
in either case you can add:
Acked-by: Ian Campbell <ian.campbell@citrix.com>
to the patch below.
commit b08cf3fa4791d7ff0d01fb932192e02078ce670a
Author: David Vrabel <david.vrabel@citrix.com>
Date: Thu Apr 16 15:31:18 2015 +0100
arm: provide xadd()
xadd() atomically adds a value and returns the previous value. This
is needed to implement ticket locks.
This generic arm implementation uses the GCC __sync_fetch_and_add()
builtin, but a arm32 or arm64 specific variant could be provided in the
future (e.g., if required to support older versions of GCC).
Signed-off-by: David Vrabel <david.vrabel@citrix.com>
diff --git a/xen/include/asm-arm/system.h b/xen/include/asm-arm/system.h
index ce3d38a..f037e84 100644
--- a/xen/include/asm-arm/system.h
+++ b/xen/include/asm-arm/system.h
@@ -51,6 +51,10 @@
# error "unknown ARM variant"
#endif
+#ifndef xadd
+# define xadd(x, v) __sync_fetch_and_add(x, v)
+#endif
+
extern struct vcpu *__context_switch(struct vcpu *prev, struct vcpu *next);
#endif
Ian.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2015-04-17 13:10 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-10 14:19 [PATCHv2 0/6] Use ticket locks for spinlocks David Vrabel
2015-04-10 14:19 ` [PATCHv2 1/6] x86/hvm: don't include asm/spinlock.h David Vrabel
2015-04-10 15:24 ` Andrew Cooper
2015-04-13 13:13 ` David Vrabel
2015-04-13 13:15 ` Andrew Cooper
2015-04-16 11:09 ` Tim Deegan
2015-04-10 14:19 ` [PATCHv2 2/6] x86/mtrr: include asm/atomic.h David Vrabel
2015-04-10 15:25 ` Andrew Cooper
2015-04-16 11:10 ` Tim Deegan
2015-04-10 14:19 ` [PATCHv2 3/6] xen: generic xadd() for ticket locks David Vrabel
2015-04-14 13:17 ` Ian Campbell
2015-04-14 16:37 ` David Vrabel
2015-04-15 8:34 ` Ian Campbell
2015-04-16 11:13 ` Tim Deegan
2015-04-16 15:28 ` Jan Beulich
2015-04-17 12:32 ` Ian Campbell
2015-04-17 12:33 ` Ian Campbell
2015-04-17 12:34 ` David Vrabel
2015-04-17 13:09 ` Ian Campbell [this message]
2015-04-17 13:13 ` David Vrabel
2015-04-10 14:19 ` [PATCHv2 4/6] x86: provide xadd() David Vrabel
2015-04-16 11:25 ` Tim Deegan
2015-04-16 11:38 ` David Vrabel
2015-04-16 11:41 ` Tim Deegan
2015-04-16 11:49 ` Jan Beulich
2015-04-16 12:49 ` Tim Deegan
2015-04-16 12:55 ` Ian Campbell
2015-04-16 13:19 ` Jan Beulich
2015-04-16 14:07 ` Ian Campbell
2015-04-16 14:09 ` Ian Campbell
2015-04-16 12:00 ` Ian Campbell
2015-04-10 14:19 ` [PATCHv2 5/6] xen: use ticket locks for spin locks David Vrabel
2015-04-10 15:29 ` Andrew Cooper
2015-04-10 16:44 ` Boris Ostrovsky
2015-04-10 17:29 ` David Vrabel
2015-04-10 17:58 ` Boris Ostrovsky
2015-04-16 12:03 ` Tim Deegan
2015-04-16 12:46 ` David Vrabel
2015-04-16 12:50 ` Tim Deegan
2015-04-16 13:32 ` Jan Beulich
2015-04-21 9:59 ` David Vrabel
2015-04-10 14:19 ` [PATCHv2 6/6] x86, arm: remove asm/spinlock.h from all architectures David Vrabel
2015-04-16 12:51 ` Tim Deegan
2015-04-16 15:29 ` Jan Beulich
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=1429276188.25195.310.camel@citrix.com \
--to=ian.campbell@citrix.com \
--cc=JBeulich@suse.com \
--cc=david.vrabel@citrix.com \
--cc=keir@xen.org \
--cc=stefano.stabellini@eu.citrix.com \
--cc=tim@xen.org \
--cc=xen-devel@lists.xenproject.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 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.