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

Re: [PATCH v3 8/9] xen/x86: add detection of memory interleaves for different nodes


  • To: Wei Chen <wei.chen@xxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 18 May 2022 15:30:37 +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=UZwWP9WKr1TiKnBhwsqjwfLpGJEuh48drxaM7ZB8l/Y=; b=CUTZc+rOwsuhVLQcTaSI94Gss/FVqq+KdidzejrU58u7PTy/vgsvbicsJP/RFNTAfJUNtPLyYYyNMUG2JouFjyn4bKsnTI2jxU19oHWyusIOewjicB9nuXj0JHoKTe8hGZQwWn0PAu3Mbyt56egJ/GSXN6T1bN2fP1/x2Zo/Oi6FbWbTEawrT1s/WMo3ZTqA/lO1a4lP6ibTv1WrXhDxoJM/BuCVnxM40lmDZp7VHyLdE6YlzNEkc9MOIOXPn03k5zsJTcYyvJudqkSaRqyrb1PLLA/NsUOzyMJxmCO7nXWOvtlJqb/C6GHg9+ekPjyKho7zYsfc9oI7LG9BBHzVhw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YId4uIYxx2j2dIf1xAtJVlpawz8ou4yvFfG5GAR+g1t+fbb5ftqHZ3guq73PUanI0r32qBl+udXk7KjVteCl0NbHZw6BTH8VEnMbPtwhEJwX0UOr1DwW+g6eUPBIiBtc2h0i9AqDOhWUT61gGNFg5yhmkj7wtKVtmFfc9PQTRt/VhHfR/F3bgLhW29DMnijVjBKUWIN2cIPbPxgVoctk8DsJO/lhMUSXV6x2kJ547jE6mJDhjo82MZCZzPcvU3HnB11NIKyZFspc7thowiDhVgZENxmGKA/Tb5zoXR2q7zTjiPyfFCf0zYHQI24j/ZsuDZmEkpHTf+UYVJXIMkoBSQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: nd@xxxxxxx, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Jiamei Xie <jiamei.xie@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Wed, 18 May 2022 13:30:49 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 11.05.2022 03:46, Wei Chen wrote:
> --- a/xen/arch/x86/srat.c
> +++ b/xen/arch/x86/srat.c
> @@ -42,6 +42,12 @@ static struct node node_memblk_range[NR_NODE_MEMBLKS];
>  static nodeid_t memblk_nodeid[NR_NODE_MEMBLKS];
>  static __initdata DECLARE_BITMAP(memblk_hotplug, NR_NODE_MEMBLKS);
>  
> +enum conflicts {
> +     NO_CONFLICT = 0,

No need for the "= 0".

> +     ERR_OVERLAP,

While this at least can be an error (the self-overlap case is merely
warned about), ...

> +     ERR_INTERLEAVE,

... I don't think this is, and hence I'd recommend to drop "ERR_".

> @@ -119,20 +125,43 @@ int valid_numa_range(paddr_t start, paddr_t end, 
> nodeid_t node)
>       return 0;
>  }
>  
> -static __init int conflicting_memblks(paddr_t start, paddr_t end)
> +static enum conflicts __init
> +conflicting_memblks(nodeid_t nid, paddr_t start, paddr_t end,
> +                 paddr_t nd_start, paddr_t nd_end, int *mblkid)

Why "int"? Can the value passed back be negative?

