[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH 12/37] xen/x86: decouple nodes_cover_memory from E820 map
+x86 maintainers On Thu, 23 Sep 2021, Wei Chen wrote: > We will reuse nodes_cover_memory for Arm to check its bootmem > info. So we introduce two arch helpers to get memory map's > entry number and specified entry's range: > arch_get_memory_bank_number > arch_get_memory_bank_range > > Depends above two helpers, we make nodes_cover_memory become > architecture independent. And the only change from an x86 > perspective is the additional checks: > !start || !end > > Signed-off-by: Wei Chen <wei.chen@xxxxxxx> > --- > xen/arch/x86/numa.c | 18 ++++++++++++++++++ > xen/arch/x86/srat.c | 11 ++++------- > xen/include/asm-x86/numa.h | 3 +++ > 3 files changed, 25 insertions(+), 7 deletions(-) > > diff --git a/xen/arch/x86/numa.c b/xen/arch/x86/numa.c > index 6337bbdf31..6bc4ade411 100644 > --- a/xen/arch/x86/numa.c > +++ b/xen/arch/x86/numa.c > @@ -378,6 +378,24 @@ unsigned int arch_have_default_dmazone(void) > return ( num_online_nodes() > 1 ) ? 1 : 0; > } > > +uint32_t __init arch_meminfo_get_nr_bank(void) > +{ > + return e820.nr_map; > +} > + > +int __init arch_meminfo_get_ram_bank_range(uint32_t bank, > + paddr_t *start, paddr_t *end) > +{ > + if (e820.map[bank].type != E820_RAM || !start || !end) { > + return -1; > + } > + > + *start = e820.map[bank].addr; > + *end = e820.map[bank].addr + e820.map[bank].size; > + > + return 0; > +} > + > static void dump_numa(unsigned char key) > { > s_time_t now = NOW(); > diff --git a/xen/arch/x86/srat.c b/xen/arch/x86/srat.c > index 18bc6b19bb..aa07a7e975 100644 > --- a/xen/arch/x86/srat.c > +++ b/xen/arch/x86/srat.c > @@ -419,17 +419,14 @@ acpi_numa_memory_affinity_init(const struct > acpi_srat_mem_affinity *ma) > static int __init nodes_cover_memory(void) > { > int i; > + uint32_t nr_banks = arch_meminfo_get_nr_bank(); > > - for (i = 0; i < e820.nr_map; i++) { > + for (i = 0; i < nr_banks; i++) { > int j, found; > paddr_t start, end; > > - if (e820.map[i].type != E820_RAM) { > + if (arch_meminfo_get_ram_bank_range(i, &start, &end)) > continue; > - } > - > - start = e820.map[i].addr; > - end = e820.map[i].addr + e820.map[i].size; > > do { > found = 0; > @@ -448,7 +445,7 @@ static int __init nodes_cover_memory(void) > } while (found && start < end); > > if (start < end) { > - printk(KERN_ERR "SRAT: No PXM for e820 range: " > + printk(KERN_ERR "SRAT: No NODE for memory map range: " > "%"PRIpaddr" - %"PRIpaddr"\n", start, end); > return 0; > } > diff --git a/xen/include/asm-x86/numa.h b/xen/include/asm-x86/numa.h > index 5772a70665..78e044a390 100644 > --- a/xen/include/asm-x86/numa.h > +++ b/xen/include/asm-x86/numa.h > @@ -82,5 +82,8 @@ void srat_parse_regions(paddr_t addr); > extern u8 __node_distance(nodeid_t a, nodeid_t b); > unsigned int arch_get_dma_bitsize(void); > unsigned int arch_have_default_dmazone(void); > +extern uint32_t arch_meminfo_get_nr_bank(void); > +extern int arch_meminfo_get_ram_bank_range(uint32_t bank, > + paddr_t *start, paddr_t *end); > > #endif > -- > 2.25.1 >
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |