[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 4/8] xen/ppc: Implement bitops.h


  • To: Shawn Anastasio <sanastasio@xxxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Fri, 1 Sep 2023 08:29:59 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1iLRMKdSo3X5O8szupheY/zd2SQEXJ8qgqh3EYQfQpA=; b=lBo+dEyAPJYML87AHyrlXB76093V49Y46Wom3HbngjojxeNtoHQU5j9AnUgdTWxZ0UhUfcfCzAX39rcgKZIsDaXMmqMcwIfRtt9KY1IngJa3TCjgm0dh729whzxnt6g+2C7SNu997yL3TdYTIUEGg5gnzilLisE0RJZ25hefMGKzyZfPlANB1mXAikKbknNTpjz9dN2DPWVUOrjdmf5gi60ZGHucpPwG5F9MwNRDIddEzLLcgDG1f5HOug3QNlwakk9DMKC50zupB0KTpeIvrxfuouSaib3BERK9CAxrLG/VT92VufehTRHm+71lnYOPSYQUwD9zi7LquZGeqeOA2A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cF3y+/DFlmiC5k5IvSmD7cxRnmPmJuCs02S8rVTeFgO4aw0koXbp1mYZEYKXxXxVg8pUq/yPYpGCl/DVYbDsE8S5d8eJdlIMwIav1zIe7Ib0vW7uvqTI8FPtZtzFeUCwRy6Xg9WzTXpaDtRyYZ5FR+I8Bs5TABjbxCTREsToueHM8RGPYDc1ZHwO5vE5axZDWZ4tJsY2VOutzlss4lj920D6PfFtoTVsPUmynv5WxcrVtiWEQYtjY9/VIQFcxpJ6aThJOVM3B8Zv9YRXVCrQ5OSCy+p3Rljc2fZuwTkaU1ml43x6ebhfdP/0PoKGfB4Vz5x5A2Qm0MgoT6Hnh4HB2A==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Timothy Pearson <tpearson@xxxxxxxxxxxxxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Fri, 01 Sep 2023 06:30:28 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 31.08.2023 22:06, Shawn Anastasio wrote:
> On 8/29/23 8:59 AM, Jan Beulich wrote:
>> On 23.08.2023 22:07, Shawn Anastasio wrote:
>>> +{                                                                          
>>>     \
>>> +    unsigned long old;                                                     
>>>     \
>>> +    unsigned int *p = (unsigned int *)_p;                                  
>>>     \
>>> +    asm volatile (                                                         
>>>     \
>>> +    prefix                                                                 
>>>     \
>>> +"1: lwarx %0,0,%3,0\n"                                                     
>>>     \
>>> +    #op "%I2 %0,%0,%2\n"                                                   
>>>     \
>>> +    "stwcx. %0,0,%3\n"                                                     
>>>     \
>>> +    "bne- 1b\n"                                                            
>>>     \
>>> +    : "=&r" (old), "+m" (*p)                                               
>>>     \
>>> +    : "rK" (mask), "r" (p)                                                 
>>>     \
>>> +    : "cc", "memory");                                                     
>>>     \
>>
>> The asm() body wants indenting by another four blanks (more instances below).
>>
> 
> If I were to match the style used in the previous patch's atomic.h, the
> body should be indented to line up with the opening ( of the asm
> statement, right?

Depends on whether the ( is to remain the last token on its line. If so, ...

> I'll go ahead and do that for consistency's sake
> unless you think it would be better to just leave it as-is with an extra
> 4 spaces of indentation.

... this style of indentation would want using. Either is fine, in case you
have a specific preference.

>>> +/* Based on linux/include/asm-generic/bitops/ffz.h */
>>> +/*
>>> + * ffz - find first zero in word.
>>> + * @word: The word to search
>>> + *
>>> + * Undefined if no zero exists, so code should check against ~0UL first.
>>> + */
>>> +#define ffz(x)  __ffs(~(x))
>>> +
>>> +/**
>>> + * hweightN - returns the hamming weight of a N-bit word
>>> + * @x: the word to weigh
>>> + *
>>> + * The Hamming Weight of a number is the total number of bits set in it.
>>> + */
>>> +#define hweight64(x) generic_hweight64(x)
>>> +#define hweight32(x) generic_hweight32(x)
>>> +#define hweight16(x) generic_hweight16(x)
>>> +#define hweight8(x) generic_hweight8(x)
>>
>> Not using popcnt{b,w,d}, e.g. via a compiler builtin?
>>
> 
> Excellent point. It looks like gcc's __builtin_popcount* family of
> builtins will do what we want here. I suppose the other architectures in
> Xen don't do this because they target toolchains old enough to not have
> these builtins?

Well, on x86 a patch introducing its use is actually pending ("x86: use
POPCNT for hweight<N>() when available").

>>> +    tmp = (*p) & (~0UL >> (BITS_PER_LONG - size));
>>> +    if (tmp == 0UL)        /* Are any bits set? */
>>> +        return result + size;    /* Nope. */
>>> +found:
>>
>> Labels indented by at least one blank please. (More elsewhere.)
> 
> I wasn't aware of this style convention -- so a single blank before the
> label would be correct?

Yes. (There are cases where deeper indentation is neater, but this isn't
one of them.)

Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.