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

Re: [PATCH v2][4.17?] core-parking: fix build with gcc12 and NR_CPUS=1


  • To: Julien Grall <julien@xxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 24 Oct 2022 12:22:42 +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=JrsT4oz+McSEWWlkWatxfRsA6DzxpFX4soqNNQbN5vc=; b=DTL858Kd/JOssYsjaHiOw4qRkYCD6zNSXzaObSplC/9/7PZd6AkV+y4dqPL4OXSjsbAzesZB1sVQMlen4akZ2vPXo31Lh9/+J1c/EA9nrIPM1g5Xl3nVnlG6nYb0D4YWjTxaIT07PkW2w9FQ845OI382SjvmctIGtmcRnVpPxQO7+WyZp1LdM7wsf0AC3CPF7tg6leLV0bwCBV7MTvk+fa7Cdk7/l0wsN2fypVBranlstwShgrFApYjOApbk4pU0t7yGDrQVUpnyg+GpxrrELHDUrSBEX8Rk7JvVGZeSEqzZk/0/dTF7FATe3Jc0ozNKVIgHfhNQ4TAVaxkbYpP1tg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Zx0rF9MTZ9XPZX8nbVmNQFDsEF3GndsGNNH7eVT0p6PnMdrc3ax51bSt4tsAcWrz11BePpkqGp7y7X3M5OAOhsNlHzC7iULAbrw9IwRzw0tIvTmCImpJeDlrp8voKYWvnyjf4PKeSg58f6H+ya3pzh69CX3HhuAVEZtUXLeeFik93VudEh0qnGA+FI9dXNyiibZHDiHCrE0wx94gJXqsQVmWeNr1hIGqoIaTtIGZbWXr5BtKCOFy4FjvwoZjBLjAy+nyll2rCVSHXVhh5Q+3pX0lQjnDTvayJaXcYB0xB92nJ5hbZW3aZvzsPxJhQ0Inqflc7W4OjDMdQXj+EO9YOg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Henry Wang <Henry.Wang@xxxxxxx>
  • Delivery-date: Mon, 24 Oct 2022 10:22:56 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 24.10.2022 12:03, Julien Grall wrote:
> Hi Jan,
> 
> On 24/10/2022 08:26, Jan Beulich wrote:
>> On 22.10.2022 17:30, Julien Grall wrote:
>>> Is this intended for 4.17?
>>
>> Well, yes, it was meant to be - it has been ...
>>
>>> On 09/09/2022 15:30, Jan Beulich wrote:
>>
>> ... well over a month since it was sent.
>>
>>>> --- a/xen/arch/x86/sysctl.c
>>>> +++ b/xen/arch/x86/sysctl.c
>>>> @@ -157,7 +157,7 @@ long arch_do_sysctl(
>>>>            long (*fn)(void *);
>>>>            void *hcpu;
>>>>    
>>>> -        switch ( op )
>>>> +        switch ( op | -(CONFIG_NR_CPUS == 1) )
>>> This code is quite confusing to read and potentially risky as you are
>>> are relying the top bit of 'op' to never be 1. While I am expecting this
>>> will ever be the case, this will be a "fun" issue to debug if this ever
>>> happen. So I would suggest to check CONFIG_NR_CPUS == 1 separately.
>>
>> You're aware that we use this pattern in a few other places already (I
>> guess in my local tree I have one or two which aren't upstream yet)? Just
>> grep for "switch[^_].*[|]" to see them.
> 
> I could only spot two upstream in arch/x86/hvm/svm/svm.c and 
> arch/x86/hvm/vmx/vmx.c.
> 
> But I am not convinced this is a good enough reason to continue to use 
> this approach. There are a few bad code examples in Xen and we have been 
> pushing against continue to spread certain construct.

Sure. But these were introduced consciously and deliberately, iirc.

>> Also note that it's not just the
>> top bit of "op" - we merely assume "op" will never be ~0.
> Yes, I misread the code.
> 
>> Personally I
>> prefer this way of coding the logic, but if at least one of the other x86
>> maintainers agreed with you, I'd be okay to switch to using a separate
>> if().
> 
> I am curious why, is it just a matter of taste?

I think so. It's not written down anywhere that such constructs should
not be used.

> If you really want to go down this route, then I think you should add 
> "ASSERT(op != ~0U);" to catch someone introducing a value match that one 
> we exclude.

No, such an assertion would be checking user input; a caller might
deliberately pass this (invalid) value.

Jan



 


Rackspace

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