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

RE: [PATCH v4 7/8] xen/x86: add detection of memory interleaves for different nodes


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Wei Chen <Wei.Chen@xxxxxxx>
  • Date: Thu, 2 Jun 2022 02:20:10 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=2; 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=q+Qp4/v8H8bsT09zM7B9CbaKi4RLdX9Cv22MapYeN20=; b=GrSnUPFBmwEh9c8AzZRJ3kOzXLE+rIbyLQfqwzzkcmTRqjTgd4OTNV6BchnxDV6uBQ6/5z+19dyDeiewQfiHp/kj1E4aYiWkEwWjFFQEpICONHDQNKqhO6N49lqIZyVO8aVTctdRHj4BZuegwhj4a0baaks5kVERXvkLbYqMnkdD6jNznA5WOxvJK6y6fOElsw67EOc17qAnYbQIbUzBnE+FsV+TPOgvVSOBdbSmRT3lSqW5N2agJW7izclq+3y8TinfGIhvlhZx22rHpbkT63gbmGykA/lf8Pzo67r5pb0QGYAzZ8RR3Mi8eC8Po9hWMNpRc68+o47yTTsPb6qNQA==
  • 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=q+Qp4/v8H8bsT09zM7B9CbaKi4RLdX9Cv22MapYeN20=; b=DEr7qTKLdI8Y22R2gEtM8ervJHWLfAYLLApRi0Kg3NcQ5L2AzqGoF9sHMwNAOAP5bJFMJERxR7PlELGQmygrmE3ngsE/QBClwVyzQKEyyQgUFOzX7oxWFQrxwDePQaLrzuYTWUvtfNoTAAyISmVGVJk3t8M5CmegORGusFUcQU+FFBWTgRF4i69YRBkM/dYHxWVo+AlhrphCl9AZ4Me2EUdLRxJM/XrDMl9DnLO+Oso9hQekey4v4yfWzcgiRn0UvpHksAnZRjj6/TJ1KhT6G7wmow/UsvWkpF36rEJ+jhll2ueOARz1pyx/THqWvTNC87MTHpzkmvl2puOoqdBCRw==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=XNIUFDHEdl1sf1ATyYPQ+i820HplWGITl8+2X54eC1lkT3SXm6dpdS3NXo1fcdX6C5jckUpyWyWWJLXDYiEGy7SRuhRKekbBQyk3MQMHdYx74TenmG5ayBMNqTMxNUE0KTiwz/bZ/qJ60MpCtplrAd6e6Q1ETYdwsaDZkL8SaVS3X18eL5f8bSTgUmO7A1vYKX0XzACGOiSRMVenAINTtj4H2NzbdthWP48v7tYxT3HeYGXuFEQVDpNTeUo3Z/rUCx9RXeSmcojZLkQ4qmGPlUED0V+a3swvnErJa30rx1AJngIuPB2hX0hoHTSKNWBHeboJHnTHjGq1UhZ3dQbkJg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZzkIe8zEFo79kvIBjrjv9Fqx6rdvoeAQBBzXjb0vbg3Hzd4vLUqsvwfoLQ48Mp1DX4e14npMIYeLxio+N7KyTvdCh20hBz6luoizL6K4GSChdH2z9XP40uqfSSB2zvGAfgXg6CJdv4ZSwDCR/Hbpdn5moxii4aHhe2rUDdW77A5aV2CDlAq0xTTj2QFOpCEhRStsWumcONd3XCxacYUKX2Ftaw/RW09sE/6mY02InYK4rdL9qdDGx4xM9yufJfO0mWYzuEBxT4lk26nC9WAo+0LzNFq8mNIZG9mz8xlT3auD7KdaT5Q6/Z9ot9Bf3HO2o6cyLzJv9HcEvueowyexNw==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: nd <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" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 02 Jun 2022 02:20:32 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHYbm4HiKDL321oiEuXmbKNpj1MH605Bc8AgADVNxCAAErZgIABQrBA
  • Thread-topic: [PATCH v4 7/8] xen/x86: add detection of memory interleaves for different nodes

Hi Jan,

