[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] x86/NUMA: improve memnode_shift calculation for multi node system
- To: Jan Beulich <jbeulich@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
- Date: Fri, 30 Sep 2022 11:54:49 +0000
- Accept-language: en-GB, en-US
- 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=8YYF/cnDZqENZwZKC0XF58Oanh/6Pdqhed9NsNBsj04=; b=fO/OaoSucwEcNUWyrMjuawSJQMGYExhdx+BIxuT1MeIc1z0r368/RUd5FHhnSlPWssrxuYDyFKJ8IwOOlfwiEzmmEjSipXBqqeffIXtD0wH0JyVO3s0WDYJD5ruI3VHw30oQ+kIPyDJ+nVs+00fcJNRNH4+HQ/XncL/PHu+TBhCSNxYq0YxL6uf/WSc42i0HvTYB1ztF5Oe6zwfLKepdOBVWtL8QWJ0MiONnsFTCWnme2IpEO7SSysyWkR0up/aD7E401lT7Y3a6zxqDmpTbn9M4eWwYSYGidc+s2l6mQHHNj2KlMT3DbDFNgTVz4sXpso2JGwpH9xTXEABI/6U0mQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ngy22XyzvK9eZZG0QekNFveK6INVQS4Bo/6oEPeU/0I8S0j3KMdOHrQwDVZ40TSYPVt5KQyh1+bbA80nrSyr31G2ntpyWMWBgJp2jFR5mUIO7420Q7lUOz/Zx/dWE5df/MRzqHincij5W470NLi+xGSFxBa6G88fLFBlRVcCACdMFZK7xz94V4w+g+5m/TPzK5mArU0RsoilMZts5Slv2C1vHzM3K/xRJUv1iX34opvVnRNbeUe72HpiU04DtVo2DRxKasJRR738Ln+j3n6KVn6AmU4yb6/bsrAvwm3i9NvgnjPsEr92aGjdRagVGNx+Mqmc3UP1ZevDrMV6AchROA==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
- Cc: Wei Liu <wl@xxxxxxx>, Roger Pau Monne <roger.pau@xxxxxxxxxx>
- Delivery-date: Fri, 30 Sep 2022 11:55:09 +0000
- Ironport-data: A9a23:5wbYuK5NG9dZ08cUEO3JtgxRtB7GchMFZxGqfqrLsTDasY5as4F+v mAYCj/UPfaINzbxe9h0boy+phkPup/Wyt9iG1drq3tkHi5G8cbLO4+Ufxz6V8+wwm8vb2o8t plDNYOQRCwQZiWBzvt4GuG59RGQ7YnRGvymTras1hlZHWdMUD0mhQ9oh9k3i4tphcnRKw6Ws Jb5rta31GWNglaYCUpJrfPYwP9TlK6q4mlA7wdmPaojUGL2zBH5MrpOfcldEFOgKmVkNrbSb /rOyri/4lTY838FYj9yuu+mGqGiaue60Tmm0hK6aYD76vRxjnVaPpIAHOgdcS9qZwChxLid/ jnvWauYEm/FNoWU8AgUvoIx/ytWZcWq85efSZSzXFD6I+QrvBIAzt03ZHzaM7H09c5qWiJQy 6MXMgtTawzev/71xZmkb8Vj05FLwMnDZOvzu1lG5BSAVbMDfsqGRK/Ho9hFwD03m8ZCW+7EY NYUYiZuaxKGZABTPlAQC9Q1m+LAanvXKmUE7g7K4/dqpTGLl2Sd05C0WDbRUvWMSd9YgQCzo WXe8n6iKhobKMae2XyO9XfEaurnzXqgBdhLROPQGvhCgh6a6TcxJ0ctf3ySodiBsFOeXIoYN BlBksYphe1onKCxdfH/VRClpH+PvjYHRsFdVeY97Wml2qfSpgqUGGUAZjpAc8A98t87QyQw0 V2ElM+vAiZg2JWKTVqN+7HSqim9URX5NkcHbC4ACA4aud/qpdhrigqVF444VqmoktfyBDf8h SiQqzQzjKkSishN0Lin+VfAgHSnoZ2hohMJ2zg7l1mNtmtRDLNJraTxgbQHxZ6s9Lqkc2Q=
- Ironport-hdrordr: A9a23:vYNqP6jquAoKSQ6VbxMRtT4TY3BQX3l13DAbv31ZSRFFG/FwyP rCoB1L73XJYWgqM03IwerwQ5VpQRvnhP1ICRF4B8buYOCUghrTEGgE1/qv/9SAIVy1ygc578 tdmsdFebrN5DRB7PoSpTPIa+rIo+P3v5xA592uqUuFJDsCA84P0+46MHfjLqQcfnglOXNNLu v52iMxnUvERZ14VKSGL0hAe9KGi8zAlZrgbxJDLQUg8hOygTSh76O/OwSE3z8FOgk/gIsKwC zgqUjU96+ju/a0xlv3zGnI9albn9Pn159qGNGMsM4IMT/h4zzYJLiJGofy/wzdktvfrWrCo+ O85yvI+P4DrE85S1vF4ycFHTOQlgrGpUWSkGNwykGT3PARDAhKd/apw7gpPCcxonBQwu2Vms hwrh2knosSAhXakCvn4d/UExlsi0qvuHIn1fUelnpFTOIlGfZsRKEkjTRo+a07bVTHwZFiFP MrANDX5f5Qf1/fZ3fFvnN3yNjpWngoBB+JTkULp8TQilFt7TtE5lpdwNZakmYL9Zo7RZUB7+ PYMr5wnLULSsMNd6pyCOoIXMPyAG3QRhDHNn6UPD3cZek6EmOIr4Sy7KQ+5emsdpBNxJwumI 7ZWFcdrmI2c1KGM7z74HSKyGG5fIyQZ0Wf9igF3ekJhlTVfsuaDQSTDFYzjsCnv/ITRsXGRv fbAuMlP8Pe
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Thread-index: AQHY0o0ZBOomZIkt5kiwNmpgdKrIoa334ciA
- Thread-topic: [PATCH] x86/NUMA: improve memnode_shift calculation for multi node system
On 27/09/2022 17:20, Jan Beulich wrote:
> --- a/xen/arch/x86/srat.c
> +++ b/xen/arch/x86/srat.c
> @@ -413,14 +414,37 @@ acpi_numa_memory_affinity_init(const str
> node, pxm, start, end - 1,
> ma->flags & ACPI_SRAT_MEM_HOT_PLUGGABLE ? " (hotplug)" : "");
>
> - node_memblk_range[num_node_memblks].start = start;
> - node_memblk_range[num_node_memblks].end = end;
> - memblk_nodeid[num_node_memblks] = node;
> + /* Keep node_memblk_range[] sorted by address. */
> + for (i = 0; i < num_node_memblks; ++i)
> + if (node_memblk_range[i].start > start ||
> + (node_memblk_range[i].start == start &&
> + node_memblk_range[i].end > end))
> + break;
> +
> + memmove(&node_memblk_range[i + 1], &node_memblk_range[i],
> + (num_node_memblks - i) * sizeof(*node_memblk_range));
> + node_memblk_range[i].start = start;
> + node_memblk_range[i].end = end;
> +
> + memmove(&memblk_nodeid[i + 1], &memblk_nodeid[i],
> + (num_node_memblks - i) * sizeof(*memblk_nodeid));
> + memblk_nodeid[i] = node;
This is now the 4th example we have of logic wanting a sorted array.
(two examples in ARM code which want to switch away from using sort(),
and the VMX MSR lists).
I was already contemplating doing a small library (static inline, or
perhaps extern inline now we've started using that) to abstract away the
insert/find/delete operations and their decidedly non-trivial pointer
operations.
The secondary purpose was to be able to do some actual unit tests of the
library, so we can be rather better assured of correctness.
For this case, and the two ARM cases, the firmware data is supposed to
be sorted to begin with, so the search-for-insertion loop should look at
the num_node_memblks entry first because the overwhelming common case is
that the end is the correct place to put it. If not, it should binary
search backwards rather than doing a linear search.
Obviously not work for 4.17, but there's a lot of value in such a library.
~Andrew
|