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

Re: [PATCH] x86/NUMA: correct memnode_shift calculation for single node system


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 27 Sep 2022 18:08:17 +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=s2OGboVq3PfQxxwhvFOy0FoahiAPxk8VGhf5ESu5kZo=; b=nn7LGK2hrIjOS0jdB2y4MTWtN7SjDrGx655SGVDSChoiCk7FLqFGn5hGAYRm5w1pnbEaEUO4o4/L2kAa7ZR3ubrAh4DtZxRtL4s0veBY2Hx8g3Qud4BNHFz/aZ0HgjEDowy0w9U4lmjdy6Qu25QhZpYeBbOFLrXt90sjvhdvsIMMY5IQEGUgbT4I8PCH2m2qZHhXxlCsCmvKn0k5ST1zQ2YH7tZlQ3iddqYuSEfpLstnZgBlARfwYYCpGXH6+FbT7zLZzUGuaHikW0SzSsoIFNq95gb9XvY9cXx1/h17U8HaU+Ka0s7zGpUQnsbv77i/v2rXCkCRQDNKHa7qjU0yEw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HEMwUGSI834N9Oe7xPlHaXsPeo+hy9zzIlc2qULKtmEWpfYfLsX/me/fw0lVHE2kVO9M+kL0gNYDIpa/6iEuWbnJ7sN9nuDrgRNtK9bZ6CyiuBmzPAw4ffOHiMMHes6pLBafRz3V9/0WfsHmSjqZAin3PiHI2zyz4tlC6FNfPQBUTdsRpnGARA9QsG2Ka6KYWaOcEGXQu3eDBw4kkKWhM4t8NeGX0PhI4wW4MAzi1k98UqT1oAtyULTs0iijg4LsiFwc6HRC1qMtQCTEZR9O0YuZP20NNk+OZLoMaE4L7MxgQd6sqQusR/ETSTVf/MPQHk7MC6YtWVDTM+ne76uphA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Tue, 27 Sep 2022 16:08:28 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 27.09.2022 17:53, Roger Pau Monné wrote:
> On Tue, Sep 27, 2022 at 04:15:19PM +0200, Jan Beulich wrote:
>> SRAT may describe even a single node system (including such with
>> multiple nodes, but only one having any memory) using multiple ranges.
>> Hence simply counting the number of ranges (note that function
>> parameters are mis-named) is not an indication of the number of nodes in
>> use. Since we only care about knowing whether we're on a single node
>> system, accounting for this is easy: Increment the local variable only
>> when adjacent ranges are for different nodes. That way the count may
>> still end up larger than the number of nodes in use, but it won't be
>> larger than 1 when only a single node has any memory.
>>
>> To compensate populate_memnodemap() now needs to be prepared to find
>> the correct node ID already in place for a range. (This could of course
>> also happen when there's more than one node with memory, while at least
>> one node has multiple adjacent ranges, provided extract_lsb_from_nodes()
>> would also know to recognize this case.)
>>
>> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> 
> Acked-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>

Thanks.

>> --- a/xen/arch/x86/numa.c
>> +++ b/xen/arch/x86/numa.c
>> @@ -78,7 +78,8 @@ static int __init populate_memnodemap(co
>>          if ( (epdx >> shift) >= memnodemapsize )
>>              return 0;
>>          do {
>> -            if ( memnodemap[spdx >> shift] != NUMA_NO_NODE )
>> +            if ( memnodemap[spdx >> shift] != NUMA_NO_NODE &&
>> +                 (!nodeids || memnodemap[spdx >> shift] != nodeids[i]) )
>>                  return -1;
>>  
>>              if ( !nodeids )
>> @@ -114,7 +115,7 @@ static int __init allocate_cachealigned_
>>   * maximum possible shift.
>>   */
>>  static int __init extract_lsb_from_nodes(const struct node *nodes,
>> -                                         int numnodes)
>> +                                         int numnodes, const nodeid_t 
>> *nodeids)
>>  {
>>      int i, nodes_used = 0;
>>      unsigned long spdx, epdx;
>> @@ -127,7 +128,7 @@ static int __init extract_lsb_from_nodes
>>          if ( spdx >= epdx )
>>              continue;
>>          bitfield |= spdx;
>> -        nodes_used++;
>> +        nodes_used += i == 0 || !nodeids || nodeids[i - 1] != nodeids[i];
> 
> I think I would also prefer the `if ( ... ) nodes_used++;` form, as
> it's clearer.

Okay, will switch then. This isn't for 4.17 anyway (I think), so
there's no rush.

Jan



 


Rackspace

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