>  {
>       int i;
>  
> +     /*
> +      * Scan all recorded nodes' memory blocks to check conflicts:
> +      * Overlap or interleave.
> +      */
>       for (i = 0; i < num_node_memblks; i++) {
>               struct node *nd = &node_memblk_range[i];
> +             *mblkid = i;

Style: Please maintain a blank line between declaration(s) and
statement(s).

> @@ -310,42 +342,67 @@ acpi_numa_memory_affinity_init(const struct 
> acpi_srat_mem_affinity *ma)
>               bad_srat();
>               return;
>       }
> +
> +     /*
> +      * For the node that already has some memory blocks, we will
> +      * expand the node memory range temporarily to check memory
> +      * interleaves with other nodes. We will not use this node
> +      * temp memory range to check overlaps, because it will mask
> +      * the overlaps in same node.
> +      *
> +      * Node with 0 bytes memory doesn't need this expandsion.
> +      */
> +     nd_start = start;
> +     nd_end = end;
> +     nd = &nodes[node];
> +     if (nd->start != nd->end) {
> +             if (nd_start > nd->start)
> +                     nd_start = nd->start;
> +
> +             if (nd_end < end)

Did you mean nd->end here on the right side of < ? By intentionally
not adding "default:" in the body, you then also allow the compiler
to point out that addition of a new enumerator also needs handling
here.

> +                     nd_end = nd->end;
> +     }
> +
>       /* It is fine to add this area to the nodes data it will be used later*/
> -     i = conflicting_memblks(start, end);
> -     if (i < 0)
> -             /* everything fine */;
> -     else if (memblk_nodeid[i] == node) {
> -             bool mismatch = !(ma->flags & ACPI_SRAT_MEM_HOT_PLUGGABLE) !=
> -                             !test_bit(i, memblk_hotplug);
> -
> -             printk("%sSRAT: PXM %u (%"PRIpaddr"-%"PRIpaddr") overlaps with 
> itself (%"PRIpaddr"-%"PRIpaddr")\n",
> -                    mismatch ? KERN_ERR : KERN_WARNING, pxm, start, end,
> -                    node_memblk_range[i].start, node_memblk_range[i].end);
> -             if (mismatch) {
> +     status = conflicting_memblks(node, start, end, nd_start, nd_end, &i);
> +     if (status == ERR_OVERLAP) {

Please use switch(status) when checking enumerated values.

> +             if (memblk_nodeid[i] == node) {
> +                     bool mismatch = !(ma->flags &
> +                                     ACPI_SRAT_MEM_HOT_PLUGGABLE) !=
> +                                     !test_bit(i, memblk_hotplug);

Style: The middle line wants indenting by two more characters.

> +
> +                     printk("%sSRAT: PXM %u (%"PRIpaddr"-%"PRIpaddr") 
> overlaps with itself (%"PRIpaddr"-%"PRIpaddr")\n",
> +                            mismatch ? KERN_ERR : KERN_WARNING, pxm, start,
> +                            end, node_memblk_range[i].start,
> +                            node_memblk_range[i].end);
> +                     if (mismatch) {
> +                             bad_srat();
> +                             return;
> +                     }
> +             } else {
> +                     printk(KERN_ERR
> +                            "SRAT: PXM %u (%"PRIpaddr"-%"PRIpaddr") overlaps 
> with PXM %u (%"PRIpaddr"-%"PRIpaddr")\n",
> +                            pxm, start, end, node_to_pxm(memblk_nodeid[i]),
> +                            node_memblk_range[i].start,
> +                            node_memblk_range[i].end);
>                       bad_srat();
>                       return;
>               }
> -     } else {
> +     } else if (status == ERR_INTERLEAVE) {
>               printk(KERN_ERR
> -                    "SRAT: PXM %u (%"PRIpaddr"-%"PRIpaddr") overlaps with 
> PXM %u (%"PRIpaddr"-%"PRIpaddr")\n",
> -                    pxm, start, end, node_to_pxm(memblk_nodeid[i]),
> +                    "SRAT: Node %u: (%"PRIpaddr"-%"PRIpaddr") interleaves 
> with node %u memblk (%"PRIpaddr"-%"PRIpaddr")\n",
> +                    node, nd_start, nd_end, memblk_nodeid[i],

Please log pxm (not node) here just like is done in the overlap case.
The remote node ID will then require converting to PXM, of course.

Jan




 


Rackspace

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