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

RE: [PATCH v4 4/6] xen/x86: use arch_get_ram_range to get information from E820 map


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Wei Chen <Wei.Chen@xxxxxxx>
  • Date: Thu, 8 Sep 2022 14:55:11 +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=O+prVyg5c9zu9gczVOEkC80Uht3impG6KJztFkLvX9E=; b=jqtdpuZuAujDkfYTcbcttDWploKRc6RagZ3usccV05HVA0qmdmsgbYI/Fn9Yyf/7k0Dbzv7WLTgoVDx0lLQEtc08+7682jqtg+5k/kALFcaQvbjelenIoXFUxvi12HLEhpu6OESGvniCAqEQdkXLZdCmeUkpydJOwbWei8tsJjD/Y/ZS1wx0ETrRLWF9yYs1mVMj7X4qOEc+548T4cso7B7kIFvhlwrEMLOEYmEpHSMV9dq31tN31uE4RZmExy855xicDIMX/26XuoTi94DW/q7y5p/TfjO3lMV3kiYPAtAYRcQKDxMwzCPxRgjP3dHCD2F99YovhSOnUVC2iAMdwg==
  • 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=O+prVyg5c9zu9gczVOEkC80Uht3impG6KJztFkLvX9E=; b=dm/l/I47tQaJNZrshhtiCGysqH38YPk7gaREQfNFQ+eyLcNMOFs38riRAVe/x+SZJLY8pn8bnnGC/ebY68QUIZeK1zdu9gC8i5HAp8lTCCAT38fPUcIWE3iyKWxiVvIIeRTMFA+e2n+JHYbKfIgFzMrtYmscUWECzLmELtJVLCCKirNQsK+uCRdT1o1rJTr0YDeOIntQP+yoYecrbtUfkOmLdTqUy0oaxxTTf+BEjy2oPlQu8bu8gttYOSDWsqGIGM/lgo11IYc/40jCLFaFvYPQWyijyezW6rbWsRIujDg0Av64WU/O5fsrVCaakgHTFODEZRjK4W8Qp0Bs8ijARA==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=FFxhnZtCojwywSacuYDWJRHNlRIoLgCxNn3TCZxmCiE5Hox2dnrb9e0rtb6ePbiak1I92M6g0JZOz2jnpSquGMcAZnA2YERDazc2wG/yQF+ZkJOyJkm9a/4oXt/hlTE75cJl+2OuvUPNAdlch9187Szplg0y8LGYKb/0UWEkoM3ryY9/m+fILSbii0yqBnScttLJrC2XFuQX2H2QfepQczXULW89/ftKgbMaQ0FJ0D/yBo3We1XDHG3u6tYjNtzNkByHEYiQMSJHUAO8wtQLibwbIB2Ry4itvRLLeMnM5IzfPPSFAPBJddpmcfzT4dW+VQhSOuIj2lAamAK/ftV5oA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ayCO2PqHJSKrEZ54y237D9B9A1gyE649kpDRmvoa+0+GDgDG95MBLq+0lQwvkyBLEoQ0eFw18KSEbu+dM8+evPNSbz0dWDVw0y6wGcmwIS+3f/Xs/S32stRp5trl14CaYQDj4Ubv4ePwHELHSsUEzUp63EhVuqphmM4moap2N5KV/2Q0JUlR1v9Ac1GMn9N9/40agiehrIcE+Gm0X6WXcNkadn5E5YKheUCIh+qk4xXoKu10Vk7JcxoDZ2PHqr6HQ54QSqfQqQk6YNE+XrQuhH5AwX7OCVuZ8pDhaIeg2U/R/B2orWCw+f42BPPXsOoooXLECmDbQQAk+R4G01Kf9A==
  • 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>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 08 Sep 2022 14:55:43 +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: AQHYvnyUkd8Ta8Mw/E68HKFtTdhKYK3VfB2AgAAsdNA=
  • Thread-topic: [PATCH v4 4/6] xen/x86: use arch_get_ram_range to get information from E820 map

Hi Jan,

> -----Original Message-----
> From: Jan Beulich <jbeulich@xxxxxxxx>
> Sent: 2022年9月8日 20:14
> 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>; George Dunlap
> <george.dunlap@xxxxxxxxxx>; Julien Grall <julien@xxxxxxx>; Stefano
> Stabellini <sstabellini@xxxxxxxxxx>; xen-devel@xxxxxxxxxxxxxxxxxxxx
> Subject: Re: [PATCH v4 4/6] xen/x86: use arch_get_ram_range to get
> information from E820 map
> 
> On 02.09.2022 05:31, Wei Chen wrote:
> > The sanity check of nodes_cover_memory is also a requirement of
> > other architectures that support NUMA. But now, the code of
> > nodes_cover_memory is tied to the x86 E820. In this case, we
> > introduce arch_get_ram_range to decouple architecture specific
> > memory map from this function. This means, other architectures
> > like Arm can also use it to check its node and memory coverage
> > from bootmem info.
> >
> > Depends arch_get_ram_range, we make nodes_cover_memory become
> > architecture independent. We also use neutral words to replace
> > SRAT and E820 in the print message of this function. This will
> > to make the massage seems more common.
> >
> > As arch_get_ram_range use unsigned int for index, we also adjust
> > the index in nodes_cover_memory from int to unsigned int.
> >
> > Signed-off-by: Wei Chen <wei.chen@xxxxxxx>
> 
> Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
> albeit still with a couple of suggestions:
> 

Thanks, I will adjust the code comments to address your suggestions.

> > --- a/xen/arch/x86/srat.c
> > +++ b/xen/arch/x86/srat.c
> > @@ -428,37 +428,43 @@ acpi_numa_memory_affinity_init(const struct
> acpi_srat_mem_affinity *ma)
> >     Make sure the PXMs cover all memory. */
> >  static int __init nodes_cover_memory(void)
> >  {
> > -   int i;
> > +   unsigned int i;
> >
> > -   for (i = 0; i < e820.nr_map; i++) {
> > -           int j, found;
> > +   for (i = 0; ; i++) {
> > +           int err;
> > +           unsigned int j;
> > +           bool found;
> >             paddr_t start, end;
> >
> > -           if (e820.map[i].type != E820_RAM) {
> > -                   continue;
> > -           }
> > +           /* Try to loop memory map from index 0 to end to get RAM
> ranges. */
> > +           err = arch_get_ram_range(i, &start, &end);
> >
> > -           start = e820.map[i].addr;
> > -           end = e820.map[i].addr + e820.map[i].size;
> > +           /* Reach the end of arch's memory map */
> > +           if (err == -ENOENT)
> > +                   break;
> 
> Such a comment ahead of an if() is often better put as a question, e.g.
> "Reached the end of the memory map?" here or, if you dislike using a
> question, "Exit the loop at the end of the memory map".
> 
> > +           /* Index relate entry is not RAM, skip it. */
> > +           if (err)
> > +                   continue;
> 
> And then perhaps "Skip non-RAM entries" here.
> 
> > --- a/xen/include/xen/numa.h
> > +++ b/xen/include/xen/numa.h
> > @@ -81,6 +81,19 @@ static inline nodeid_t __attribute_pure__
> phys_to_nid(paddr_t addr)
> >  #define node_end_pfn(nid)       (NODE_DATA(nid)->node_start_pfn + \
> >                                   NODE_DATA(nid)->node_spanned_pages)
> >
> > +/*
> > + * This function provides the ability for caller to get one RAM entry
> > + * from architectural memory map by index.
> > + *
> > + * This function will return zero if it can return a proper RAM entry.
> > + * otherwise it will return -ENOENT for out of scope index, or return
> > + * -ENODATA for non-RAM type memory entry.
> 
> The way you've implemented things, -ENODATA isn't special anymore, so
> better wouldn't be called out as special here. May I suggest to at
> least insert "e.g." in front of it? (An alternative would be to check
> for -ENODATA in nodes_cover_memory() again, followed by ASSERT(!err).)
> 
> > + * Note: the range is exclusive at the end, e.g. [start, end).
> 
> Perhaps better [*start, *end) to match ...
> 
> > + */
> > +extern int arch_get_ram_range(unsigned int idx,
> > +                              paddr_t *start, paddr_t *end);
> 
> ... this?
> 
> Jan

 


Rackspace

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