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

Re: [PATCH 2/2][4.15?] x86: fix build when NR_CPUS == 1


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Mon, 1 Mar 2021 19:00:22 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.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-SenderADCheck; bh=UcG1mWCLe/SWiqsP06+QG1dmbGdRnRy4uXk+hjWYqmY=; b=LtInf6fXzmihb1zZlykvhXUCirQ/7pxoVrGn27TOWYOU9w6miqqhcDPjnAgqTXpOT3wHzLO+sbK2+swYms430dBqqwYublNib0VzFsb7X2qwsRxranThk5/iMpvFk5Si7lBkaljudWXQTCRsNvnmGao1UadChMwZzCRaQhoI3fgnRCrJkJi5ZCtBAZRH9V60H5bIzvoTuPVkBrDUKozaEzPtp4hBtdfAC4qLA+NBY4DxqdaLC8O/4nCHZOc8BNFBIo0BSKYgOG0h8/SFyUbGFEEczkGof9JGiKMpLcdQdrRe3mgnibGXnQOzwUksc9fsBvbVVUmaE9InKfXBO2sxrg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RkyanwfCvnNHVLb0BFyA/zahEPqaIOs8pPtD+WfC/N6kSAfctB2CVz17L+r+9qdWBwlneNK5Ah7jinYFXwbW/Pt7fJ9HLfL0OqQuyETlYTLfWit7HOZRAmIMznS6Grt6ZO7z3ixFfbU/KTAMpOsSXxFp/mbZ5GuxKFTv++u3CZ9zxw+lILJeQW/Asei3aUtR2KD9bg1GjaZY4zX0x7Uzx4FnpVD/XIle0UpCTWbixyhRdtvkr1EJ9o4OHwtspAj2cK3DWOoqWVPjkFcFRoBP1zFdzSzUnLZIz5Kr2EFIQ9TkqCu+gDbE1HMlxk7PdjF6dB0csrC5C341UwB0FnN9RA==
  • Authentication-results: esa4.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>
  • Delivery-date: Mon, 01 Mar 2021 18:00:35 +0000
  • Ironport-sdr: J9oxg10ClAMHhvD9nQD78YW+e5e3SZ4p9xmQNwOl3ix0B1jxZfCdVC2GglV6JWR4FniOgjGPfJ Nq6vVtwlY0tdKW/y6FY2uq967BjQv6igkal11219cC38bXqDHId4CM8IjE5ZhYTPsnFBYET/Wh typR+LiPrBKAYFjA8MaUf915fOyhR6Himxkwey5/x8dKf2fZfWR6ZmGsYHu0BZQt6zvXmc7SZ1 4o7JlD8TfAWXixDoBn0NXbtr3/aL1xazSNS2O5ciSVuRzltFa/yy2rqUSwJg2c0fCobHTcG771 iPc=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Mon, Mar 01, 2021 at 04:14:26PM +0100, Jan Beulich wrote:
> On 01.03.2021 15:01, Roger Pau Monné wrote:
> > On Mon, Mar 01, 2021 at 09:31:07AM +0100, Jan Beulich wrote:
> >> In this case the compiler is recognizing that no valid array indexes
> >> remain (in x2apic_cluster()'s access to per_cpu(cpu_2_logical_apicid,
> >> ...)), but oddly enough isn't really consistent about the checking it
> >> does (see the code comment).
> > 
> > I assume this is because of the underlying per_cpu access to
> > __per_cpu_offset using cpu as the index, in which case wouldn't it be
> > better to place the BUG_ON there?
> 
> Not sure, to be honest. It seemed more logical to me to place it
> next to where the issue is.

I'm not sure whether I would prefer to place it in per_cpu directly to
avoid similar issues popping up in other parts of the code in the
future?

Maybe that's not likely. TBH it seems kind of random to be placing
this BUG_ON conditionals to make the compilers happy, but maybe
there's no other option.

> > Also I wonder why the accesses the same function does to the per_cpu
> > area before the modified chunk using this_cpu as index don't also
> > trigger such warnings.
> 
> The compiler appears to be issuing the warning when it can prove
> that no legitimate index can make it to a respective use. in this
> case it means that is is
> 
>         if ( this_cpu == cpu )
>             continue;
> 
> which makes it possible for the compiler to know that what gets
> past this would be an out of bounds access, since for NR_CPUS=1
> both this_cpu and cpu can only validly both be zero. (This also
> plays into my choice of placement, because it is not
> x2apic_cluster() on its own which has this issue.)

I see, thanks for the explanation. It makes me wonder whether other
random issues like this will pop up in other parts of the code. We
should have a gitlab build with NR_CPUS=1 in order to assert we don't
regress it. Speaking for myself I certainly won't be able to detect
whether something broke this support in the future.

Thanks, Roger.



 


Rackspace

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