> -----Original Message-----
> From: Jan Beulich <jbeulich@xxxxxxxx>
> Sent: 2022年6月1日 14:32
> To: Wei Chen <Wei.Chen@xxxxxxx>
> Cc: nd <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
> Subject: Re: [PATCH v4 7/8] xen/x86: add detection of memory interleaves
> for different nodes
> 
> On 01.06.2022 04:53, Wei Chen wrote:
> >> From: Jan Beulich <jbeulich@xxxxxxxx>
> >> Sent: 2022年5月31日 21:21
> >>
> >> On 23.05.2022 08:25, Wei Chen wrote:
> >>> @@ -119,20 +125,45 @@ 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, unsigned int *mblkid)
> >>>  {
> >>> - int i;
> >>> + unsigned 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;
> >>> +
> >>> +         /* Skip 0 bytes node memory block. */
> >>>           if (nd->start == nd->end)
> >>>                   continue;
> >>> +         /*
> >>> +          * Use memblk range to check memblk overlaps, include the
> >>> +          * self-overlap case.
> >>> +          */
> >>>           if (nd->end > start && nd->start < end)
> >>> -                 return i;
> >>> +                 return OVERLAP;
> >>>           if (nd->end == end && nd->start == start)
> >>> -                 return i;
> >>> +                 return OVERLAP;
> >>
> >> Knowing that nd's range is non-empty, is this 2nd condition actually
> >> needed here? (Such an adjustment, if you decided to make it and if not
> >> split out to a separate patch, would need calling out in the
> >> description.)
> >
> > The 2nd condition here, you meant is "(nd->end == end && nd->start ==
> start)"
> > or just "nd->start == start" after "&&"?
> 
> No, I mean the entire 2nd if().
> 

OK.

> >>> +         /*
> >>> +          * Use node memory range to check whether new range contains
> >>> +          * memory from other nodes - interleave check. We just need
> >>> +          * to check full contains situation. Because overlaps have
> >>> +          * been checked above.
> >>> +          */
> >>> +         if (nid != memblk_nodeid[i] &&
> >>> +             (nd_start < nd->start && nd->end < nd_end))
> >>> +                 return INTERLEAVE;
> >>
> >> Doesn't this need to be <= in both cases (albeit I think one of the two
> >> expressions would want switching around, to better line up with the
> >> earlier one, visible in context further up).
> >>
> >
> > Yes, I will add "="in both cases. But for switching around, I also
> > wanted to make a better line up. But if nid == memblk_nodeid[i],
> > the check of (nd_start < nd->start && nd->end < nd_end) is meaningless.
> > I'll adjust their order in the next version if you think this is
> > acceptable.
> 
> I wasn't referring to the "nid != memblk_nodeid[i]" part at all. What
> I'm after is for the two range checks to come as close as possible to
> what the other range check does. (Which, as I notice only now, would
> include the dropping of the unnecessary inner pair of parentheses.)
> E.g. (there are other variations of it)
> 
>               if (nid != memblk_nodeid[i] &&
>                   nd->start >= nd_start && nd->end <= nd_end)
>                       return INTERLEAVE;
> 

Oh, thanks. I had thought too much, I will drop them.

> >>> @@ -275,10 +306,13 @@ acpi_numa_processor_affinity_init(const struct
> >> acpi_srat_cpu_affinity *pa)
> >>>  void __init
> >>>  acpi_numa_memory_affinity_init(const struct acpi_srat_mem_affinity
> *ma)
> >>>  {
> >>> + enum conflicts status;
> >>
> >> I don't think you need this local variable.
> >>
> >
> > Why I don't need this one? Did you mean I can use
> > switch (conflicting_memblks(...)) directly?
> 
> Yes. Why could this not be possible?
> 

Ok.

> >>>                  node_memblk_range[i].start, node_memblk_range[i].end);
> >>>           bad_srat();
> >>>           return;
> >>>   }
> >>> - if (!(ma->flags & ACPI_SRAT_MEM_HOT_PLUGGABLE)) {
> >>> -         struct node *nd = &nodes[node];
> >>>
> >>> -         if (!node_test_and_set(node, memory_nodes_parsed)) {
> >>> -                 nd->start = start;
> >>> -                 nd->end = end;
> >>> -         } else {
> >>> -                 if (start < nd->start)
> >>> -                         nd->start = start;
> >>> -                 if (nd->end < end)
> >>> -                         nd->end = end;
> >>> -         }
> >>> + default:
> >>> +         break;
> >>
> >> This wants to be "case NO_CONFLICT:", such that the compiler would
> >> warn if a new enumerator appears without adding code here. (An
> >> alternative - which personally I don't like - would be to put
> >> ASSERT_UNREACHABLE() in the default: case. The downside is that
> >> then the issue would only be noticeable at runtime.)
> >>
> >
> > Thanks, I will adjust it to:
> >     case NO_CONFLICT:
> >             break;
> >     default:
> >             ASSERT_UNREACHABLE();
> > in next version.
> 
> As said - I consider this form less desirable, as it'll defer
> noticing of an issue from build-time to runtime. If you think that
> form is better, may I ask why?
> 

Ok. I will drop the default. I had mis-understood your comment.

> Jan


 


Rackspace

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