From: Ian Campbell Subject: Re: [PATCH] xen: fix alignment for bitops Date: Tue, 15 Apr 2014 10:37:43 +0100 Message-ID: <1397554663.24638.36.camel@kazak.uk.xensource.com> References: <1397508202-16249-1-git-send-email-murzin.v@gmail.com> <534CFD520200007800008CF1@nat28.tlf.novell.com> <534D0EB30200007800008D8B@nat28.tlf.novell.com> <1397553350.24638.19.camel@kazak.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WZzoK-0005cP-TD for xen-devel@lists.xenproject.org; Tue, 15 Apr 2014 09:37:49 +0000 In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Vladimir Murzin Cc: xen-devel@lists.xenproject.org, boris.ostrovsky@oracle.com, david.vrabel@citrix.com, Jan Beulich List-Id: xen-devel@lists.xenproject.org On Tue, 2014-04-15 at 10:30 +0100, Vladimir Murzin wrote: > On Tue, Apr 15, 2014 at 10:15 AM, Ian Campbell wrote: > > On Tue, 2014-04-15 at 09:49 +0100, Jan Beulich wrote: > >> >>> On 15.04.14 at 10:29, wrote: > >> > On Tue, Apr 15, 2014 at 8:35 AM, Jan Beulich wrote: > >> >> only place you'd need to alter - we simply assume bitops on 32-bit > >> >> aligned quantities to work. > >> >> > >> > > >> > You do, but reality seems to be different, apart from arm64 looks like > >> > ppc64 has the same alignment requirement, I'm not aware about other > >> > 64-bit implementations... but, is it really possible to convince all > >> > these people to change the implementation? I guess the answer would be > >> > "use unsigned long", or like that :) > >> > >> That's no the point. The point is that if the arch has such > >> requirements, the arch-specific bitmap manipulation functions > >> should be written such that generic code works with the present > >> assumptions. > > > > In this case the interface which arch-specific code has contracted to > > expose to the generic code is: > > extern unsigned long find_first_bit(const unsigned long > > *addr, ... > > i.e. the bitmask is unsigned long (and this is the case for the majority > > of archs in Linux AFAICS, include asm-generic, note that this differs to > > Xen which IIRC uses void * here) > > > > So it is reasonable IMHO for the Linux arch code to except to be passed > > something which obeys the alignment rules for an unsigned long. > > > > I'm not convinced by the use of __aligned here -- I think it would be > > better to just use unsigned long. > > It was original idea, but I was in doubt that it didn't break > interface... The usage is ready = xchg(&control_block->ready, 0); and ready |= xchg(&control_block->ready, 0); where control_block->ready is a uint32_t, so I don't think anything will be broken (at least so long as sizeof(unsigned long) >= sizeof(uint32_t), which I think we can rely on) > Should I send v2 or wait for other proposals? I'd wait for the Linux maintainers to speak up. Ian.