[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: Jan Beulich <jbeulich@xxxxxxxx>
- From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
- Date: Tue, 27 Sep 2022 17:53:08 +0200
- 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wVkphd21ENVtWsNYeVVgVUbFeR91ASK26PDzuyvoD+4=; b=fZUPPewzqRplyDOWiEHZCt8cMWMoRFAWB5ghv91ncwi/Af7u0glxAca/QfdNd+pqWqrWY6DNEeBsuSGxe4x8n4hVd6XNry0VbqIFuaoxAaYGmolE0uSsKT2tUw47mL2YMVPhdzoaM4+NVYkB1dl1eRb69mH2X0P+tOtrabwsJzdKMVN3WODootEJaYPNMB7GS6gD0kYpfv+fnv2UeEW+15zXepXRRdHiz+eU9eR9yW4m/KyBDvBK56IZWkExMMR3BRPyvvUU3BAKCQsgY/hi44YdR5J4VaiTJLmPjfLRPhvnFKnirwOel3iOBgTVVshMX6Ti/s4JFBqcGcP2HQXYRQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XuFZgtwDOe/qQq/QeAJnmiBsZy+q+08z18T/IYth2O5fX1hWeH7jw9cBSb53+B1INbL5Gg53CjvZ5SaVQ20/BSBafD2wxwmWdmEISBcA6vQqonhMoAb/bpPpYIEaFRpyYeK7N4mR8tovEfPSCI+YVNj6nhc0F3cfmoGTxamt+lZ6PmssnOXNc5xPjfoZIfsEwrtyyjdj+AvKqyqYhU/h11TW4aaeTsfUyz13DMyVd2DetoaX8sMn1vchMyTvtYFowWGQIimzFxUq40VtZMEhFOH+FU+JPzvc8jqFBXwOmVR5d7rB2luf2S0RSp7OxxaaWYhceOvaNq/y4EhHKkjrBw==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
- Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
- Delivery-date: Tue, 27 Sep 2022 15:53:24 +0000
- Ironport-data: A9a23:yLKQUa7tjpZl85vHaQQQLQxRtCPGchMFZxGqfqrLsTDasY5as4F+v moaWj3VOKuJN2b1L4x1Pti/9RkE75aGzoc3T1ZoqiBkHi5G8cbLO4+Ufxz6V8+wwm8vb2o8t plDNYOQRCwQZiWBzvt4GuG59RGQ7YnRGvymTras1hlZHWdMUD0mhQ9oh9k3i4tphcnRKw6Ws Jb5rta31GWNglaYCUpJrfPYwP9TlK6q4mlA7wZhPaojUGL2zBH5MrpOfcldEFOgKmVkNrbSb /rOyri/4lTY838FYj9yuu+mGqGiaue60Tmm0hK6aYD76vRxjnVaPpIAHOgdcS9qZwChxLid/ jnvWauYEm/FNoWU8AgUvoIx/ytWZcWq85efSZSzXFD6I+QrvBIAzt03ZHzaM7H09c5dDkZ31 fxBOQwob0i5o/P157ihTrdF05FLwMnDZOvzu1lG5BSAV7MMZ8CGRK/Ho9hFwD03m8ZCW+7EY NYUYiZuaxKGZABTPlAQC9Q1m+LAanvXKmUE7g7K4/dqpTGMkWSd05C0WDbRUsaNSshP2F6Ru 0rN/njjAwFcP9uaodaA2iL137eezHmrMG4UPLyA2sJa0EGi+mASCicabHiq++CCh1HrDrqzL GRRoELCt5Ma9kamU938VB2Qu2Ofs1gXXN84O/037kSBx7TZ5y6dB3MYVXhRZdo+rsg0SDc2k FiTkLvBGjhHoLCTD3WH+d+pQSiaPCEUKSoIY38CRA5cud37+ths01TIU8ppF7OzgpvtAzbsz juWrS84wbIOkcoM0Kb99lfC696xmqX0oscOzl2/dgqYAslRPuZJu6TABYDn0Mt9
- Ironport-hdrordr: A9a23:tHlep65Jr14yBfoqHQPXwVOBI+orL9Y04lQ7vn2ZFiY5TiXIra qTdaogviMc6Ax/ZJjvo6HkBEClewKlyXcT2/hrAV7CZniehILMFu1fBOTZowEIdxeOldK1kJ 0QCZSWa+eAcmSS7/yKhzVQeuxIqLfnzEnrv5a5854Ed3AXV0gK1XYcNu/0KDwVeOEQbqBJaa Z0q/A30QaISDAyVICWF3MFV+/Mq5nik4/nWwcPA1oC5BOVhT2lxbbmG1zAty1uGw9n8PMHyy zoggb57qKsv7WSzQLd7Xba69BzlMH6wtVOKcSQgow+KynqiCyveIN9Mofy9QwdkaWK0hIHgd PMqxAvM4Ba7G7QRHi8pV/X1wzpwF8Vmgrf4G7dpUGmjd3yRTo8BcYEr5leaAHl500pu8w5+L 5X3kqC3qAnQS/orWDY3ZzlRhtqnk27rT4JiugIlUFSVoMYdft4sZEfxkVIC50NdRiKpbzPKN MeQv002cwmMG9zNxvizylSKZ2XLz4O9y69Mwc/Upf/6UkUoJh7p3FotvD30E1wtq7VcKM0l9 gsAp4Y6o2mcfVmHJ6VJN1xNfdfWVa9Ni7kASa1HWnNMp0hFjbkl6PXiY9Fl91CPqZ4h6cPpA ==
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
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>
> ---
> On my Skylake system this changes memnodemapsize from 17 to 1 (and the
> shift from 20 to 63).
>
> --- 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.
Thanks, Roger.
|