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

Re: [PATCH 1/2] x86/mm: avoid phys_to_nid() calls for invalid addresses


  • To: Wei Chen <Wei.Chen@xxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 14 Dec 2022 08:44:42 +0100
  • 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=qq3IpAcUi72TvglG7aCmx0LlJl/vlgVF+F4dXcQsL1o=; b=GVBDmhnuz6OL82zMT0nMfbsSPnCW5Uw1WI5wqTFOBQGv4xERV5A1FrP1pmAcuxkfB+QtV0SkJp4FQ83/u2EwsBSSdXU+CEBJPV/t2YygZzHC/TGvRM5rXZDsa7HJWhBMA1vKExg1osu/WsnhXW3nz/7b8BCjzE/J5KaCVyf80gIqjs1c3l139op77qCFozNAnPWoqERoLBLltJj5F/Qo5y+k0lBOH5Mvo/31OjhpqH9pBzjHxZdDeDIs0/AonK9clT8wTlianeMe/ylYn1rbb4bPlW6QieKZnzubnBxj7UOTrJEOkYDomOPubeDlnV8IIOlTZJ2cnoIglHh5uL5q+w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=if9uVh8Z79jsjrcOaPHubA+OGJ42bslQ2Hy/8vP8veEjywAoRxVOBvTjQOH66WkKQ2ztvWrMBgxtAkb2aotIhtfS6+4G57/812f2OMjEx0X2ccMoND8OtuOWLF2gPL1372dOzqFKEvJGAnQK81imieeSlOOeIFTE0GWz0Hu6K0aXsqt+qW/gfejCc88MIlIouCNov1hj/M5dcg1RKy9ERIRkqtBaP1r9hiBUIW9o2EEuoTDKZD/5sGXigDPA0brs6ekbeDfmpza5TEb0BXEzLYRXLcYHE131ejvkLZ2XWaDQ106CGfFgGFsG5xc6obdZEmGHfuvwQZnDK7vm3FRVAA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Wed, 14 Dec 2022 07:44:51 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 14.12.2022 04:28, Wei Chen wrote:
> Hi Jan,
> 
> On 2022/12/13 19:36, Jan Beulich wrote:
>> With phys_to_nid() now actively checking that a valid node ID is on
>> record, the two uses in paging_init() can actually trigger at least the
>> 2nd of the assertions there. They're used to calculate allocation flags,
>> but the calculated flags wouldn't be used when dealing with an invalid
>> (unpopulated) address range. Defer the calculations such that they can
>> be done with a validated MFN in hands. This also does away with the
>> artificial calculations of an address to pass to phys_to_nid().
>>
>> Note that while the variable is provably written before use, at least
>> some compiler versions can't actually verify that. Hence the variable
>> also needs to gain a (dead) initializer.
>>
>> Fixes: e9c72d524fbd ("xen/x86: Use ASSERT instead of VIRTUAL_BUG_ON for 
>> phys_to_nid")
>> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
>> ---
>> RFC: With small enough a NUMA hash shift it would still be possible to
>>       hit an SRAT hole, despite mfn_valid() passing. Hence, like was the
>>       original plan, it may still be necessary to relax the checking in
>>       phys_to_nid() (or its designated replacements). At which point the
>>       value of this change here would shrink to merely reducing the
>>       chance of unintentionally doing NUMA_NO_NODE allocations.
>>
> 
> I think it's better to place the last sentence or the whole RFC to the
> commit log. Without the RFC content, after a while, when I check this 
> commit again, I will be confused about what problem this commit solved. 
> Because just looking at the changes, as your said in RFC, it doesn't 
> completely solve the problem.

Moving some/all of this to the commit message is one of the ways to
resolve this RFC, yes. But the other one, flipping the order of the
two patches and making mfn_to_nid() check less than page_to_nid() is
one where the commit message here would need re-writing anyway. IOW
the primary question here is what route to go.

Jan



 


Rackspace

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