From: "Jan Beulich" Subject: Re: [PATCHv4 2/5] arm: provide add_sized() Date: Wed, 13 May 2015 10:26:33 +0100 Message-ID: <555334E90200007800079E80@mail.emea.novell.com> References: <1431355025-20468-1-git-send-email-david.vrabel@citrix.com> <1431355025-20468-3-git-send-email-david.vrabel@citrix.com> <5550C083.2080106@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YsSw0-00051x-Rg for xen-devel@lists.xenproject.org; Wed, 13 May 2015 09:26:36 +0000 In-Reply-To: <5550C083.2080106@citrix.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: David Vrabel , Ian Campbell Cc: Andrew Cooper , Tim Deegan , Keir Fraser , Jennifer Herbert , xen-devel@lists.xenproject.org List-Id: xen-devel@lists.xenproject.org >>> On 11.05.15 at 16:45, wrote: > On 11/05/15 15:37, David Vrabel wrote: >> add_sized(ptr, inc) adds inc to the value at ptr using only the correct >> size of loads and stores for the type of *ptr. The add is /not/ atomic. >> >> This is needed for ticket locks to ensure the increment of the head ticket >> does not affect the tail ticket. > [...] >> >> +#define add_sized(p, x) ({ \ >> + typeof(*p) __x = (x); \ >> + switch ( sizeof(*p) ) \ >> + { \ >> + case 1: add_u8_sized((uint8_t *)p, (uint8_t)__x); break; \ >> + case 2: add_u16_sized((uint16_t *)p, (uint16_t)__x); break; \ >> + case 4: add_u32_sized((uint32_t *)p, (uint32_t)__x); break; \ >> + default: __bad_atomic_size(); break; \ >> + } \ >> + __x; \ > > I should have cleaned up this arm implementation in the same way I did > x86. Please drop this "__x;" before committing, or I can resubmit if it > is preferred. No problem. But I suppose the casts on __x inside the individual case statements aren't needed either. Also it looks a little odd that x86 handles 8-byte operands here, but ARM (and namely ARM64) doesn't. Jan