ARM: Add Xen NUMA support
v2 cover ARM: Add Xen NUMA support
From: Vijaya Kumar K <[email protected]>
With this RFC patch series, NUMA support is added for ARM platform. Both DT and ACPI based NUMA support is added.
Only Xen is made aware of NUMA platform. NUMA awareness to DOM0 is not added.
As part of this series, the code under x86 architecture is reused by moving into common files.
New files xen/common/numa.c and xen/drivers/acpi/srat.c files are added.
For ARM specific new folder is added xen/arch/arm/numa and new files numa.c, dt_numa.c and acpi_numa are introduced under this folder.
DT NUMA: The following major changes are performed
- Dropped numa-node-id information from Dom0 DT.
So that Dom0 devices make allocation from node 0 for
devmalloc requests.
- Memory DT is not deleted by EFI. It is exposed to Xen
to extract numa information.
- On NUMA failure, Fallback to Non-NUMA booting.ACPI_SRAT_TYPE_MEMORY_AFFINITY Assuming all the memory and CPU's are under node 0.
- CONFIG_NUMA is introduced.
ACPI NUMA:
- MADT is parsed before parsing SRAT table to extract CPU_ID to MPIDR mapping info. In Linux, while parsing SRAT table, MADT table is opened and extract MPIDR. This approach avoids opening ACPI tables recursively.
- SRAT table is parsed for ACPI_SRAT_TYPE_GICC_AFFINITY to extract proximity info and MPIDR from CPU_ID to MPIDR mapping table.
- SRAT table is parsed for ACPI_SRAT_TYPE_MEMORY_AFFINITY to extract memory proximity.
- Re-use SLIT parsing of x86 for node distance information.
- CONFIG_ACPI_NUMA is introduced
No changes are made to x86 implementation only code is sanitized and refactored. Hence only compilation tested for x86.
Code is shared at
https://github.com/vijaykilari/xen-numa/commits/rfc_2
v2: Major changes
- Rebased to lastest staging branch
- Reworked on x86 NUMA code and cleanup to possible extent. Patches 1 to 8 are created for this
- Reworked on DT and ACPI NUMA extracting information
- Reused DT code for memory node processing to extract NUMA info.
- Fixed issues with DT processing
- Added arch specific processing of SRAT
- Reworked on MADT and SRAT processing
- Reworked on node distance
- All ARM changes are moved under folder arch/arm/numa.
- NUMA ACPI common changes are kept in drivers/acpi/srat.c
Vijaya Kumar K (25):
x86: NUMA: Clean up: Drop trailing spaces
x86: NUMA: Fix datatypes and attributes
x86: NUMA: Rename and sanitize some common functions
x86: NUMA: Add accessors for acpi_numa, numa_off and numa_fake
variables
x86: NUMA: Move generic dummy_numa_init to separate function
x86: NUMA: Add accessors for nodes[] and node_memblk_range[] structs
x86: NUMA: Rename some generic functions
x86: NUMA: Sanitize node distance
ARM: NUMA: Add existing ARM numa code under CONFIG_NUMA
x86: NUMA: Move numa code and make it generic
x86: NUMA: Move common code from srat.c
ARM: NUMA: Parse CPU NUMA information
ARM: NUMA: Parse memory NUMA information
ARM: NUMA: Parse NUMA distance information
ARM: NUMA: Add CPU NUMA support
ARM: NUMA: Add memory NUMA support
ARM: NUMA: Add fallback on NUMA failure
ARM: NUMA: Do not expose numa info to DOM0
ACPI: Refactor acpi SRAT and SLIT table handling code
ARM: NUMA: Extract MPIDR from MADT table
ACPI: Move arch specific SRAT parsing
ARM: NUMA: Extract proximity from SRAT table
ARM: NUMA: Initialize ACPI NUMA
NUMA: Move CONFIG_NUMA to common Kconfig
NUMA: Enable ACPI_NUMA config
xen/arch/arm/Makefile | 1 + xen/arch/arm/acpi/boot.c | 2 + xen/arch/arm/bootfdt.c | 44 ++- xen/arch/arm/domain_build.c | 9 + xen/arch/arm/efi/efi-boot.h | 25 -- xen/arch/arm/numa/Makefile | 3 + xen/arch/arm/numa/acpi_numa.c | 249 ++++++++++++++ xen/arch/arm/numa/dt_numa.c | 244 +++++++++++++ xen/arch/arm/numa/numa.c | 196 +++++++++++ xen/arch/arm/setup.c | 4 + xen/arch/arm/smpboot.c | 25 +- xen/arch/x86/dom0_build.c | 1 + xen/arch/x86/mm.c | 2 - xen/arch/x86/numa.c | 454 +------------------------ xen/arch/x86/physdev.c | 1 + xen/arch/x86/setup.c | 3 +- xen/arch/x86/smpboot.c | 3 +- xen/arch/x86/srat.c | 412 ++++------------------ xen/arch/x86/x86_64/mm.c | 3 +- xen/common/Kconfig | 4 + xen/common/Makefile | 1 + xen/common/numa.c | 662 ++++++++++++++++++++++++++++++++++++ xen/drivers/acpi/Kconfig | 5 +- xen/drivers/acpi/Makefile | 1 + xen/drivers/acpi/numa.c | 58 +--- xen/drivers/acpi/srat.c | 299 ++++++++++++++++ xen/drivers/passthrough/vtd/iommu.c | 1 + xen/include/acpi/actbl1.h | 17 +- xen/include/acpi/srat.h | 24 ++ xen/include/asm-arm/numa.h | 73 +++- xen/include/asm-arm/setup.h | 6 +- xen/include/asm-x86/acpi.h | 4 - xen/include/asm-x86/config.h | 1 - xen/include/asm-x86/mm.h | 1 - xen/include/asm-x86/numa.h | 64 +--- xen/include/xen/acpi.h | 6 + xen/include/xen/mm.h | 2 + xen/include/xen/numa.h | 42 +++ 38 files changed, 2023 insertions(+), 929 deletions(-) create mode 100644 xen/arch/arm/numa/Makefile create mode 100644 xen/arch/arm/numa/acpi_numa.c create mode 100644 xen/arch/arm/numa/dt_numa.c create mode 100644 xen/arch/arm/numa/numa.c create mode 100644 xen/common/numa.c create mode 100644 xen/drivers/acpi/srat.c create mode 100644 xen/include/acpi/srat.h
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
RFC PATCH v2 1/25 x86: NUMA: Clean up: Drop trailing spaces
From: Vijaya Kumar K <[email protected]>
Fix coding style, trailing spaces, tabs in NUMA code. Also drop unused macros and functions.
--- xen/arch/x86/numa.c | 47 +++++++++++++++++++++------------------------- xen/arch/x86/srat.c | 2 +- xen/include/asm-x86/numa.h | 43 ++++++++++++++++-------------------------- 3 files changed, 38 insertions(+), 54 deletions(-)
xen/arch/x86/numa.c +21 -26
@@ -1,8 +1,8 @@ -/* +/* * Generic VM initialization for x86-64 NUMA setups. * Copyright 2002,2003 Andi Kleen, SuSE Labs. * Adapted for Xen: Ryan Harper <[email protected]> -*/ +*/ #include <xen/mm.h> #include <xen/string.h>
@@ -21,13 +21,6 @@static int numa_setup (char *s);custom_param ("numa" , numa_setup); -#ifndef Dprintk -#define Dprintk(x...) -#endif - -/* from proto.h */ -#define round_up (x,y) ((((x)+(y))-1) & (~((y)-1))) -struct node_data node_data[MAX_NUMNODES ];/* Mapping from pdx to node id */
@@ -144,8 +137,9 @@ static int __init extract_lsb_from_nodes(const struct node *nodes,if ( nodes_used <=1 ) i =BITS_PER_LONG -1 ;else - i =find_first_bit (&bitfield,sizeof (unsigned long )*8 ); + i =find_first_bit (&bitfield,sizeof (unsigned long ) *8 ); memnodemapsize = (memtop >> i) +1 ; +return i; }
@@ -173,7 +167,7 @@ int __init compute_hash_shift(struct node *nodes, int numnodes, }/* initialize NODE_DATA given nodeid and start/end */ void __init setup_node_bootmem (nodeid_t nodeid,u64 start,u64 end) -{ +{unsigned long start_pfn, end_pfn; start_pfn = start >>PAGE_SHIFT ;
@@ -183,7 +177,7 @@ void __init setup_node_bootmem(nodeid_t nodeid, u64 start, u64 end)NODE_DATA (nodeid)->node_spanned_pages = end_pfn - start_pfn;node_set_online (nodeid); -} +}void __init numa_init_array (void ) {
@@ -214,7 +208,7 @@ static int __init numa_emulation(u64 start_pfn, u64 end_pfn) {int i;struct node nodes[MAX_NUMNODES ]; -u64 sz = ((end_pfn - start_pfn)<<PAGE_SHIFT ) / numa_fake; +u64 sz = ((end_pfn - start_pfn) <<PAGE_SHIFT ) / numa_fake;/* Kludge needed for the hash function */ if (hweight64 (sz) >1 )
@@ -222,21 +216,22 @@ static int __init numa_emulation(u64 start_pfn, u64 end_pfn)u64 x =1 ;while ( (x <<1 ) < sz ) x <<=1 ; -if ( x < sz/2 ) -printk (KERN_ERR "Numa emulation unbalanced. Complain to maintainer\n" ); +if ( x < sz /2 ) +printk (KERN_ERR +"Numa emulation unbalanced. Complain to maintainer\n" ); sz = x; }memset (&nodes,0 ,sizeof (nodes));for ( i =0 ; i < numa_fake; i++ ) { - nodes[i].start = (start_pfn<<PAGE_SHIFT ) + i*sz; + nodes[i].start = (start_pfn <<PAGE_SHIFT ) + i * sz;if ( i == numa_fake -1 ) - sz = (end_pfn<<PAGE_SHIFT ) - nodes[i].start; + sz = (end_pfn <<PAGE_SHIFT ) - nodes[i].start; nodes[i].end = nodes[i].start + sz; -printk (KERN_INFO "Faking node %d at %" PRIx64"-%" PRIx64" (%" PRIu64"MB)\n" , - i, - nodes[i].start, nodes[i].end, +printk (KERN_INFO +"Faking node %d at %" PRIx64"-%" PRIx64" (%" PRIu64"MB)\n" , + i, nodes[i].start, nodes[i].end, (nodes[i].end - nodes[i].start) >>20 );node_set_online (i); }
@@ -256,7 +251,7 @@ static int __init numa_emulation(u64 start_pfn, u64 end_pfn)#endif void __init numa_initmem_init (unsigned long start_pfn,unsigned long end_pfn) -{ +{int i;#ifdef CONFIG_NUMA_EMU
@@ -291,7 +286,7 @@ void __init numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn)void numa_add_cpu (int cpu) {cpumask_set_cpu (cpu, &node_to_cpumask[cpu_to_node (cpu)]); -} +}void numa_set_node (int cpu,nodeid_t node) {
@@ -299,8 +294,8 @@ void numa_set_node(int cpu, nodeid_t node) }/* [numa=off] */ -static __init int numa_setup (char *opt) -{ +static __init int numa_setup (char *opt) +{if ( !strncmp (opt,"off" ,3 ) ) numa_off =1 ;if ( !strncmp (opt,"on" ,2 ) )
@@ -323,7 +318,7 @@ static __init int numa_setup(char *opt)#endif return 1 ; -} +}/* * Setup early cpu_to_node.
@@ -385,7 +380,7 @@ static void dump_numa(unsigned char key)const struct vnuma_info *vnuma;printk ("'%c' pressed -> dumping numa info (now-0x%X:%08X)\n" , key, - (u32)(now>>32 ), (u32 )now); + (u32)(now >>32 ), (u32 )now);for_each_online_node ( i ) {
xen/arch/x86/srat.c +1 -1
@@ -7,7 +7,7 @@* Called from acpi_numa_init while reading the SRAT and SLIT tables. * Assumes all memory regions belonging to a single proximity domain * are in one chunk. Holes between them will be included in the node. -* +* * Adapted for Xen: Ryan Harper <[email protected]> */
xen/include/asm-x86/numa.h +16 -27
75 lines not on this page · raw message
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 01/25] x86: NUMA: Clean up: Drop trailing spaces
The subject should be updated -- it does more than dropping trailing spaces.
Quoted 5 lines · On Tue, Mar 28, 2017 at 09:23:09PM +0530, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
Fix coding style, trailing spaces, tabs in NUMA code. Also drop unused macros and functions.
No functional change.
Quoted 1 line
Signed-off-by Vijaya Kumar K <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 01/25] x86: NUMA: Clean up: Drop trailing spaces
In reply to [email protected]Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 28.03.17 at 17:53, <[email protected]> wrote:
xen/include/asm-x86/numa.h +1
-2@@ -1,4 +1,4 @@ -#ifndef _ASM_X8664_NUMA_H +#ifndef _ASM_X8664_NUMA_H#define _ASM_X8664_NUMA_H 1#include <xen/cpumask.h> @@ -12,21 +12,20 @@ extern int srat_rev;extern nodeid_t cpu_to_node[NR_CPUS ];extern cpumask_t node_to_cpumask[]; -#define cpu_to_node (cpu) (cpu_to_node[cpu])
xen/include/asm-x86/numa.h extern int srat_rev; · line 21
Quoted 10 lines
xen/include/asm-x86/numa.h +4
-3-#define parent_node (node) (node) +#define cpu_to_node (cpu) (cpu_to_node[cpu]) +#define parent_node (node) (node)#define node_to_first_cpu (node) (__ffs(node_to_cpumask[node]))#define node_to_cpumask (node) (node_to_cpumask[node]) -struct node { -u64 start,end; +struct node { +u64 start,end;
You want to add a blank after the comma. Also at least where you touch lines anyway, please also switch to uint64_t and alike.
xen/include/asm-x86/numa.h extern void setup_node_bootmem(nodeid_t nodeid, u64 start, u64 end); · line 45
Quoted 13 lines
xen/include/asm-x86/numa.h +1
-7@@ -42,14 +41,8 @@ extern void setup_node_bootmem(nodeid_t nodeid, u64 start, u64 end);extern nodeid_t apicid_to_node[];extern void init_cpu_to_node (void ); -static inline void clear_node_cpumask (int cpu) -{ -cpumask_clear_cpu (cpu, &node_to_cpumask[cpu_to_node (cpu)]); -} -/* Simple perfect hash to map pdx to node numbers */ -extern int memnode_shift; -extern unsigned long memnodemapsize; +extern int memnode_shift;
If you remove an extern declaration from a header, the corresponding definition should become static.
Quoted 8 lines
xen/include/asm-x86/numa.h +0
-4@@ -60,20 +53,16 @@ struct node_data {extern struct node_data node_data[];static inline __attribute__((pure))nodeid_t phys_to_nid (paddr_t addr) -{ -nodeid_t nid; -VIRTUAL_BUG_ON ((paddr_to_pdx (addr) >> memnode_shift) >= memnodemapsize); - nid = memnodemap[paddr_to_pdx (addr) >> memnode_shift];
xen/include/asm-x86/numa.h struct node_data { · line 57
Quoted 10 lines
xen/include/asm-x86/numa.h +2
-8-VIRTUAL_BUG_ON (nid >=MAX_NUMNODES || !node_data[nid]); -return nid; -} - -#define NODE_DATA (nid) (&(node_data[nid])) - -#define node_start_pfn (nid) (NODE_DATA(nid)->node_start_pfn) -#define node_spanned_pages (nid) (NODE_DATA(nid)->node_spanned_pages) +{ +return memnodemap[paddr_to_pdx (addr) >> memnode_shift];
I think it would be a good idea to convert the ineffective VIRTUAL_BUG_ON()s to ASSERT()s.
xen/include/asm-x86/numa.h struct node_data { · line 60
Quoted 3 lines
xen/include/asm-x86/numa.h +3
-0+} + +#define NODE_DATA (nid) (&(node_data[nid]))
Please drop the pointless inner parentheses.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 01/25] x86: NUMA: Clean up: Drop trailing spaces
In reply to [email protected]xen/include/asm-x86/numa.h struct node_data { · line 55
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 28.03.17 at 17:53, <[email protected]> wrote:
xen/include/asm-x86/numa.h +0
-0@@ -60,20 +53,16 @@ struct node_data {extern struct node_data node_data[];static inline __attribute__((pure))nodeid_t phys_to_nid (paddr_t addr)
Please also take the opportunity and switch to __attribute_pure__ here.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
RFC PATCH v2 2/25 x86: NUMA: Fix datatypes and attributes
In reply to [email protected]From: Vijaya Kumar K <[email protected]>
Change u{8,32,64} to uint{8,32,64}_t and bool_t to bool. Fix attributes coding styles.
Also change memnodeshift to unsigned int.
--- xen/arch/x86/numa.c | 40 +++++++++++++++++------------------ xen/arch/x86/srat.c | 52 +++++++++++++++++++++++----------------------- xen/include/asm-arm/numa.h | 2 +- xen/include/asm-x86/numa.h | 17 ++++++++------- 4 files changed, 56 insertions(+), 55 deletions(-)
xen/arch/x86/numa.c +20 -20
@@ -24,12 +24,12 @@ custom_param("numa", numa_setup);struct node_data node_data[MAX_NUMNODES ];/* Mapping from pdx to node id */ -int memnode_shift; +unsigned int memnode_shift; static typeof(*memnodemap) _memnodemap[64];unsigned long memnodemapsize; -u8 *memnodemap; +uint8_t *memnodemap; -nodeid_t cpu_to_node[NR_CPUS ]__read_mostly = { +nodeid_t __read_mostly cpu_to_node[NR_CPUS ] = { [0 ...NR_CPUS -1 ] =NUMA_NO_NODE };/*
@@ -38,11 +38,11 @@ nodeid_t cpu_to_node[NR_CPUS] __read_mostly = {nodeid_t apicid_to_node[MAX_LOCAL_APIC ] = { [0 ...MAX_LOCAL_APIC -1 ] =NUMA_NO_NODE }; -cpumask_t node_to_cpumask[MAX_NUMNODES ]__read_mostly ; +cpumask_t __read_mostly node_to_cpumask[MAX_NUMNODES ];nodemask_t __read_mostly node_online_map = { { [0 ] =1UL } }; -bool_t numa_off =0 ; +bool numa_off =0 ;s8 acpi_numa =0 ;int srat_disabled (void )
@@ -166,7 +166,7 @@ int __init compute_hash_shift(struct node *nodes, int numnodes,return shift; }/* initialize NODE_DATA given nodeid and start/end */ -void __init setup_node_bootmem (nodeid_t nodeid,u64 start,u64 end) +void __init setup_node_bootmem (nodeid_t nodeid,paddr_t start,paddr_t end) {unsigned long start_pfn, end_pfn;
@@ -201,19 +201,19 @@ void __init numa_init_array(void) }#ifdef CONFIG_NUMA_EMU -static int numa_fake__initdata =0 ; +static int __initdata numa_fake =0 ;/* Numa emulation */ -static int __init numa_emulation (u64 start_pfn,u64 end_pfn) +static int __init numa_emulation (uint64_t start_pfn,uint64_t end_pfn) {int i;struct node nodes[MAX_NUMNODES ]; -u64 sz = ((end_pfn - start_pfn) <<PAGE_SHIFT ) / numa_fake; +uint64_t sz = ((end_pfn - start_pfn) <<PAGE_SHIFT ) / numa_fake;/* Kludge needed for the hash function */ if (hweight64 (sz) >1 ) { -u64 x =1 ; +uint64_t x =1 ;while ( (x <<1 ) < sz ) x <<=1 ;if ( x < sz /2 )
@@ -260,8 +260,8 @@ void __init numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn)#endif #ifdef CONFIG_ACPI_NUMA -if ( !numa_off && !acpi_scan_nodes ((u64 )start_pfn <<PAGE_SHIFT , - (u64 )end_pfn <<PAGE_SHIFT ) ) +if ( !numa_off && !acpi_scan_nodes ((uint64_t )start_pfn <<PAGE_SHIFT , + (uint64_t )end_pfn <<PAGE_SHIFT ) )return ;#endif
@@ -269,8 +269,8 @@ void __init numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn) numa_off ? "NUMA turned off" : "No NUMA configuration found");printk (KERN_INFO "Faking a node at %016" PRIx64"-%016" PRIx64"\n" , - (u64 )start_pfn <<PAGE_SHIFT , - (u64 )end_pfn <<PAGE_SHIFT ); + (uint64_t )start_pfn <<PAGE_SHIFT , + (uint64_t )end_pfn <<PAGE_SHIFT );/* setup dummy node covering all memory */ memnode_shift =BITS_PER_LONG -1 ; memnodemap = _memnodemap;
@@ -279,8 +279,8 @@ void __init numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn)for ( i =0 ; i < nr_cpu_ids; i++ )numa_set_node (i,0 );cpumask_copy (&node_to_cpumask[0 ],cpumask_of (0 )); -setup_node_bootmem (0 , (u64 )start_pfn <<PAGE_SHIFT , - (u64 )end_pfn <<PAGE_SHIFT ); +setup_node_bootmem (0 , (paddr_t )start_pfn <<PAGE_SHIFT , + (paddr_t )end_pfn <<PAGE_SHIFT ); }void numa_add_cpu (int cpu)
@@ -294,7 +294,7 @@ void numa_set_node(int cpu, nodeid_t node) }/* [numa=off] */ -static __init int numa_setup (char *opt) +static int __init numa_setup (char *opt) {if ( !strncmp (opt,"off" ,3 ) ) numa_off =1 ;
@@ -339,7 +339,7 @@ void __init init_cpu_to_node(void)for ( i =0 ; i < nr_cpu_ids; i++ ) { -u32 apicid = x86_cpu_to_apicid[i]; +uint32_t apicid = x86_cpu_to_apicid[i];if ( apicid ==BAD_APICID )continue ; node = apicid <MAX_LOCAL_APIC ? apicid_to_node[apicid] :NUMA_NO_NODE ;
@@ -380,7 +380,7 @@ static void dump_numa(unsigned char key)const struct vnuma_info *vnuma;printk ("'%c' pressed -> dumping numa info (now-0x%X:%08X)\n" , key, - (u32)(now >>32 ), (u32 )now); + (uint32_t )(now >>32 ), (uint32_t )now);for_each_online_node ( i ) {
@@ -507,7 +507,7 @@ static void dump_numa(unsigned char key)rcu_read_unlock (&domlist_read_lock); } -static __init int register_numa_trigger (void ) +static int __init register_numa_trigger (void ) {register_keyhandler ('u' , dump_numa,"dump NUMA info" ,1 );return 0 ;
xen/arch/x86/srat.c +26 -26
158 lines not on this page · raw message
xen/include/asm-arm/numa.h +1 -1
@@ -1,7 +1,7 @@#ifndef __ARCH_ARM_NUMA_H#define __ARCH_ARM_NUMA_H -typedef u8 nodeid_t ; +typedef uint8_t nodeid_t ;/* Fake one node for now. See also node_online_map. */ #define cpu_to_node (cpu) 0
xen/include/asm-x86/numa.h +9 -8
@@ -5,7 +5,7 @@#define NODES_SHIFT 6 -typedef u8 nodeid_t ; +typedef uint8_t nodeid_t ;extern int srat_rev;
@@ -18,7 +18,8 @@ extern cpumask_t node_to_cpumask[];#define node_to_cpumask (node) (node_to_cpumask[node])struct node { -u64 start,end; +paddr_t start; +paddr_t end; }; extern int compute_hash_shift(struct node *nodes, int numnodes,
@@ -37,13 +38,13 @@ extern void numa_set_node(int cpu, nodeid_t node);extern nodeid_t setup_node (unsigned int pxm);extern void srat_detect_node (int cpu); -extern void setup_node_bootmem (nodeid_t nodeid,u64 start,u64 end); +extern void setup_node_bootmem (nodeid_t nodeid,paddr_t start,paddr_t end);extern nodeid_t apicid_to_node[];extern void init_cpu_to_node (void );/* Simple perfect hash to map pdx to node numbers */ -extern int memnode_shift; -extern u8 *memnodemap; +extern unsigned int memnode_shift; +extern uint8_t *memnodemap;struct node_data {unsigned long node_start_pfn;
@@ -64,10 +65,10 @@ static inline __attribute__((pure)) nodeid_t phys_to_nid(paddr_t addr)#define node_end_pfn (nid) (NODE_DATA(nid)->node_start_pfn + \ NODE_DATA(nid)->node_spanned_pages) -extern int valid_numa_range (u64 start,u64 end,nodeid_t node); +extern int valid_numa_range (paddr_t start,paddr_t end,nodeid_t node); -void srat_parse_regions (u64 addr); -extern u8 __node_distance (nodeid_t a,nodeid_t b); +void srat_parse_regions (uint64_t addr); +extern uint8_t __node_distance (nodeid_t a,nodeid_t b);unsigned int arch_get_dma_bitsize (void );#endif
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 02/25] x86: NUMA: Fix datatypes and attributes
Quoted 5 lines · On Tue, Mar 28, 2017 at 09:23:10PM +0530, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
Change u{8,32,64} to uint{8,32,64}_t and
bool_tto bool. Fix attributes coding styles.
Also change memnodeshift to unsigned int.
I think you also need to say you changed u64 to paddr_t where appropriate.
Quoted 12 lines
xen/arch/x86/numa.c +2
-2@@ -269,8 +269,8 @@ void __init numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn) numa_off ? "NUMA turned off" : "No NUMA configuration found");printk (KERN_INFO "Faking a node at %016" PRIx64"-%016" PRIx64"\n" , - (u64 )start_pfn <<PAGE_SHIFT , - (u64 )end_pfn <<PAGE_SHIFT ); + (uint64_t )start_pfn <<PAGE_SHIFT , + (uint64_t )end_pfn <<PAGE_SHIFT );/* setup dummy node covering all memory */ memnode_shift =BITS_PER_LONG -1 ; memnodemap = _memnodemap;
xen/arch/x86/numa.c void __init numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn) · line 283
Quoted 7 lines
xen/arch/x86/numa.c +2
-2@@ -279,8 +279,8 @@ void __init numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn)for ( i =0 ; i < nr_cpu_ids; i++ )numa_set_node (i,0 );cpumask_copy (&node_to_cpumask[0 ],cpumask_of (0 )); -setup_node_bootmem (0 , (u64 )start_pfn <<PAGE_SHIFT , - (u64 )end_pfn <<PAGE_SHIFT ); +setup_node_bootmem (0 , (paddr_t )start_pfn <<PAGE_SHIFT , + (paddr_t )end_pfn <<PAGE_SHIFT );
Indentation.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 02/25] x86: NUMA: Fix datatypes and attributes
In reply to [email protected]Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 28.03.17 at 17:53, <[email protected]> wrote:
Change u{8,32,64} to uint{8,32,64}_t and
bool_tto bool.
Oh, I see you do this in a separate patch. Please disregard the respective comments on patch 1 then.
xen/arch/x86/numa.c nodeid_t cpu_to_node[NR_CPUS] __read_mostly = { · line 45
Quoted 2 lines
xen/arch/x86/numa.c +1
-1-bool_t numa_off =0 ; +bool numa_off =0 ;
"false" at the same time (and "true" wherever it is being set).
xen/arch/x86/numa.c void __init numa_init_array(void) · line 204
Quoted 6 lines
xen/arch/x86/numa.c +1
-1@@ -201,19 +201,19 @@ void __init numa_init_array(void) }#ifdef CONFIG_NUMA_EMU -static int numa_fake__initdata =0 ; +static int __initdata numa_fake =0 ;
unsigned int and the initializer can be dropped at once.
Quoted 5 lines
xen/arch/x86/numa.c +1
-1/* Numa emulation */ -static int __init numa_emulation (u64 start_pfn,u64 end_pfn) +static int __init numa_emulation (uint64_t start_pfn,uint64_t end_pfn) {int i;
xen/arch/x86/numa.c void __init numa_init_array(void) · line 217
Quoted 10 lines
xen/arch/x86/numa.c +2
-2struct node nodes[MAX_NUMNODES ]; -u64 sz = ((end_pfn - start_pfn) <<PAGE_SHIFT ) / numa_fake; +uint64_t sz = ((end_pfn - start_pfn) <<PAGE_SHIFT ) / numa_fake;/* Kludge needed for the hash function */ if (hweight64 (sz) >1 ) { -u64 x =1 ; +uint64_t x =1 ;while ( (x <<1 ) < sz )
Please also add the missing blank line between declaration and statements (same elsewhere).
xen/arch/x86/numa.c void __init numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn) · line 264
Quoted 8 lines
xen/arch/x86/numa.c +2
-2@@ -260,8 +260,8 @@ void __init numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn)#endif #ifdef CONFIG_ACPI_NUMA -if ( !numa_off && !acpi_scan_nodes ((u64 )start_pfn <<PAGE_SHIFT , - (u64 )end_pfn <<PAGE_SHIFT ) ) +if ( !numa_off && !acpi_scan_nodes ((uint64_t )start_pfn <<PAGE_SHIFT , + (uint64_t )end_pfn <<PAGE_SHIFT ) )
Instead of altering the casts please use pfn_to_paddr() (also further down).
Quoted 8 lines
xen/arch/x86/srat.c +0
-2@@ -23,12 +23,12 @@static struct acpi_table_slit *__read_mostly acpi_slit; -static nodemask_t memory_nodes_parsed__initdata ; -static nodemask_t processor_nodes_parsed__initdata ;
xen/arch/x86/srat.c line 33
Quoted 10 lines
xen/arch/x86/srat.c +4
-2-static struct node nodes[MAX_NUMNODES ]__initdata ; +static nodemask_t __initdata memory_nodes_parsed; +static nodemask_t __initdata processor_nodes_parsed; +static struct node __initdata nodes[MAX_NUMNODES ];struct pxm2node { -unsigned pxm; +unsigned int pxm;nodeid_t node; };
How come there are still tabs left here after patch 1?
xen/arch/x86/srat.c nodeid_t pxm_to_node(unsigned pxm) · line 68
Quoted 9 lines
xen/arch/x86/srat.c +2
-3@@ -64,9 +64,9 @@ nodeid_t pxm_to_node(unsigned pxm)nodeid_t setup_node (unsigned pxm) {nodeid_t node; -unsigned idx; -static bool_t warned; -static unsigned nodes_found; +unsigned int idx; +static bool warned;
Again together with the type change you should also change the setting of the variable to use "true".
xen/arch/x86/srat.c static __init int conflicting_memblks(u64 start, u64 end) · line 137
Quoted 6 lines
xen/arch/x86/srat.c +1
-1@@ -134,7 +134,7 @@ static __init int conflicting_memblks(u64 start, u64 end)return -1 ; } -static __init void cutoff_node (int i,u64 start,u64 end) +static void __init cutoff_node (int i,paddr_t start,paddr_t end)
The first parameter also wants changing (presumably nodeid_t).
xen/arch/x86/srat.c acpi_numa_processor_affinity_init(const struct acpi_srat_cpu_affinity *pa) · line 277
Quoted 6 lines
xen/arch/x86/srat.c +1
-1@@ -274,7 +274,7 @@ 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) { -u64 start, end; +uint64_t start, end;
Why not paddr_t, like you do elsewhere?
xen/arch/x86/srat.c static int __init srat_parse_region(struct acpi_subtable_header *header, · line 431
Quoted 6 lines
xen/arch/x86/srat.c +1
-1@@ -428,9 +428,9 @@ static int __init srat_parse_region(struct acpi_subtable_header *header,return 0 ; } -void __init srat_parse_regions (u64 addr) +void __init srat_parse_regions (uint64_t addr)
Same (at least) here.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
RFC PATCH v2 3/25 x86: NUMA: Rename and sanitize some common functions
In reply to [email protected]From: Vijaya Kumar K <[email protected]>
Following changes are made
- Rename compute_hash_shift to compute_memnode_shift and return error values instead of shift.
- Changes prototypes of populate_memnodemap() and extract_lsb_from_nodes()
--- xen/arch/x86/numa.c | 47 +++++++++++++++++++++++----------------------- xen/arch/x86/srat.c | 7 +++---- xen/include/asm-x86/numa.h | 4 ++-- 3 files changed, 28 insertions(+), 30 deletions(-)
xen/arch/x86/numa.c +23 -24
@@ -53,15 +53,15 @@ int srat_disabled(void)/* * Given a shift value, try to populate memnodemap[] * Returns : -* 1 if OK -* 0 if memnodmap[] too small (of shift too small) -* -1 if node overlap or lost ram (shift too big) +* 0 if OK +* -EINVAL if memnodmap[] too small (of shift too small) +* OR if node overlap or lost ram (shift too big) */ -static int __init populate_memnodemap (const struct node *nodes, -int numnodes,int shift,nodeid_t *nodeids) +static int __init populate_memnodemap (const struct node *nodes,int numnodes, +unsigned int shift,nodeid_t *nodeids) {unsigned long spdx, epdx; -int i, res =-1 ; +int i, res = -EINVAL ;memset (memnodemap,NUMA_NO_NODE , memnodemapsize *sizeof (*memnodemap));for ( i =0 ; i < numnodes; i++ )
@@ -74,7 +74,7 @@ static int __init populate_memnodemap(const struct node *nodes,return 0 ; do { if ( memnodemap[spdx >> shift] != NUMA_NO_NODE ) - return -1; + return -EINVAL; if ( !nodeids ) memnodemap[spdx >> shift] = i;
@@ -83,7 +83,7 @@ static int __init populate_memnodemap(const struct node *nodes, spdx += (1UL << shift); }while ( spdx < epdx ); - res =1 ; + res =0 ; }return res;
@@ -99,7 +99,7 @@ static int __init allocate_cachealigned_memnodemap(void)printk (KERN_ERR "NUMA: Unable to allocate Memory to Node hash map\n" ); memnodemapsize =0 ; -return -1 ; +return -ENOMEM ; } memnodemap =mfn_to_virt (mfn);
@@ -116,10 +116,10 @@ static int __init allocate_cachealigned_memnodemap(void)* The LSB of all start and end addresses in the node map is the value of the * maximum possible shift. */ -static int __init extract_lsb_from_nodes (const struct node *nodes, -int numnodes) +static unsigned int __init extract_lsb_from_nodes (const struct node *nodes, +int numnodes) { -int i, nodes_used =0 ; +unsigned int i, nodes_used =0 ;unsigned long spdx, epdx;unsigned long bitfield =0 , memtop =0 ;
@@ -143,27 +143,27 @@ static int __init extract_lsb_from_nodes(const struct node *nodes,return i; } -int __init compute_hash_shift (struct node *nodes,int numnodes, -nodeid_t *nodeids) +int __init compute_memnode_shift (struct node *nodes,int numnodes, +nodeid_t *nodeids,unsigned int *shift) { -int shift; + *shift =extract_lsb_from_nodes (nodes, numnodes); - shift =extract_lsb_from_nodes (nodes, numnodes);if ( memnodemapsize <=ARRAY_SIZE (_memnodemap) ) memnodemap = _memnodemap;else if (allocate_cachealigned_memnodemap () ) -return -1 ; -printk (KERN_DEBUG "NUMA: Using %d for the hash shift.\n" , shift); +return -ENOMEM ; + +printk (KERN_DEBUG "NUMA: Using %u for the hash shift.\n" , *shift); -if (populate_memnodemap (nodes, numnodes, shift, nodeids) !=1 ) +if (populate_memnodemap (nodes, numnodes, *shift, nodeids) ) {printk (KERN_INFO "Your memory is not aligned you need to " "rebuild your hypervisor with a bigger NODEMAPSIZE " -"shift=%d\n" , shift); -return -1 ; +"shift=%u\n" , *shift); +return -EINVAL ; } -return shift; +return 0 ; }/* initialize NODE_DATA given nodeid and start/end */ void __init setup_node_bootmem (nodeid_t nodeid,paddr_t start,paddr_t end)
@@ -235,8 +235,7 @@ static int __init numa_emulation(uint64_t start_pfn, uint64_t end_pfn) (nodes[i].end - nodes[i].start) >> 20);node_set_online (i); } - memnode_shift =compute_hash_shift (nodes, numa_fake,NULL ); -if ( memnode_shift <0 ) +if (compute_memnode_shift (nodes, numa_fake,NULL , &memnode_shift) ) { memnode_shift =0 ;printk (KERN_ERR "No NUMA hash function found. Emulation disabled.\n" );
xen/arch/x86/srat.c +3 -4
@@ -470,10 +470,9 @@ int __init acpi_scan_nodes(uint64_t start, uint64_t end)return -1 ; } - memnode_shift =compute_hash_shift (node_memblk_range, num_node_memblks, - memblk_nodeid); - -if (memnode_shift <0 ) { +if (compute_memnode_shift (node_memblk_range, num_node_memblks, + memblk_nodeid, &memnode_shift)) { + memnode_shift =0 ;printk (KERN_ERR "SRAT: No NUMA node hash function found. Contact maintainer\n" );bad_srat ();
xen/include/asm-x86/numa.h +2 -2
@@ -22,8 +22,8 @@ struct node {paddr_t end; }; -extern int compute_hash_shift (struct node *nodes,int numnodes, -nodeid_t *nodeids); +extern int compute_memnode_shift (struct node *nodes,int numnodes, +nodeid_t *nodeids,unsigned int *shift);extern nodeid_t pxm_to_node (unsigned int pxm);#define ZONE_ALIGN (1UL << (MAX_ORDER+PAGE_SHIFT))
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 03/25] x86: NUMA: Rename and sanitize some common functions
xen/arch/x86/numa.c int srat_disabled(void) · line 58
Quoted 13 lines
Quoted 1 line
Quoted 1 line
<[email protected]> 03/28/17 5:54 PM >>>
xen/arch/x86/numa.c +3
-3@@ -53,15 +53,15 @@ int srat_disabled(void)/* * Given a shift value, try to populate memnodemap[] * Returns : -* 1 if OK -* 0 if memnodmap[] too small (of shift too small) -* -1 if node overlap or lost ram (shift too big) +* 0 if OK +* -EINVAL if memnodmap[] too small (of shift too small) +* OR if node overlap or lost ram (shift too big)
It may not matter too much, but you're making things actually worse to the caller, as it now can't distinguish the two failure modes anymore. Also, if you already touch it, please also correct the apparent typo ("of" quite likely meant to be "or"). But what I consider most problematic is that you convert ...
xen/arch/x86/numa.c static int __init populate_memnodemap(const struct node *nodes, · line 74
Quoted 2 lines
xen/arch/x86/numa.c +0
-0@@ -74,7 +74,7 @@ static int __init populate_memnodemap(const struct node *nodes,return 0 ;
... what is an error case so far to a success one.
xen/arch/x86/numa.c static int __init allocate_cachealigned_memnodemap(void) · line 120
Quoted 8 lines
xen/arch/x86/numa.c +2
-2@@ -116,10 +116,10 @@ static int __init allocate_cachealigned_memnodemap(void)* The LSB of all start and end addresses in the node map is the value of the * maximum possible shift. */ -static int __init extract_lsb_from_nodes (const struct node *nodes, -int numnodes) +static unsigned int __init extract_lsb_from_nodes (const struct node *nodes, +int numnodes)
Why would you convert the return type to unsigned, but not also that of the bogusly signed parameter?
xen/arch/x86/numa.c static int __init extract_lsb_from_nodes(const struct node *nodes, · line 147
Quoted 8 lines
xen/arch/x86/numa.c +2
-2@@ -143,27 +143,27 @@ static int __init extract_lsb_from_nodes(const struct node *nodes,return i; } -int __init compute_hash_shift (struct node *nodes,int numnodes, -nodeid_t *nodeids) +int __init compute_memnode_shift (struct node *nodes,int numnodes, +nodeid_t *nodeids,unsigned int *shift)
I'm not in favor of returning the shift count via pointer when it can easily be returned by value.
Quoted 13 lines
xen/arch/x86/numa.c +4
-4{ -int shift; + *shift =extract_lsb_from_nodes (nodes, numnodes); - shift =extract_lsb_from_nodes (nodes, numnodes);if ( memnodemapsize <=ARRAY_SIZE (_memnodemap) ) memnodemap = _memnodemap;else if (allocate_cachealigned_memnodemap () ) -return -1 ; -printk (KERN_DEBUG "NUMA: Using %d for the hash shift.\n" , shift); +return -ENOMEM ; + +printk (KERN_DEBUG "NUMA: Using %u for the hash shift.\n" , *shift);
xen/arch/x86/numa.c static int __init extract_lsb_from_nodes(const struct node *nodes, · line 163
Quoted 10 lines
xen/arch/x86/numa.c +3
-3-if (populate_memnodemap (nodes, numnodes, shift, nodeids) !=1 ) +if (populate_memnodemap (nodes, numnodes, *shift, nodeids) ) {printk (KERN_INFO "Your memory is not aligned you need to " "rebuild your hypervisor with a bigger NODEMAPSIZE " -"shift=%d\n" , shift); -return -1 ; +"shift=%u\n" , *shift); +return -EINVAL ;
So you make populate_memnodemap() return proper error values, but then discard it and uniformly use -EINVAL here. If you mean the function to simply return a success/failure indicator, make it return bool. Otherwise use the error value it return (even if right now it can only ever be -EINVAL).
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 03/25] x86: NUMA: Rename and sanitize some common functions
Hi Jan,
Sorry for late reply.
Quoted 11 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line
<[email protected]> 03/28/17 5:54 PM >>>
xen/arch/x86/numa.c +1
-3@@ -53,15 +53,15 @@ int srat_disabled(void)/* * Given a shift value, try to populate memnodemap[] * Returns : -* 1 if OK -* 0 if memnodmap[] too small (of shift too small) -* -1 if node overlap or lost ram (shift too big) +* 0 if OK
Quoted 8 lines
xen/arch/x86/numa.c int srat_disabled(void) · line 58
Quoted 2 lines
xen/arch/x86/numa.c +2
-0+* -EINVAL if memnodmap[] too small (of shift too small) +* OR if node overlap or lost ram (shift too big) It may not matter too much, but you're making things actually worse to the caller, as it now can't distinguish the two failure modes anymore. Also, if you already touch it, please also correct the apparent typo ("of" quite likely meant to be "or"). But what I consider most problematic is that you convert ...
OK. I propose to return different error values for two failure modes. -ENOMEM for "if memnodmap[] too small" and-EINVAL for if node overlap or lost ram
But In any case it does not matter much and can drop this change.
Quoted 13 lines
... what is an error case so far to a success one.
xen/arch/x86/numa.c static int __init allocate_cachealigned_memnodemap(void) · line 120
Quoted 8 lines
xen/arch/x86/numa.c +2
-2@@ -116,10 +116,10 @@ static int __init allocate_cachealigned_memnodemap(void)* The LSB of all start and end addresses in the node map is the value of the * maximum possible shift. */ -static int __init extract_lsb_from_nodes (const struct node *nodes, -int numnodes) +static unsigned int __init extract_lsb_from_nodes (const struct node *nodes, +int numnodes)Why would you convert the return type to unsigned, but not also that of the bogusly signed parameter?
Because memnode_shift type is changed from int to unsigned int. The return type is changed.
I will change int parameter to unsigned int.
Apart from that I see that variable 'i' in extract_lsb_from_nodes() is int. This needs to changed to unsigned int.
Quoted 5 lines
Quoted 5 lines
xen/arch/x86/numa.c +0
-0@@ -143,27 +143,27 @@ static int __init extract_lsb_from_nodes(const struct node *nodes,return i; }
Quoted 7 lines
xen/arch/x86/numa.c static int __init extract_lsb_from_nodes(const struct node *nodes, · line 147
Quoted 4 lines
xen/arch/x86/numa.c +2
-2-int __init compute_hash_shift (struct node *nodes,int numnodes, -nodeid_t *nodeids) +int __init compute_memnode_shift (struct node *nodes,int numnodes, +nodeid_t *nodeids,unsigned int *shift)I'm not in favor of returning the shift count via pointer when it can easily be returned by value.
OK.
Quoted 25 lines
Quoted 14 lines
xen/arch/x86/numa.c +4
-4{ -int shift; + *shift =extract_lsb_from_nodes (nodes, numnodes); - shift =extract_lsb_from_nodes (nodes, numnodes);if ( memnodemapsize <=ARRAY_SIZE (_memnodemap) ) memnodemap = _memnodemap;else if (allocate_cachealigned_memnodemap () ) -return -1 ; -printk (KERN_DEBUG "NUMA: Using %d for the hash shift.\n" , shift); +return -ENOMEM ; + +printk (KERN_DEBUG "NUMA: Using %u for the hash shift.\n" , *shift);xen/arch/x86/numa.c static int __init extract_lsb_from_nodes(const struct node *nodes, · line 163
Quoted 10 lines
xen/arch/x86/numa.c +3
-3-if (populate_memnodemap (nodes, numnodes, shift, nodeids) !=1 ) +if (populate_memnodemap (nodes, numnodes, *shift, nodeids) ) {printk (KERN_INFO "Your memory is not aligned you need to " "rebuild your hypervisor with a bigger NODEMAPSIZE " -"shift=%d\n" , shift); -return -1 ; +"shift=%u\n" , *shift); +return -EINVAL ;
Quoted 4 lines
So you make
populate_memnodemap()return proper error values, but then discard it and uniformly use-EINVALhere. If you mean the function to simply return a success/failure indicator, make it return bool. Otherwise use the error value it return (even if right now it can only ever be-EINVAL).
OK. I will drop this change and keep compute_hash_shift() return -1 or shift value.
Regards
Vijay
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
RFC PATCH v2 4/25 x86: NUMA: Add accessors for acpi_numa, numa_off and numa_fake variables
In reply to [email protected]From: Vijaya Kumar K <[email protected]>
Add accessor functions for acpi_numa and numa_off static variables. Init value of acpi_numa is set 1 instead of 0. Also return value of srat_disabled is changed to bool.
--- xen/arch/x86/numa.c | 43 +++++++++++++++++++++++++++++++------------ xen/arch/x86/setup.c | 2 +- xen/arch/x86/srat.c | 12 ++++++------ xen/include/asm-x86/acpi.h | 1 - xen/include/asm-x86/numa.h | 5 +---- xen/include/xen/numa.h | 3 +++ 6 files changed, 42 insertions(+), 24 deletions(-)
xen/arch/x86/numa.c +31 -12
@@ -42,12 +42,27 @@ cpumask_t __read_mostly node_to_cpumask[MAX_NUMNODES];nodemask_t __read_mostly node_online_map = { { [0 ] =1UL } }; -bool numa_off =0 ; -s8 acpi_numa =0 ; +static bool numa_off =0 ; +static bool acpi_numa =1 ; -int srat_disabled (void ) +bool is_numa_off (void ) { -return numa_off || acpi_numa <0 ; +return numa_off; +} + +bool get_acpi_numa (void ) +{ +return acpi_numa; +} + +void set_acpi_numa (bool_t val) +{ + acpi_numa = val; +} + +bool srat_disabled (void ) +{ +return numa_off || acpi_numa ==0 ; }/*
@@ -202,13 +217,17 @@ void __init numa_init_array(void)#ifdef CONFIG_NUMA_EMU static int __initdata numa_fake =0 ; +static int get_numa_fake (void ) +{ +return numa_fake; +}/* Numa emulation */ static int __init numa_emulation (uint64_t start_pfn,uint64_t end_pfn) {int i;struct node nodes[MAX_NUMNODES ]; -uint64_t sz = ((end_pfn - start_pfn) <<PAGE_SHIFT ) / numa_fake; +uint64_t sz = ((end_pfn - start_pfn) <<PAGE_SHIFT ) /get_numa_fake ();/* Kludge needed for the hash function */ if (hweight64 (sz) >1 )
@@ -223,10 +242,10 @@ static int __init numa_emulation(uint64_t start_pfn, uint64_t end_pfn) }memset (&nodes,0 ,sizeof (nodes)); -for ( i =0 ; i < numa_fake; i++ ) +for ( i =0 ; i <get_numa_fake (); i++ ) { nodes[i].start = (start_pfn <<PAGE_SHIFT ) + i * sz; -if ( i == numa_fake -1 ) +if ( i ==get_numa_fake () -1 ) sz = (end_pfn <<PAGE_SHIFT ) - nodes[i].start; nodes[i].end = nodes[i].start + sz; printk(KERN_INFO
@@ -235,7 +254,7 @@ static int __init numa_emulation(uint64_t start_pfn, uint64_t end_pfn) (nodes[i].end - nodes[i].start) >> 20);node_set_online (i); } -if (compute_memnode_shift (nodes, numa_fake,NULL , &memnode_shift) ) +if (compute_memnode_shift (nodes,get_numa_fake (),NULL , &memnode_shift) ) { memnode_shift =0 ;printk (KERN_ERR "No NUMA hash function found. Emulation disabled.\n" );
@@ -254,18 +273,18 @@ void __init numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn)int i;#ifdef CONFIG_NUMA_EMU -if ( numa_fake && !numa_emulation (start_pfn, end_pfn) ) +if (get_numa_fake () && !numa_emulation (start_pfn, end_pfn) )return ;#endif #ifdef CONFIG_ACPI_NUMA -if ( !numa_off && !acpi_scan_nodes ((uint64_t )start_pfn <<PAGE_SHIFT , +if ( !is_numa_off () && !acpi_scan_nodes ((uint64_t )start_pfn <<PAGE_SHIFT , (uint64_t )end_pfn <<PAGE_SHIFT ) )return ;#endif printk (KERN_INFO "%s\n" , - numa_off ?"NUMA turned off" :"No NUMA configuration found" ); +is_numa_off () ?"NUMA turned off" :"No NUMA configuration found" ); printk(KERN_INFO "Faking a node at %016"PRIx64"-%016"PRIx64"\n", (uint64_t)start_pfn << PAGE_SHIFT,
@@ -312,7 +331,7 @@ static int __init numa_setup(char *opt)if ( !strncmp (opt,"noacpi" ,6 ) ) { numa_off =0 ; - acpi_numa =-1 ; + acpi_numa =0 ; }#endif
xen/arch/x86/setup.c +1 -1
@@ -241,7 +241,7 @@ void srat_detect_node(int cpu)node_set_online (node);numa_set_node (cpu, node); -if ( opt_cpu_info && acpi_numa >0 ) +if ( opt_cpu_info &&get_acpi_numa () )printk ("CPU %d APIC %d -> Node %d\n" , cpu, apicid, node); }
xen/arch/x86/srat.c +6 -6
@@ -153,7 +153,7 @@ static void __init bad_srat(void) {int i;printk (KERN_ERR "SRAT: SRAT not used.\n" ); - acpi_numa =-1 ; +set_acpi_numa (0 );for (i =0 ; i <MAX_LOCAL_APIC ; i++) apicid_to_node[i] =NUMA_NO_NODE ;for (i =0 ; i <ARRAY_SIZE (pxm2node); i++)
@@ -232,7 +232,7 @@ acpi_numa_x2apic_affinity_init(const struct acpi_srat_x2apic_cpu_affinity *pa) apicid_to_node[pa->apic_id] = node;node_set (node, processor_nodes_parsed); - acpi_numa =1 ; +set_acpi_numa (1 );printk (KERN_INFO "SRAT: PXM %u -> APIC %08x -> Node %u\n" , pxm, pa->apic_id, node); }
@@ -265,7 +265,7 @@ acpi_numa_processor_affinity_init(const struct acpi_srat_cpu_affinity *pa) } apicid_to_node[pa->apic_id] = node;node_set (node, processor_nodes_parsed); - acpi_numa =1 ; +set_acpi_numa (1 );printk (KERN_INFO "SRAT: PXM %u -> APIC %02x -> Node %u\n" , pxm, pa->apic_id, node); }
@@ -418,7 +418,7 @@ static int __init srat_parse_region(struct acpi_subtable_header *header, (ma->flags & ACPI_SRAT_MEM_NON_VOLATILE))return 0 ; -if (numa_off) +if (is_numa_off ())printk (KERN_INFO "SRAT: %013" PRIx64"-%013" PRIx64"\n" , ma->base_address, ma->base_address + ma->length -1 );
@@ -433,7 +433,7 @@ void __init srat_parse_regions(uint64_t addr)uint64_t mask;unsigned int i; -if (acpi_disabled || acpi_numa <0 || +if (acpi_disabled || (get_acpi_numa () ==0 ) ||acpi_table_parse (ACPI_SIG_SRAT , acpi_parse_srat))return ;
@@ -462,7 +462,7 @@ int __init acpi_scan_nodes(uint64_t start, uint64_t end)for (i =0 ; i <MAX_NUMNODES ; i++)cutoff_node (i, start, end); -if (acpi_numa <=0 ) +if (get_acpi_numa () ==0 )return -1 ;if (!nodes_cover_memory ()) {
xen/include/asm-x86/acpi.h +0 -1
@@ -103,7 +103,6 @@ extern void acpi_reserve_bootmem(void);#define ARCH_HAS_POWER_INIT 1 -extern s8 acpi_numa;extern int acpi_scan_nodes (u64 start,u64 end);#define NR_NODE_MEMBLKS (MAX_NUMNODES*2)
xen/include/asm-x86/numa.h +1 -4
@@ -30,10 +30,7 @@ extern nodeid_t pxm_to_node(unsigned int pxm);extern void numa_add_cpu (int cpu);extern void numa_init_array (void ); -extern bool_t numa_off; - - -extern int srat_disabled (void ); +extern bool srat_disabled (void );extern void numa_set_node (int cpu,nodeid_t node);extern nodeid_t setup_node (unsigned int pxm);extern void srat_detect_node (int cpu);
xen/include/xen/numa.h +3 -0
@@ -18,4 +18,7 @@ (((d)->vcpu !=NULL && (d)->vcpu[0 ] !=NULL ) \ ? vcpu_to_node((d)->vcpu[0]) : NUMA_NO_NODE) +bool is_numa_off (void ); +bool get_acpi_numa (void ); +void set_acpi_numa (bool val);#endif /* _XEN_NUMA_H */
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 04/25] x86: NUMA: Add accessors for acpi_numa, numa_off and numa_fake variables
Hi Vijay,
Quoted 4 lines · On 28/03/17 16:53, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
Add accessor functions for
acpi_numaandnuma_offstatic variables. Init value ofacpi_numais set 1 instead of 0.
Please explain why you change the acpi_numa value from 0 to 1.
Also, I am not sure to understand the benefits of those helpers. Why do you need them? Why not using the global variable directly, this will avoid to call a function just for returning a value...
Quoted 17 lines
Also return value of
srat_disabledis changed to bool.Signed-off-by Vijaya Kumar K <[email protected]>--- xen/arch/x86/numa.c | 43 +++++++++++++++++++++++++++++++------------ xen/arch/x86/setup.c | 2 +- xen/arch/x86/srat.c | 12 ++++++------ xen/include/asm-x86/acpi.h | 1 - xen/include/asm-x86/numa.h | 5 +---- xen/include/xen/numa.h | 3 +++ 6 files changed, 42 insertions(+), 24 deletions(-)xen/arch/x86/numa.c +0
-0
xen/arch/x86/numa.c cpumask_t __read_mostly node_to_cpumask[MAX_NUMNODES]; · line 46
Quoted 7 lines
xen/arch/x86/numa.c +2
-2@@ -42,12 +42,27 @@ cpumask_t __read_mostly node_to_cpumask[MAX_NUMNODES];nodemask_t __read_mostly node_online_map = { { [0 ] =1UL } }; -bool numa_off =0 ; -s8 acpi_numa =0 ; +static bool numa_off =0 ; +static bool acpi_numa =1 ;
Please don't mix 0/1 and bool. Instead use false/true.
Quoted 200 lines
xen/arch/x86/numa.c +29
-10-int srat_disabled (void ) +bool is_numa_off (void ) { -return numa_off || acpi_numa <0 ; +return numa_off; +} + +bool get_acpi_numa (void ) +{ +return acpi_numa; +} + +void set_acpi_numa (bool_t val) +{ + acpi_numa = val; +} + +bool srat_disabled (void ) +{ +return numa_off || acpi_numa ==0 ; }/* @@ -202,13 +217,17 @@ void __init numa_init_array(void)#ifdef CONFIG_NUMA_EMU static int __initdata numa_fake =0 ; +static int get_numa_fake (void ) +{ +return numa_fake; +}/* Numa emulation */ static int __init numa_emulation (uint64_t start_pfn,uint64_t end_pfn) {int i;struct node nodes[MAX_NUMNODES ]; -uint64_t sz = ((end_pfn - start_pfn) <<PAGE_SHIFT ) / numa_fake; +uint64_t sz = ((end_pfn - start_pfn) <<PAGE_SHIFT ) /get_numa_fake ();/* Kludge needed for the hash function */ if (hweight64 (sz) >1 )@@ -223,10 +242,10 @@ static int __init numa_emulation(uint64_t start_pfn, uint64_t end_pfn) }memset (&nodes,0 ,sizeof (nodes)); -for ( i =0 ; i < numa_fake; i++ ) +for ( i =0 ; i <get_numa_fake (); i++ ) { nodes[i].start = (start_pfn <<PAGE_SHIFT ) + i * sz; -if ( i == numa_fake -1 ) +if ( i ==get_numa_fake () -1 ) sz = (end_pfn <<PAGE_SHIFT ) - nodes[i].start; nodes[i].end = nodes[i].start + sz; printk(KERN_INFO@@ -235,7 +254,7 @@ static int __init numa_emulation(uint64_t start_pfn, uint64_t end_pfn) (nodes[i].end - nodes[i].start) >> 20);node_set_online (i); } -if (compute_memnode_shift (nodes, numa_fake,NULL , &memnode_shift) ) +if (compute_memnode_shift (nodes,get_numa_fake (),NULL , &memnode_shift) ) { memnode_shift =0 ;printk (KERN_ERR "No NUMA hash function found. Emulation disabled.\n" );@@ -254,18 +273,18 @@ void __init numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn)int i;#ifdef CONFIG_NUMA_EMU -if ( numa_fake && !numa_emulation (start_pfn, end_pfn) ) +if (get_numa_fake () && !numa_emulation (start_pfn, end_pfn) )return ;#endif #ifdef CONFIG_ACPI_NUMA -if ( !numa_off && !acpi_scan_nodes ((uint64_t )start_pfn <<PAGE_SHIFT , +if ( !is_numa_off () && !acpi_scan_nodes ((uint64_t )start_pfn <<PAGE_SHIFT , (uint64_t )end_pfn <<PAGE_SHIFT ) )return ;#endif printk (KERN_INFO "%s\n" , - numa_off ?"NUMA turned off" :"No NUMA configuration found" ); +is_numa_off () ?"NUMA turned off" :"No NUMA configuration found" ); printk(KERN_INFO "Faking a node at %016"PRIx64"-%016"PRIx64"\n", (uint64_t)start_pfn << PAGE_SHIFT,@@ -312,7 +331,7 @@ static int __init numa_setup(char *opt)if ( !strncmp (opt,"noacpi" ,6 ) ) { numa_off =0 ; - acpi_numa =-1 ; + acpi_numa =0 ; }#endif xen/arch/x86/setup.c +1
-1@@ -241,7 +241,7 @@ void srat_detect_node(int cpu)node_set_online (node);numa_set_node (cpu, node); -if ( opt_cpu_info && acpi_numa >0 ) +if ( opt_cpu_info &&get_acpi_numa () )printk ("CPU %d APIC %d -> Node %d\n" , cpu, apicid, node); }xen/arch/x86/srat.c +6
-6@@ -153,7 +153,7 @@ static void __init bad_srat(void) {int i;printk (KERN_ERR "SRAT: SRAT not used.\n" ); - acpi_numa =-1 ; +set_acpi_numa (0 );for (i =0 ; i <MAX_LOCAL_APIC ; i++) apicid_to_node[i] =NUMA_NO_NODE ;for (i =0 ; i <ARRAY_SIZE (pxm2node); i++)@@ -232,7 +232,7 @@ acpi_numa_x2apic_affinity_init(const struct acpi_srat_x2apic_cpu_affinity *pa) apicid_to_node[pa->apic_id] = node;node_set (node, processor_nodes_parsed); - acpi_numa =1 ; +set_acpi_numa (1 );printk (KERN_INFO "SRAT: PXM %u -> APIC %08x -> Node %u\n" , pxm, pa->apic_id, node); }@@ -265,7 +265,7 @@ acpi_numa_processor_affinity_init(const struct acpi_srat_cpu_affinity *pa) } apicid_to_node[pa->apic_id] = node;node_set (node, processor_nodes_parsed); - acpi_numa =1 ; +set_acpi_numa (1 );printk (KERN_INFO "SRAT: PXM %u -> APIC %02x -> Node %u\n" , pxm, pa->apic_id, node); }@@ -418,7 +418,7 @@ static int __init srat_parse_region(struct acpi_subtable_header *header, (ma->flags & ACPI_SRAT_MEM_NON_VOLATILE))return 0 ; -if (numa_off) +if (is_numa_off ())printk (KERN_INFO "SRAT: %013" PRIx64"-%013" PRIx64"\n" , ma->base_address, ma->base_address + ma->length -1 );@@ -433,7 +433,7 @@ void __init srat_parse_regions(uint64_t addr)uint64_t mask;unsigned int i; -if (acpi_disabled || acpi_numa <0 || +if (acpi_disabled || (get_acpi_numa () ==0 ) ||acpi_table_parse (ACPI_SIG_SRAT , acpi_parse_srat))return ;@@ -462,7 +462,7 @@ int __init acpi_scan_nodes(uint64_t start, uint64_t end)for (i =0 ; i <MAX_NUMNODES ; i++)cutoff_node (i, start, end); -if (acpi_numa <=0 ) +if (get_acpi_numa () ==0 )return -1 ;if (!nodes_cover_memory ()) {xen/include/asm-x86/acpi.h +0
-1@@ -103,7 +103,6 @@ extern void acpi_reserve_bootmem(void);#define ARCH_HAS_POWER_INIT 1 -extern s8 acpi_numa;extern int acpi_scan_nodes (u64 start,u64 end);#define NR_NODE_MEMBLKS (MAX_NUMNODES*2)xen/include/asm-x86/numa.h +1
-4@@ -30,10 +30,7 @@ extern nodeid_t pxm_to_node(unsigned int pxm);extern void numa_add_cpu (int cpu);extern void numa_init_array (void ); -extern bool_t numa_off; - - -extern int srat_disabled (void ); +extern bool srat_disabled (void );extern void numa_set_node (int cpu,nodeid_t node);extern nodeid_t setup_node (unsigned int pxm);extern void srat_detect_node (int cpu);xen/include/xen/numa.h +0
-0
xen/include/xen/numa.h line 23
Quoted 6 lines
xen/include/xen/numa.h +3
-0@@ -18,4 +18,7 @@ (((d)->vcpu !=NULL && (d)->vcpu[0 ] !=NULL ) \ ? vcpu_to_node((d)->vcpu[0]) : NUMA_NO_NODE) +bool is_numa_off (void ); +bool get_acpi_numa (void ); +void set_acpi_numa (bool val);
I am not sure to understand why you add those helpers directly here in xen/numa.h. IHMO, This should belong to the moving code patches.
Quoted 2 lines
xen/include/xen/numa.h +0
-0#endif /* _XEN_NUMA_H */
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 04/25] x86: NUMA: Add accessors for acpi_numa, numa_off and numa_fake variables
Quoted 11 lines · Julien Grall
Hi Vijay,
Quoted 5 lines · On 28/03/17 16:53, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
Add accessor functions for
acpi_numaandnuma_offstatic variables. Init value ofacpi_numais set 1 instead of 0.Please explain why you change the
acpi_numavalue from 0 to 1.
previously acpi_numa was s8 and are using 0 and -1 values. I have made it bool and set
the initial value to 1.
By setting 1, we are enabling acpi_numa by default. If not enabled, the below call has check srat_disabled() before proceeding fails.
acpi_numa_memory_affinity_init(const struct acpi_srat_mem_affinity *ma) {
....
if ( srat_disabled() )
return;
}
Quoted 4 lines
Also, I am not sure to understand the benefits of those helpers. Why do you need them? Why not using the global variable directly, this will avoid to call a function just for returning a value...
These helpers are used by both common code and arch specific code later. Hence made these global variables as static and added helpers
Quoted 22 lines
Quoted 22 lines
Also return value of
srat_disabledis changed to bool.Signed-off-by Vijaya Kumar K <[email protected]>--- xen/arch/x86/numa.c | 43 +++++++++++++++++++++++++++++++------------ xen/arch/x86/setup.c | 2 +- xen/arch/x86/srat.c | 12 ++++++------ xen/include/asm-x86/acpi.h | 1 - xen/include/asm-x86/numa.h | 5 +---- xen/include/xen/numa.h | 3 +++ 6 files changed, 42 insertions(+), 24 deletions(-)xen/arch/x86/numa.c +0
-0@@ -42,12 +42,27 @@ cpumask_t __read_mostly node_to_cpumask[MAX_NUMNODES];nodemask_t __read_mostly node_online_map = { { [0 ] =1UL } };
Quoted 7 lines
xen/arch/x86/numa.c cpumask_t __read_mostly node_to_cpumask[MAX_NUMNODES]; · line 46
Quoted 4 lines
xen/arch/x86/numa.c +2
-2-bool numa_off =0 ; -s8 acpi_numa =0 ; +static bool numa_off =0 ; +static bool acpi_numa =1 ;Please don't mix 0/1 and bool. Instead use false/true.
OK.
Quoted 218 lines
Quoted 218 lines
xen/arch/x86/numa.c +22
-3-int srat_disabled (void ) +bool is_numa_off (void ) { -return numa_off || acpi_numa <0 ; +return numa_off; +} + +bool get_acpi_numa (void ) +{ +return acpi_numa; +} + +void set_acpi_numa (bool_t val) +{ + acpi_numa = val; +} + +bool srat_disabled (void ) +{ +return numa_off || acpi_numa ==0 ; }/* @@ -202,13 +217,17 @@ void __init numa_init_array(void)#ifdef CONFIG_NUMA_EMU static int __initdata numa_fake =0 ; +static int get_numa_fake (void ) +{ +return numa_fake; +}/* Numa emulation */ static int __init numa_emulation (uint64_t start_pfn,uint64_t end_pfn) {int i;struct node nodes[MAX_NUMNODES ]; -uint64_t sz = ((end_pfn - start_pfn) <<PAGE_SHIFT ) / numa_fake; +uint64_t sz = ((end_pfn - start_pfn) <<PAGE_SHIFT ) /get_numa_fake ();/* Kludge needed for the hash function */ if ( hweight64(sz) > 1 )xen/arch/x86/numa.c +2
-2@@ -223,10 +242,10 @@ static int __init numa_emulation(uint64_t start_pfn, uint64_t end_pfn) }memset (&nodes,0 ,sizeof (nodes)); -for ( i =0 ; i < numa_fake; i++ ) +for ( i =0 ; i <get_numa_fake (); i++ ) { nodes[i].start = (start_pfn <<PAGE_SHIFT ) + i * sz; -if ( i == numa_fake -1 ) +if ( i ==get_numa_fake () -1 ) sz = (end_pfn <<PAGE_SHIFT ) - nodes[i].start; nodes[i].end = nodes[i].start + sz;printk(KERN_INFO
xen/arch/x86/numa.c +1
-1@@ -235,7 +254,7 @@ static int __init numa_emulation(uint64_t start_pfn, uint64_t end_pfn) (nodes[i].end - nodes[i].start) >> 20);node_set_online (i); } -if (compute_memnode_shift (nodes, numa_fake,NULL , &memnode_shift) ) +if (compute_memnode_shift (nodes,get_numa_fake (),NULL , &memnode_shift) ) {
memnode_shift= 0;
printk(KERN_ERR "No NUMA hash function found. Emulation
disabled.\n");xen/arch/x86/numa.c +3
-3@@ -254,18 +273,18 @@ void __init numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn)int i;#ifdef CONFIG_NUMA_EMU -if ( numa_fake && !numa_emulation (start_pfn, end_pfn) ) +if (get_numa_fake () && !numa_emulation (start_pfn, end_pfn) )return ;#endif #ifdef CONFIG_ACPI_NUMA -if ( !numa_off && !acpi_scan_nodes ((uint64_t )start_pfn <<PAGE_SHIFT , +if ( !is_numa_off () && !acpi_scan_nodes ((uint64_t )start_pfn <<PAGE_SHIFT , (uint64_t )end_pfn <<PAGE_SHIFT ) )return ;#endif printk (KERN_INFO "%s\n" , - numa_off ?"NUMA turned off" :"No NUMA configuration found" ); +is_numa_off () ?"NUMA turned off" :"No NUMA configuration found");printk(KERN_INFO "Faking a node at %016"PRIx64"-%016"PRIx64"\n", (uint64_t)start_pfn << PAGE_SHIFT,xen/arch/x86/numa.c +1
-1@@ -312,7 +331,7 @@ static int __init numa_setup(char *opt)if ( !strncmp (opt,"noacpi" ,6 ) ) { numa_off =0 ; - acpi_numa =-1 ; + acpi_numa =0 ; }#endif xen/arch/x86/setup.c +1
-1@@ -241,7 +241,7 @@ void srat_detect_node(int cpu)node_set_online (node);numa_set_node (cpu, node); -if ( opt_cpu_info && acpi_numa >0 ) +if ( opt_cpu_info &&get_acpi_numa () )printk ("CPU %d APIC %d -> Node %d\n" , cpu, apicid, node); }xen/arch/x86/srat.c +2
-2@@ -153,7 +153,7 @@ static void __init bad_srat(void) {int i;printk (KERN_ERR "SRAT: SRAT not used.\n" ); - acpi_numa =-1 ; +set_acpi_numa (0 );for (i =0 ; i <MAX_LOCAL_APIC ; i++) apicid_to_node[i] =NUMA_NO_NODE ;for (i =0 ; i <ARRAY_SIZE (pxm2node); i++)@@ -232,7 +232,7 @@ acpi_numa_x2apic_affinity_init(const struct acpi_srat_x2apic_cpu_affinity *pa) apicid_to_node[pa->apic_id] = node;node_set (node, processor_nodes_parsed); - acpi_numa =1 ; +set_acpi_numa (1 );printk (KERN_INFO "SRAT: PXM %u -> APIC %08x -> Node %u\n" , pxm, pa->apic_id, node);}
xen/arch/x86/srat.c +1
-1@@ -265,7 +265,7 @@ acpi_numa_processor_affinity_init(const struct acpi_srat_cpu_affinity *pa) } apicid_to_node[pa->apic_id] = node;node_set (node, processor_nodes_parsed); - acpi_numa =1 ; +set_acpi_numa (1 );printk (KERN_INFO "SRAT: PXM %u -> APIC %02x -> Node %u\n" , pxm, pa->apic_id, node);}
xen/arch/x86/srat.c +1
-1@@ -418,7 +418,7 @@ static int __init srat_parse_region(struct acpi_subtable_header *header, (ma->flags & ACPI_SRAT_MEM_NON_VOLATILE))return 0 ; -if (numa_off) +if (is_numa_off ()) printk(KERN_INFO "SRAT: %013"PRIx64"-%013"PRIx64"\n", ma->base_address, ma->base_address + ma->length -1);
xen/arch/x86/srat.c +2
-2@@ -433,7 +433,7 @@ void __init srat_parse_regions(uint64_t addr)uint64_t mask;unsigned int i; -if (acpi_disabled || acpi_numa <0 || +if (acpi_disabled || (get_acpi_numa () ==0 ) ||acpi_table_parse (ACPI_SIG_SRAT , acpi_parse_srat))return ;@@ -462,7 +462,7 @@ int __init acpi_scan_nodes(uint64_t start, uint64_t end)for (i =0 ; i <MAX_NUMNODES ; i++)cutoff_node (i, start, end); -if (acpi_numa <=0 ) +if (get_acpi_numa () ==0 )return -1 ;if (!nodes_cover_memory()) {xen/include/asm-x86/acpi.h +0
-1@@ -103,7 +103,6 @@ extern void acpi_reserve_bootmem(void);#define ARCH_HAS_POWER_INIT 1 -extern s8 acpi_numa;extern int acpi_scan_nodes (u64 start,u64 end);#define NR_NODE_MEMBLKS (MAX_NUMNODES*2)xen/include/asm-x86/numa.h +1
-4@@ -30,10 +30,7 @@ extern nodeid_t pxm_to_node(unsigned int pxm);extern void numa_add_cpu (int cpu);extern void numa_init_array (void ); -extern bool_t numa_off; - - -extern int srat_disabled (void ); +extern bool srat_disabled (void );extern void numa_set_node (int cpu,nodeid_t node);extern nodeid_t setup_node (unsigned int pxm);extern void srat_detect_node (int cpu);xen/include/xen/numa.h +0
-0@@ -18,4 +18,7 @@ (((d)->vcpu !=NULL && (d)->vcpu[0 ] !=NULL ) \ ?vcpu_to_node ((d)->vcpu[0 ]) :NUMA_NO_NODE )
Quoted 7 lines
xen/include/xen/numa.h line 23
Quoted 3 lines
xen/include/xen/numa.h +3
-0+bool is_numa_off (void ); +bool get_acpi_numa (void ); +void set_acpi_numa (bool val);I am not sure to understand why you add those helpers directly here in
xen/numa.h. IHMO, This should belong to the moving code patches.
To have code moving patches doing only code movement, I have exported in the patch it is defined.
Quoted 7 lines
xen/include/xen/numa.h line 24
Quoted 4 lines
xen/include/xen/numa.h +0
-0#endif /* _XEN_NUMA_H */ --
Julien Grall
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 04/25] x86: NUMA: Add accessors for acpi_numa, numa_off and numa_fake variables
Hello Vijay,
Quoted 11 lines · Vijay Kilari
Quoted 10 lines · Julien Grall
Hi Vijay,
Quoted 5 lines · On 28/03/17 16:53, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
Add accessor functions for
acpi_numaandnuma_offstatic variables. Init value ofacpi_numais set 1 instead of 0.
Quoted 5 lines
Quoted 1 line
Please explain why you change the
acpi_numavalue from 0 to 1.previously
acpi_numawas s8 and are using 0 and -1 values. I have made it bool and set
the initial value to 1.
Are you sure? With a quick grep I spot it sounds like acpi_numa can have the value 0, -1, 1.
Quoted 3 lines
By setting 1, we are enabling
acpi_numaby default. If not enabled, the below call has checksrat_disabled()before proceeding fails.
My understanding is on x86 acpi_numa is disabled by default and will be enabled if they are able to parse the SRAT. So why are you changing the behavior for x86?
Quoted 11 lines
acpi_numa_memory_affinity_init(const struct acpi_srat_mem_affinity *ma){
....if (
srat_disabled())
return;}
Quoted 1 line
Quoted 6 lines
Quoted 3 lines
Also, I am not sure to understand the benefits of those helpers. Why do you need them? Why not using the global variable directly, this will avoid to call a function just for returning a value...
These helpers are used by both common code and arch specific code later. Hence made these global variables as static and added helpers
The variables were global so they could already be used anywhere.
Furthermore, those helpers are not even inlined, so everytime you want to access read acpi_numa you have to do a branch then a memory access.
So what is the point to do that?
Quoted 44 lines
Quoted 36 lines
Quoted 36 lines
xen/include/asm-x86/acpi.h +0
-1@@ -103,7 +103,6 @@ extern void acpi_reserve_bootmem(void);#define ARCH_HAS_POWER_INIT 1 -extern s8 acpi_numa;extern int acpi_scan_nodes (u64 start,u64 end);#define NR_NODE_MEMBLKS (MAX_NUMNODES*2)xen/include/asm-x86/numa.h +1
-4@@ -30,10 +30,7 @@ extern nodeid_t pxm_to_node(unsigned int pxm);extern void numa_add_cpu (int cpu);extern void numa_init_array (void ); -extern bool_t numa_off; - - -extern int srat_disabled (void ); +extern bool srat_disabled (void );extern void numa_set_node (int cpu,nodeid_t node);extern nodeid_t setup_node (unsigned int pxm);extern void srat_detect_node (int cpu);xen/include/xen/numa.h +0
-0@@ -18,4 +18,7 @@ (((d)->vcpu !=NULL && (d)->vcpu[0 ] !=NULL ) \ ?vcpu_to_node ((d)->vcpu[0 ]) :NUMA_NO_NODE )Quoted 7 lines
xen/include/xen/numa.h line 23
Quoted 3 lines
xen/include/xen/numa.h +3
-0+bool is_numa_off (void ); +bool get_acpi_numa (void ); +void set_acpi_numa (bool val);I am not sure to understand why you add those helpers directly here in
xen/numa.h. IHMO, This should belong to the moving code patches.
Quoted 2 lines
To have code moving patches doing only code movement, I have exported in the patch it is defined.
Sorry but what are prototypes if not code?
The point of moving the prototypes in the patch which move the actual declarations is helping the reviewers to check if you correctly moved everything.
Quoted 8 lines
Quoted 8 lines
xen/include/xen/numa.h line 24
Quoted 5 lines
xen/include/xen/numa.h +0
-0#endif /* _XEN_NUMA_H */ --
Julien Grall
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 04/25] x86: NUMA: Add accessors for acpi_numa, numa_off and numa_fake variables
Quoted 22 lines · Julien Grall
Hello Vijay,
Quoted 19 lines · Vijay Kilari
Quoted 14 lines · Julien Grall
Hi Vijay,
Quoted 6 lines · On 28/03/17 16:53, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
Add accessor functions for
acpi_numaandnuma_offstatic variables. Init value ofacpi_numais set 1 instead of 0.Please explain why you change the
acpi_numavalue from 0 to 1.
Quoted 8 lines
Quoted 3 lines
previously
acpi_numawas s8 and are using 0 and -1 values. I have made it bool and set
the initial value to 1.Are you sure? With a quick grep I spot it sounds like
acpi_numacan have the value 0, -1, 1.
Hmm.. But I don't see use of having 0, -1 and 1. But I don't see any use of having 3 values to say enable or disable.
Quoted 9 lines
Quoted 4 lines
By setting 1, we are enabling
acpi_numaby default. If not enabled, the below
call has checksrat_disabled()before proceeding fails.My understanding is on x86
acpi_numais disabled by default and will be enabled if they are able to parse the SRAT. So why are you changing the behavior for x86?
acpi_numa = 0 means it is enabled by default on x86.
Quoted 22 lines
Quoted 12 lines
acpi_numa_memory_affinity_init(const struct acpi_srat_mem_affinity *ma){
....if (
srat_disabled())
return;}
Quoted 1 line
Quoted 8 lines
Quoted 4 lines
Also, I am not sure to understand the benefits of those helpers. Why do you
need them? Why not using the global variable directly, this will avoid to call a function just for returning a value...These helpers are used by both common code and arch specific code later. Hence made these global variables as static and added helpers
Quoted 6 lines
The variables were global so they could already be used anywhere.
Furthermore, those helpers are not even inlined, so everytime you want to access read
acpi_numayou have to do a branch then a memory access.So what is the point to do that?
I agree with making inline. But I don't think there is any harm in making them static and adding helpers.
Quoted 52 lines
Quoted 48 lines
Quoted 38 lines
Quoted 38 lines
xen/include/asm-x86/acpi.h +0
-1@@ -103,7 +103,6 @@ extern void acpi_reserve_bootmem(void);#define ARCH_HAS_POWER_INIT 1 -extern s8 acpi_numa;extern int acpi_scan_nodes (u64 start,u64 end);#define NR_NODE_MEMBLKS (MAX_NUMNODES*2)xen/include/asm-x86/numa.h +1
-4@@ -30,10 +30,7 @@ extern nodeid_t pxm_to_node(unsigned int pxm);extern void numa_add_cpu (int cpu);extern void numa_init_array (void ); -extern bool_t numa_off; - - -extern int srat_disabled (void ); +extern bool srat_disabled (void );extern void numa_set_node (int cpu,nodeid_t node);extern nodeid_t setup_node (unsigned int pxm);extern void srat_detect_node (int cpu);xen/include/xen/numa.h +0
-0@@ -18,4 +18,7 @@ (((d)->vcpu !=NULL && (d)->vcpu[0 ] !=NULL ) \ ?vcpu_to_node ((d)->vcpu[0 ]) :NUMA_NO_NODE )Quoted 8 lines
xen/include/xen/numa.h line 23
Quoted 3 lines
xen/include/xen/numa.h +3
-0+bool is_numa_off (void ); +bool get_acpi_numa (void ); +void set_acpi_numa (bool val);I am not sure to understand why you add those helpers directly here in
xen/numa.h. IHMO, This should belong to the moving code patches.Quoted 2 lines
To have code moving patches doing only code movement, I have exported in the patch it is defined.
Quoted 5 lines
Sorry but what are prototypes if not code?
The point of moving the prototypes in the patch which move the actual declarations is helping the reviewers to check if you correctly moved everything.
I am ok if it helps in review.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
xen/include/xen/numa.h +0
-0#endif /* _XEN_NUMA_H */
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
--
Julien Grall--
Julien Grall
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 04/25] x86: NUMA: Add accessors for acpi_numa, numa_off and numa_fake variables
Quoted 28 lines · Vijay Kilari
Quoted 27 lines · Julien Grall
Hello Vijay,
Quoted 22 lines · Vijay Kilari
Quoted 6 lines · Julien Grall
Hi Vijay,
Quoted 2 lines · On 28/03/17 16:53, [email protected] wrote:
Quoted 8 lines
Quoted 4 lines
From: Vijaya Kumar K <[email protected]>
Add accessor functions for
acpi_numaandnuma_offstatic variables. Init value ofacpi_numais set 1 instead of 0.Please explain why you change the
acpi_numavalue from 0 to 1.previously
acpi_numawas s8 and are using 0 and -1 values. I have made it bool and set
the initial value to 1.
Quoted 6 lines
Quoted 3 lines
Are you sure? With a quick grep I spot it sounds like
acpi_numacan have the value 0, -1, 1.Hmm.. But I don't see use of having 0, -1 and 1. But I don't see any use of having 3 values to say enable or disable.
Then explain why in the commit message and don't let people discover. If you have not done it, I would recommend to read:
https://wiki.xenproject.org/wiki/Submitting_Xen_Project_Patches
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
By setting 1, we are enabling
acpi_numaby default. If not enabled, the below
call has checksrat_disabled()before proceeding fails.
Quoted 5 lines
Quoted 3 lines
My understanding is on x86
acpi_numais disabled by default and will be enabled if they are able to parse the SRAT. So why are you changing the behavior for x86?
acpi_numa= 0 means it is enabled by default on x86.
In acpi_scan_nodes:
if (acpi_numa <= 0)
return -1;
So it does not seem that 0 means enabled.
Quoted 25 lines
Quoted 25 lines
Quoted 13 lines
acpi_numa_memory_affinity_init(const struct acpi_srat_mem_affinity *ma){
....if (
srat_disabled())
return;}
Quoted 1 line
Quoted 8 lines
Quoted 4 lines
Also, I am not sure to understand the benefits of those helpers. Why do you
need them? Why not using the global variable directly, this will avoid to call a function just for returning a value...These helpers are used by both common code and arch specific code later. Hence made these global variables as static and added helpers
The variables were global so they could already be used anywhere.
Quoted 7 lines
Quoted 4 lines
Furthermore, those helpers are not even inlined, so everytime you want to access read
acpi_numayou have to do a branch then a memory access.So what is the point to do that?
I agree with making inline. But I don't think there is any harm in making them static and adding helpers.
But why? Why don't you keep the code as it is? You modify code without any justification and not for the better.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 04/25] x86: NUMA: Add accessors for acpi_numa, numa_off and numa_fake variables
Quoted 71 lines · Julien Grall
Quoted 37 lines · Vijay Kilari
Quoted 34 lines · Julien Grall
Hello Vijay,
Quoted 27 lines · Vijay Kilari
Quoted 10 lines · Julien Grall
Hi Vijay,
Quoted 5 lines · On 28/03/17 16:53, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
Quoted 7 lines
Quoted 2 lines
Add accessor functions for
acpi_numaandnuma_offstatic variables. Init value ofacpi_numais set 1 instead of 0.Please explain why you change the
acpi_numavalue from 0 to 1.previously
acpi_numawas s8 and are using 0 and -1 values. I have made it bool and set
the initial value to 1.Quoted 8 lines
Quoted 4 lines
Are you sure? With a quick grep I spot it sounds like
acpi_numacan have the
value 0, -1, 1.Hmm.. But I don't see use of having 0, -1 and 1. But I don't see any use of
having 3 values to say enable or disable.Then explain why in the commit message and don't let people discover. If you have not done it, I would recommend to read:
https://wiki.xenproject.org/wiki/Submitting_Xen_Project_Patches
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
By setting 1, we are enabling
acpi_numaby default. If not enabled, the below
call has checksrat_disabled()before proceeding fails.Quoted 6 lines
Quoted 3 lines
My understanding is on x86
acpi_numais disabled by default and will be enabled if they are able to parse the SRAT. So why are you changing the behavior for x86?
acpi_numa= 0 means it is enabled by default on x86.
Quoted 6 lines
In
acpi_scan_nodes:if (
acpi_numa<= 0)
return -1;So it does not seem that 0 means enabled.
IMO, In x86
-1 means disabled
0 enabled but not numa initialized
1 enabled and numa initialized.
I clubbed 0 & 1.
I was referring to below code in x86 where in acpi_numa = 0 means srat_disabled() returns false. Which means acpi_numa is enabled implicitly.
int srat_disabled(void)
{
return numa_off || acpi_numa < 0;
}When I changed acpi_numa to bool, it is initialized to 1 and changed below code.
bool srat_disabled(void)
{
return numa_off || acpi_numa == 0;
}Also this srat_disabed() is used in acpi_numa_memory_affinity_init which is called from acpi_numa_init() before calling acpi_scan_nodes().
Quoted 40 lines
Quoted 32 lines
Quoted 32 lines
Quoted 22 lines
acpi_numa_memory_affinity_init(const struct acpi_srat_mem_affinity *ma){
....if (
srat_disabled())
return;}
Quoted 6 lines
Also, I am not sure to understand the benefits of those helpers. Why do you
need them? Why not using the global variable directly, this will avoid to
call a function just for returning a value...Quoted 2 lines
These helpers are used by both common code and arch specific code later. Hence made these global variables as static and added helpers
The variables were global so they could already be used anywhere.
Furthermore, those helpers are not even inlined, so everytime you want to access read
acpi_numayou have to do a branch then a memory access.Quoted 6 lines
Quoted 1 line
So what is the point to do that?
I agree with making inline. But I don't think there is any harm in making them
static and adding helpers.
Quoted 7 lines
But why? Why don't you keep the code as it is? You modify code without any justification and not for the better.
Cheers,
--
Julien Grall
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 04/25] x86: NUMA: Add accessors for acpi_numa, numa_off and numa_fake variables
Quoted 21 lines · Vijay Kilari
Quoted 20 lines · Julien Grall
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
By setting 1, we are enabling
acpi_numaby default. If not enabled, the below
call has checksrat_disabled()before proceeding fails.Quoted 6 lines
Quoted 3 lines
My understanding is on x86
acpi_numais disabled by default and will be enabled if they are able to parse the SRAT. So why are you changing the behavior for x86?
acpi_numa= 0 means it is enabled by default on x86.In
acpi_scan_nodes:if (
acpi_numa<= 0)
return -1;
Quoted 8 lines
Quoted 1 line
So it does not seem that 0 means enabled.
IMO, In x86
-1 means disabled
0 enabled but not numa initialized
1 enabled and numa initialized.I clubbed 0 & 1.
From your description 0 and 1 have different meaning, so I don't see how you can merge them that easily without any explanation.
Anyway, I will leave x86 maintainers give their opinion here.
Quoted 19 lines
I was referring to below code in x86 where in
acpi_numa= 0 meanssrat_disabled()returns false. Which meansacpi_numais enabled implicitly.int
srat_disabled(void){ return numa_off || acpi_numa < 0; }When I changed
acpi_numato bool, it is initialized to 1 and changed below code.bool
srat_disabled(void){ return numa_off || acpi_numa == 0; }Also this
srat_disabed()is used inacpi_numa_memory_affinity_initwhich is called fromacpi_numa_init()before callingacpi_scan_nodes().
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 04/25] x86: NUMA: Add accessors for acpi_numa, numa_off and numa_fake variables
Quoted 30 lines
Quoted 1 line
Quoted 1 line · On 25.04.17 at 17:14, <[email protected]> wrote:
Quoted 28 lines · Vijay Kilari
Quoted 15 lines · Julien Grall
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
By setting 1, we are enabling
acpi_numaby default. If not enabled, the below
call has checksrat_disabled()before proceeding fails.Quoted 6 lines
Quoted 3 lines
My understanding is on x86
acpi_numais disabled by default and will be enabled if they are able to parse the SRAT. So why are you changing the behavior for x86?
acpi_numa= 0 means it is enabled by default on x86.Quoted 6 lines
In
acpi_scan_nodes:if (
acpi_numa<= 0)
return -1;So it does not seem that 0 means enabled.
IMO, In x86
-1 means disabled
0 enabled but not numa initialized
1 enabled and numa initialized.
Quoted 6 lines
Quoted 1 line
I clubbed 0 & 1.
From your description 0 and 1 have different meaning, so I don't see
how you can merge them that easily without any explanation.Anyway, I will leave x86 maintainers give their opinion here.
I'm pretty certain this needs to remain a tristate.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 04/25] x86: NUMA: Add accessors for acpi_numa, numa_off and numa_fake variables
Quoted 30 lines · Jan Beulich
Quoted 30 lines
Quoted 1 line
Quoted 1 line · On 25.04.17 at 17:14, <[email protected]> wrote:
Quoted 28 lines · Vijay Kilari
Quoted 15 lines · Julien Grall
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
By setting 1, we are enabling
acpi_numaby default. If not enabled, the below
call has checksrat_disabled()before proceeding fails.Quoted 6 lines
Quoted 3 lines
My understanding is on x86
acpi_numais disabled by default and will be enabled if they are able to parse the SRAT. So why are you changing the behavior for x86?
acpi_numa= 0 means it is enabled by default on x86.Quoted 6 lines
In
acpi_scan_nodes:if (
acpi_numa<= 0)
return -1;So it does not seem that 0 means enabled.
IMO, In x86
-1 means disabled
0 enabled but not numa initialized
1 enabled and numa initialized.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
I clubbed 0 & 1.
From your description 0 and 1 have different meaning, so I don't see
how you can merge them that easily without any explanation.Anyway, I will leave x86 maintainers give their opinion here.
I'm pretty certain this needs to remain a tristate.
Ok. I will drop this patch from this series and can be fixed outside this series.
BTW, any review comments on remaining patches?
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 04/25] x86: NUMA: Add accessors for acpi_numa, numa_off and numa_fake variables
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 02.05.17 at 11:47, <[email protected]> wrote:
BTW, any review comments on remaining patches?
I didn't even manage to get to the start of the flood of RFCs posted during the last 1.5 months (which priority wise all sit behind the various non-RFC postings), so I can't predict when I'll get to yours. Also please remember that the focus right now is to make 4.9 good quality ...
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 04/25] x86: NUMA: Add accessors for acpi_numa, numa_off and numa_fake variables
In reply to Vijay KilariHi Vijay,
Quoted 36 lines · Vijay Kilari
Quoted 35 lines · Jan Beulich
Quoted 35 lines
Quoted 1 line
Quoted 1 line · On 25.04.17 at 17:14, <[email protected]> wrote:
Quoted 21 lines · Vijay Kilari
Quoted 20 lines · Julien Grall
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
By setting 1, we are enabling
acpi_numaby default. If not enabled, the below
call has checksrat_disabled()before proceeding fails.Quoted 6 lines
Quoted 3 lines
My understanding is on x86
acpi_numais disabled by default and will be enabled if they are able to parse the SRAT. So why are you changing the behavior for x86?
acpi_numa= 0 means it is enabled by default on x86.In
acpi_scan_nodes:if (
acpi_numa<= 0)
return -1;Quoted 8 lines
Quoted 1 line
So it does not seem that 0 means enabled.
IMO, In x86
-1 means disabled
0 enabled but not numa initialized
1 enabled and numa initialized.I clubbed 0 & 1.
From your description 0 and 1 have different meaning, so I don't see
how you can merge them that easily without any explanation.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Anyway, I will leave x86 maintainers give their opinion here.
I'm pretty certain this needs to remain a tristate.
Ok. I will drop this patch from this series and can be fixed outside this series.
BTW, any review comments on remaining patches?
I had a looked at the series and decided to stop reviewing it because comments are not addressed.
I am not going to review anything until *all* the comments from previous version are addressed. I would recommend the other to do the same.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 04/25] x86: NUMA: Add accessors for acpi_numa, numa_off and numa_fake variables
In reply to [email protected]Quoted 4 lines
Quoted 1 line
Quoted 1 line
<[email protected]> 03/28/17 5:55 PM >>>
xen/arch/x86/numa.c cpumask_t __read_mostly node_to_cpumask[MAX_NUMNODES]; · line 48
Quoted 10 lines
xen/arch/x86/numa.c +3
-3@@ -42,12 +42,27 @@ cpumask_t __read_mostly node_to_cpumask[MAX_NUMNODES];nodemask_t __read_mostly node_online_map = { { [0 ] =1UL } }; -bool numa_off =0 ; -s8 acpi_numa =0 ; +static bool numa_off =0 ; +static bool acpi_numa =1 ; -int srat_disabled (void ) +bool is_numa_off (void )
numa_enabled() (or less desirably numa_disabled())
xen/arch/x86/numa.c cpumask_t __read_mostly node_to_cpumask[MAX_NUMNODES]; · line 53
Quoted 1 line
xen/arch/x86/numa.c +1
-0+bool get_acpi_numa (void )
acpi_numa_enabled() then perhaps.
Iirc Julien has already commented on the non-boolean nature of acpi_numa.
xen/arch/x86/numa.c void __init numa_init_array(void) · line 223
Quoted 8 lines
xen/arch/x86/numa.c +4
-0@@ -202,13 +217,17 @@ void __init numa_init_array(void)#ifdef CONFIG_NUMA_EMU static int __initdata numa_fake =0 ; +static int get_numa_fake (void ) +{ +return numa_fake; +}
I don't see the point of having static accessors for static variables. Even if the accessor became non-static, I'd expect it to be used only in other translation units.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
RFC PATCH v2 5/25 x86: NUMA: Move generic dummy_numa_init to separate function
In reply to [email protected]From: Vijaya Kumar K <[email protected]>
Split numa_initmem_init() so that the numa fallback code is moved as separate function which is generic.
--- xen/arch/x86/numa.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-)
xen/arch/x86/numa.c +17 -12
@@ -268,21 +268,10 @@ static int __init numa_emulation(uint64_t start_pfn, uint64_t end_pfn) }#endif -void __init numa_initmem_init (unsigned long start_pfn,unsigned long end_pfn) +static void __init numa_dummy_init (unsigned long start_pfn,unsigned long end_pfn) {int i; -#ifdef CONFIG_NUMA_EMU -if (get_numa_fake () && !numa_emulation (start_pfn, end_pfn) ) -return ; -#endif - -#ifdef CONFIG_ACPI_NUMA -if ( !is_numa_off () && !acpi_scan_nodes ((uint64_t )start_pfn <<PAGE_SHIFT , - (uint64_t )end_pfn <<PAGE_SHIFT ) ) -return ; -#endif -printk (KERN_INFO "%s\n" ,is_numa_off () ?"NUMA turned off" :"No NUMA configuration found" );
@@ -301,6 +290,22 @@ void __init numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn) (paddr_t)end_pfn << PAGE_SHIFT); } +void __init numa_initmem_init (unsigned long start_pfn,unsigned long end_pfn) +{ +#ifdef CONFIG_NUMA_EMU +if (get_numa_fake () && !numa_emulation (start_pfn, end_pfn) ) +return ; +#endif + +#ifdef CONFIG_ACPI_NUMA +if ( !is_numa_off () && !acpi_scan_nodes ((uint64_t )start_pfn <<PAGE_SHIFT , + (uint64_t )end_pfn <<PAGE_SHIFT ) ) +return ; +#endif + +numa_dummy_init (start_pfn, end_pfn); +} +void numa_add_cpu (int cpu) {cpumask_set_cpu (cpu, &node_to_cpumask[cpu_to_node (cpu)]);
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 05/25] x86: NUMA: Move generic dummy_numa_init to separate function
Hi Vijay,
Quoted 38 lines · On 28/03/17 16:53, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
Split
numa_initmem_init()so that the numa fallback code is moved as separate function which is generic.Signed-off-by Vijaya Kumar K <[email protected]>--- xen/arch/x86/numa.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-)xen/arch/x86/numa.c +1
-12@@ -268,21 +268,10 @@ static int __init numa_emulation(uint64_t start_pfn, uint64_t end_pfn) }#endif -void __init numa_initmem_init (unsigned long start_pfn,unsigned long end_pfn) +static void __init numa_dummy_init (unsigned long start_pfn,unsigned long end_pfn) {int i; -#ifdef CONFIG_NUMA_EMU -if (get_numa_fake () && !numa_emulation (start_pfn, end_pfn) ) -return ; -#endif - -#ifdef CONFIG_ACPI_NUMA -if ( !is_numa_off () && !acpi_scan_nodes ((uint64_t )start_pfn <<PAGE_SHIFT , - (uint64_t )end_pfn <<PAGE_SHIFT ) ) -return ; -#endif -printk (KERN_INFO "%s\n" ,is_numa_off () ?"NUMA turned off" :"No NUMA configuration found" );
xen/arch/x86/numa.c void __init numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn) · line 298
Quoted 9 lines
xen/arch/x86/numa.c +6
-0@@ -301,6 +290,22 @@ void __init numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn) (paddr_t)end_pfn << PAGE_SHIFT); } +void __init numa_initmem_init (unsigned long start_pfn,unsigned long end_pfn) +{ +#ifdef CONFIG_NUMA_EMU +if (get_numa_fake () && !numa_emulation (start_pfn, end_pfn) ) +return ; +#endif
I am not sure where to comment about it in this series, so I will say it here.
As asked on v1, why don't you consider fake NUMA? This would help to test the series on non-NUMA platform.
Quoted 4 lines
xen/arch/x86/numa.c +3
-0+ +#ifdef CONFIG_ACPI_NUMA + if ( !is_numa_off() && !acpi_scan_nodes((uint64_t)start_pfn << PAGE_SHIFT,
xen/arch/x86/numa.c void __init numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn) · line 311
Quoted 10 lines
xen/arch/x86/numa.c +7
-0+ (uint64_t)end_pfn << PAGE_SHIFT) ) +return ; +#endif + +numa_dummy_init (start_pfn, end_pfn); +} +void numa_add_cpu (int cpu) {cpumask_set_cpu (cpu, &node_to_cpumask[cpu_to_node (cpu)]);
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 05/25] x86: NUMA: Move generic dummy_numa_init to separate function
Quoted 64 lines · Julien Grall
Hi Vijay,
Quoted 45 lines · On 28/03/17 16:53, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
Split
numa_initmem_init()so that the numa fallback code is moved as separate function which is generic.Signed-off-by Vijaya Kumar K <[email protected]>--- xen/arch/x86/numa.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-)xen/arch/x86/numa.c +1
-8@@ -268,21 +268,10 @@ static int __init numa_emulation(uint64_t start_pfn, uint64_t end_pfn) }#endif -void __init numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn) +static void __init numa_dummy_init(unsigned long start_pfn, unsigned long end_pfn) {int i; -#ifdef CONFIG_NUMA_EMU - if ( get_numa_fake() && !numa_emulation(start_pfn, end_pfn) ) - return; -#endif - -#ifdef CONFIG_ACPI_NUMA - if ( !is_numa_off() && !acpi_scan_nodes((uint64_t)start_pfn <<
PAGE_SHIFT,xen/arch/x86/numa.c +0
-4- (uint64_t)end_pfn << PAGE_SHIFT) ) -return ; -#endif - printk(KERN_INFO "%s\n", is_numa_off() ? "NUMA turned off" : "No NUMA configurationfound");
xen/arch/x86/numa.c +0
-0@@ -301,6 +290,22 @@ void __init numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn)xen/arch/x86/numa.c void __init numa_initmem_init(unsigned long · line 300
Quoted 10 lines
xen/arch/x86/numa.c +6
-0(paddr_t)end_pfn << PAGE_SHIFT); } +void __init numa_initmem_init (unsigned long start_pfn,unsigned long end_pfn) +{ +#ifdef CONFIG_NUMA_EMU +if (get_numa_fake () && !numa_emulation (start_pfn, end_pfn) ) +return ; +#endif I am not sure where to comment about it in this series, so I will say it here.
Quoted 2 lines
As asked on v1, why don't you consider fake NUMA? This would help to test the series on non-NUMA platform.
I have not tested non-NUMA case with this series. Agreed this two lines should be added
to numa_initmem_init() of arm (xen/arch/arm/numa/numa.c)
Quoted 19 lines
Quoted 13 lines
xen/arch/x86/numa.c +10
-0+ +#ifdef CONFIG_ACPI_NUMA +if ( !is_numa_off () && !acpi_scan_nodes ((uint64_t )start_pfn <<PAGE_SHIFT , + (uint64_t )end_pfn <<PAGE_SHIFT ) ) +return ; +#endif + +numa_dummy_init (start_pfn, end_pfn); +} +void
numa_add_cpu(int cpu)Quoted 3 lines
{ cpumask_set_cpu(cpu, &node_to_cpumask[cpu_to_node(cpu)]);Cheers,
Quoted 2 lines
--
Julien Grall
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 05/25] x86: NUMA: Move generic dummy_numa_init to separate function
In reply to [email protected]Quoted 5 lines
Quoted 1 line
Quoted 1 line
<[email protected]> 03/28/17 5:54 PM >>>
xen/arch/x86/numa.c +0
-0@@ -301,6 +290,22 @@ void __init numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn) (paddr_t)end_pfn << PAGE_SHIFT); }
xen/arch/x86/numa.c void __init numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn) · line 302
Quoted 10 lines
xen/arch/x86/numa.c +10
-0+void __init numa_initmem_init (unsigned long start_pfn,unsigned long end_pfn) +{ +#ifdef CONFIG_NUMA_EMU +if (get_numa_fake () && !numa_emulation (start_pfn, end_pfn) ) +return ; +#endif + +#ifdef CONFIG_ACPI_NUMA +if ( !is_numa_off () && !acpi_scan_nodes ((uint64_t )start_pfn <<PAGE_SHIFT , + (uint64_t )end_pfn <<PAGE_SHIFT ) )
Please use pfn_to_paddr() as you move this code.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
RFC PATCH v2 6/25 x86: NUMA: Add accessors for nodes[] and node_memblk_range[] structs
In reply to [email protected]From: Vijaya Kumar K <[email protected]>
Add accessor for nodes[] and other static variables and used those accessors.
--- xen/arch/x86/srat.c | 108 +++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 82 insertions(+), 26 deletions(-)
xen/arch/x86/srat.c +82 -26
@@ -41,7 +41,45 @@ 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); -static inline bool node_found (unsigned idx,unsigned pxm) +static struct node *get_numa_node (int id) +{ +return &nodes[id]; +} + +static nodeid_t get_memblk_nodeid (int id) +{ +return memblk_nodeid[id]; +} + +static nodeid_t *get_memblk_nodeid_map (void ) +{ +return &memblk_nodeid[0 ]; +} + +static struct node *get_node_memblk_range (int memblk) +{ +return &node_memblk_range[memblk]; +} + +static int get_num_node_memblks (void ) +{ +return num_node_memblks; +} + +static int __init numa_add_memblk (nodeid_t nodeid,paddr_t start,uint64_t size) +{ +if (nodeid >=NR_NODE_MEMBLKS ) +return -EINVAL ; + + node_memblk_range[num_node_memblks].start = start; + node_memblk_range[num_node_memblks].end = start + size; + memblk_nodeid[num_node_memblks] = nodeid; + num_node_memblks++; + +return 0 ; +} + +static inline bool node_found (unsigned int idx,unsigned int pxm) {return ((pxm2node[idx].pxm == pxm) && (pxm2node[idx].node !=NUMA_NO_NODE ));
@@ -107,11 +145,11 @@ int valid_numa_range(paddr_t start, paddr_t end, nodeid_t node) {int i; -for (i =0 ; i < num_node_memblks; i++) { -struct node *nd = &node_memblk_range[i]; +for (i =0 ; i <get_num_node_memblks (); i++) { +struct node *nd =get_node_memblk_range (i);if (nd->start <= start && nd->end > end && - memblk_nodeid[i] == node ) +get_memblk_nodeid (i) == node)return 1 ; }
@@ -122,8 +160,8 @@ static int __init conflicting_memblks(paddr_t start, paddr_t end) {int i; -for (i =0 ; i < num_node_memblks; i++) { -struct node *nd = &node_memblk_range[i]; +for (i =0 ; i <get_num_node_memblks (); i++) { +struct node *nd =get_node_memblk_range (i);if (nd->start == nd->end)continue ;if (nd->end > start && nd->start < end)
@@ -136,7 +174,8 @@ static int __init conflicting_memblks(paddr_t start, paddr_t end)static void __init cutoff_node (int i,paddr_t start,paddr_t end) { -struct node *nd = &nodes[i]; +struct node *nd =get_numa_node (i); +if (nd->start < start) { nd->start = start;if (nd->end < nd->start)
@@ -278,6 +317,7 @@ acpi_numa_memory_affinity_init(const struct acpi_srat_mem_affinity *ma)unsigned pxm;nodeid_t node;int i; +struct node *memblk;if (srat_disabled ())return ;
@@ -288,7 +328,7 @@ acpi_numa_memory_affinity_init(const struct acpi_srat_mem_affinity *ma)if (!(ma->flags &ACPI_SRAT_MEM_ENABLED ))return ; -if (num_node_memblks >=NR_NODE_MEMBLKS ) +if (get_num_node_memblks () >=NR_NODE_MEMBLKS ) {dprintk (XENLOG_WARNING ,"Too many numa entry, try bigger NR_NODE_MEMBLKS \n" );
@@ -310,27 +350,31 @@ acpi_numa_memory_affinity_init(const struct acpi_srat_mem_affinity *ma) i =conflicting_memblks (start, end);if (i <0 )/* everything fine */ ; -else if (memblk_nodeid[i] == node) { +else if (get_memblk_nodeid (i) == node) {bool mismatch = !(ma->flags &ACPI_SRAT_MEM_HOT_PLUGGABLE ) != !test_bit (i, memblk_hotplug); + memblk =get_node_memblk_range (i); +printk ("%sSRAT: PXM %u (%" PRIx64"-%" PRIx64") overlaps with itself (%" PRIx64"-%" PRIx64")\n" , mismatch ?KERN_ERR :KERN_WARNING , pxm, start, end, - node_memblk_range[i].start, node_memblk_range[i].end); + memblk->start, memblk->end);if (mismatch) {bad_srat ();return ; } }else { + memblk =get_node_memblk_range (i); +printk (KERN_ERR "SRAT: PXM %u (%" PRIx64"-%" PRIx64") overlaps with PXM %u (%" PRIx64"-%" PRIx64")\n" , - pxm, start, end,node_to_pxm (memblk_nodeid[i]), - node_memblk_range[i].start, node_memblk_range[i].end); + pxm, start, end,node_to_pxm (get_memblk_nodeid (i)), + memblk->start, memblk->end);bad_srat ();return ; }if (!(ma->flags &ACPI_SRAT_MEM_HOT_PLUGGABLE )) { -struct node *nd = &nodes[node]; +struct node *nd =get_numa_node (node);if (!node_test_and_set (node, memory_nodes_parsed)) { nd->start = start;
@@ -346,15 +390,17 @@ acpi_numa_memory_affinity_init(const struct acpi_srat_mem_affinity *ma) node, pxm, start, end, 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; +if (numa_add_memblk (node, start, ma->length)) { +printk (KERN_ERR "SRAT: node-id %u out of range\n" , node); +bad_srat (); +return ; + } +if (ma->flags &ACPI_SRAT_MEM_HOT_PLUGGABLE ) { -__set_bit (num_node_memblks, memblk_hotplug); +__set_bit (get_num_node_memblks (), memblk_hotplug);if (end > mem_hotplug) mem_hotplug = end; } - num_node_memblks++; }/* Sanity check to catch more bad SRATs (they are amazingly common).
@@ -377,17 +423,21 @@ static int __init nodes_cover_memory(void)do { found =0 ;for_each_node_mask (j, memory_nodes_parsed) -if (start < nodes[j].end - && end > nodes[j].start) { -if (start >= nodes[j].start) { - start = nodes[j].end; + { +struct node *nd =get_numa_node (j); + +if (start < nd->end + && end > nd->start) { +if (start >= nd->start) { + start = nd->end; found =1 ; } -if (end <= nodes[j].end) { - end = nodes[j].start; +if (end <= nd->end) { + end = nd->start; found =1 ; } } + } }while (found && start < end);if (start < end) {
@@ -457,6 +507,8 @@ int __init acpi_scan_nodes(uint64_t start, uint64_t end) {int i;nodemask_t all_nodes_parsed; +struct node *memblks; +nodeid_t *nodeids;/* First clean up the node list */ for (i =0 ; i <MAX_NUMNODES ; i++)
@@ -470,6 +522,8 @@ int __init acpi_scan_nodes(uint64_t start, uint64_t end)return -1 ; } + memblks =get_node_memblk_range (0 ); + nodeids =get_memblk_nodeid_map ();if (compute_memnode_shift (node_memblk_range, num_node_memblks, memblk_nodeid, &memnode_shift)) { memnode_shift =0 ;
@@ -484,12 +538,14 @@ int __init acpi_scan_nodes(uint64_t start, uint64_t end)/* Finally register nodes */ for_each_node_mask (i, all_nodes_parsed) { -uint64_t size = nodes[i].end - nodes[i].start; +struct node *nd =get_numa_node (i); +uint64_t size = nd->end - nd->start; +if ( size ==0 )printk (KERN_WARNING "SRAT: Node %u has no memory. " "BIOS Bug or mis-configured hardware?\n" , i); -setup_node_bootmem (i, nodes[i].start, nodes[i].end); +setup_node_bootmem (i, nd->start, nd->end); }for (i =0 ; i < nr_cpu_ids; i++) {if (cpu_to_node[i] ==NUMA_NO_NODE )
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 06/25] x86: NUMA: Add accessors for nodes[] and node_memblk_range[] structs
Hi Vijay,
Quoted 3 lines · On 28/03/17 16:53, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
Add accessor for nodes[] and other static variables and
s/accessor/accessors/
Quoted 1 line
used those accessors.
Also, I am not sure to understand the usefulness of those accessors over a global variable.
Quoted 10 lines
Signed-off-by Vijaya Kumar K <[email protected]>--- xen/arch/x86/srat.c | 108 +++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 82 insertions(+), 26 deletions(-)xen/arch/x86/srat.c +0
-0
xen/arch/x86/srat.c static struct node node_memblk_range[NR_NODE_MEMBLKS]; · line 44
Quoted 5 lines
xen/arch/x86/srat.c +1
-1@@ -41,7 +41,45 @@ 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); -static inline bool node_found (unsigned idx,unsigned pxm) +static struct node *get_numa_node (int id)
unsigned int.
xen/arch/x86/srat.c static struct node node_memblk_range[NR_NODE_MEMBLKS]; · line 49
Quoted 5 lines
xen/arch/x86/srat.c +5
-0+{ +return &nodes[id]; +} + +static nodeid_t get_memblk_nodeid (int id)
unsigned int.
xen/arch/x86/srat.c static struct node node_memblk_range[NR_NODE_MEMBLKS]; · line 59
Quoted 10 lines
xen/arch/x86/srat.c +10
-0+{ +return memblk_nodeid[id]; +} + +static nodeid_t *get_memblk_nodeid_map (void ) +{ +return &memblk_nodeid[0 ]; +} + +static struct node *get_node_memblk_range (int memblk)
unsigned int.
Quoted 13 lines
xen/arch/x86/srat.c +13
-0+{ +return &node_memblk_range[memblk]; +} + +static int get_num_node_memblks (void ) +{ +return num_node_memblks; +} + +static int __init numa_add_memblk (nodeid_t nodeid,paddr_t start,uint64_t size) +{ +if (nodeid >=NR_NODE_MEMBLKS ) +return -EINVAL ;
xen/arch/x86/srat.c static struct node node_memblk_range[NR_NODE_MEMBLKS]; · line 82
Quoted 10 lines
xen/arch/x86/srat.c +10
-0+ + node_memblk_range[num_node_memblks].start = start; + node_memblk_range[num_node_memblks].end = start + size; + memblk_nodeid[num_node_memblks] = nodeid; + num_node_memblks++; + +return 0 ; +} + +static inline bool node_found (unsigned int idx,unsigned int pxm)
Please don't make unrelated change in the same patch. In this case I don't see why you switch from "unsigned" to "unsigned int".
Quoted 5 lines
xen/arch/x86/srat.c +0
-0{return ((pxm2node[idx].pxm == pxm) && (pxm2node[idx].node !=NUMA_NO_NODE ));@@ -107,11 +145,11 @@ int valid_numa_range(paddr_t start, paddr_t end, nodeid_t node) {
xen/arch/x86/srat.c int valid_numa_range(paddr_t start, paddr_t end, nodeid_t node) · line 152
Quoted 10 lines
xen/arch/x86/srat.c +3
-3int i; -for (i =0 ; i < num_node_memblks; i++) { -struct node *nd = &node_memblk_range[i]; +for (i =0 ; i <get_num_node_memblks (); i++) { +struct node *nd =get_node_memblk_range (i);if (nd->start <= start && nd->end > end && - memblk_nodeid[i] == node ) +get_memblk_nodeid (i) == node)
Why the indentation changed here?
Quoted 155 lines
xen/arch/x86/srat.c +38
-21return 1 ; }@@ -122,8 +160,8 @@ static int __init conflicting_memblks(paddr_t start, paddr_t end) {int i; -for (i =0 ; i < num_node_memblks; i++) { -struct node *nd = &node_memblk_range[i]; +for (i =0 ; i <get_num_node_memblks (); i++) { +struct node *nd =get_node_memblk_range (i);if (nd->start == nd->end)continue ;if (nd->end > start && nd->start < end)@@ -136,7 +174,8 @@ static int __init conflicting_memblks(paddr_t start, paddr_t end)static void __init cutoff_node (int i,paddr_t start,paddr_t end) { -struct node *nd = &nodes[i]; +struct node *nd =get_numa_node (i); +if (nd->start < start) { nd->start = start;if (nd->end < nd->start)@@ -278,6 +317,7 @@ acpi_numa_memory_affinity_init(const struct acpi_srat_mem_affinity *ma)unsigned pxm;nodeid_t node;int i; +struct node *memblk;if (srat_disabled ())return ;@@ -288,7 +328,7 @@ acpi_numa_memory_affinity_init(const struct acpi_srat_mem_affinity *ma)if (!(ma->flags &ACPI_SRAT_MEM_ENABLED ))return ; -if (num_node_memblks >=NR_NODE_MEMBLKS ) +if (get_num_node_memblks () >=NR_NODE_MEMBLKS ) {dprintk (XENLOG_WARNING ,"Too many numa entry, try bigger NR_NODE_MEMBLKS \n" );@@ -310,27 +350,31 @@ acpi_numa_memory_affinity_init(const struct acpi_srat_mem_affinity *ma) i =conflicting_memblks (start, end);if (i <0 )/* everything fine */ ; -else if (memblk_nodeid[i] == node) { +else if (get_memblk_nodeid (i) == node) {bool mismatch = !(ma->flags &ACPI_SRAT_MEM_HOT_PLUGGABLE ) != !test_bit (i, memblk_hotplug); + memblk =get_node_memblk_range (i); +printk ("%sSRAT: PXM %u (%" PRIx64"-%" PRIx64") overlaps with itself (%" PRIx64"-%" PRIx64")\n" , mismatch ?KERN_ERR :KERN_WARNING , pxm, start, end, - node_memblk_range[i].start, node_memblk_range[i].end); + memblk->start, memblk->end);if (mismatch) {bad_srat ();return ; } }else { + memblk =get_node_memblk_range (i); +printk (KERN_ERR "SRAT: PXM %u (%" PRIx64"-%" PRIx64") overlaps with PXM %u (%" PRIx64"-%" PRIx64")\n" , - pxm, start, end,node_to_pxm (memblk_nodeid[i]), - node_memblk_range[i].start, node_memblk_range[i].end); + pxm, start, end,node_to_pxm (get_memblk_nodeid (i)), + memblk->start, memblk->end);bad_srat ();return ; }if (!(ma->flags &ACPI_SRAT_MEM_HOT_PLUGGABLE )) { -struct node *nd = &nodes[node]; +struct node *nd =get_numa_node (node);if (!node_test_and_set (node, memory_nodes_parsed)) { nd->start = start;@@ -346,15 +390,17 @@ acpi_numa_memory_affinity_init(const struct acpi_srat_mem_affinity *ma) node, pxm, start, end, 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; +if (numa_add_memblk (node, start, ma->length)) { +printk (KERN_ERR "SRAT: node-id %u out of range\n" , node); +bad_srat (); +return ; + } +if (ma->flags &ACPI_SRAT_MEM_HOT_PLUGGABLE ) { -__set_bit (num_node_memblks, memblk_hotplug); +__set_bit (get_num_node_memblks (), memblk_hotplug);if (end > mem_hotplug) mem_hotplug = end; } - num_node_memblks++; }/* Sanity check to catch more bad SRATs (they are amazingly common). @@ -377,17 +423,21 @@ static int __init nodes_cover_memory(void)do { found =0 ;for_each_node_mask (j, memory_nodes_parsed) -if (start < nodes[j].end - && end > nodes[j].start) { -if (start >= nodes[j].start) { - start = nodes[j].end; + { +struct node *nd =get_numa_node (j); + +if (start < nd->end + && end > nd->start) { +if (start >= nd->start) { + start = nd->end; found =1 ; } -if (end <= nodes[j].end) { - end = nodes[j].start; +if (end <= nd->end) { + end = nd->start; found =1 ; } } + } }while (found && start < end);if (start < end) {@@ -457,6 +507,8 @@ int __init acpi_scan_nodes(uint64_t start, uint64_t end) {int i;nodemask_t all_nodes_parsed; +struct node *memblks; +nodeid_t *nodeids;/* First clean up the node list */ for (i =0 ; i <MAX_NUMNODES ; i++)@@ -470,6 +522,8 @@ int __init acpi_scan_nodes(uint64_t start, uint64_t end)return -1 ; } + memblks =get_node_memblk_range (0 ); + nodeids =get_memblk_nodeid_map ();if (compute_memnode_shift (node_memblk_range, num_node_memblks, memblk_nodeid, &memnode_shift)) { memnode_shift =0 ;@@ -484,12 +538,14 @@ int __init acpi_scan_nodes(uint64_t start, uint64_t end)/* Finally register nodes */ for_each_node_mask (i, all_nodes_parsed) { -uint64_t size = nodes[i].end - nodes[i].start; +struct node *nd =get_numa_node (i); +uint64_t size = nd->end - nd->start;
xen/arch/x86/srat.c int __init acpi_scan_nodes(uint64_t start, uint64_t end) · line 551
Quoted 10 lines
xen/arch/x86/srat.c +2
-1+if ( size ==0 )printk (KERN_WARNING "SRAT: Node %u has no memory. " "BIOS Bug or mis-configured hardware?\n" , i); -setup_node_bootmem (i, nodes[i].start, nodes[i].end); +setup_node_bootmem (i, nd->start, nd->end); }for (i =0 ; i < nr_cpu_ids; i++) {if (cpu_to_node[i] ==NUMA_NO_NODE )
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 06/25] x86: NUMA: Add accessors for nodes[] and node_memblk_range[] structs
Quoted 9 lines · Julien Grall
Hi Vijay,
Quoted 4 lines · On 28/03/17 16:53, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
Add accessor for nodes[] and other static variables and
Quoted 7 lines
s/accessor/accessors/
Quoted 1 line
used those accessors.
Also, I am not sure to understand the usefulness of those accessors over a global variable.
These are static variables which needs to accessed from other files and later moved to generic file.
Quoted 15 lines
Quoted 15 lines
Signed-off-by Vijaya Kumar K <[email protected]>--- xen/arch/x86/srat.c | 108 +++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 82 insertions(+), 26 deletions(-)xen/arch/x86/srat.c +0
-0@@ -41,7 +41,45 @@ 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);
Quoted 5 lines
xen/arch/x86/srat.c static struct node node_memblk_range[NR_NODE_MEMBLKS]; · line 44
Quoted 2 lines
xen/arch/x86/srat.c +1
-1-static inline bool node_found (unsigned idx,unsigned pxm) +static struct node *get_numa_node (int id)unsigned int.
OK
Quoted 66 lines
xen/arch/x86/srat.c static struct node node_memblk_range[NR_NODE_MEMBLKS]; · line 49
Quoted 6 lines
xen/arch/x86/srat.c +5
-0+{ +return &nodes[id]; +} + +static nodeid_t get_memblk_nodeid (int id)unsigned int.
xen/arch/x86/srat.c static struct node node_memblk_range[NR_NODE_MEMBLKS]; · line 59
Quoted 10 lines
xen/arch/x86/srat.c +10
-0+{ +return memblk_nodeid[id]; +} + +static nodeid_t *get_memblk_nodeid_map (void ) +{ +return &memblk_nodeid[0 ]; +} + +static struct node *get_node_memblk_range (int memblk)unsigned int.
Quoted 14 lines
xen/arch/x86/srat.c +13
-0+{ +return &node_memblk_range[memblk]; +} + +static int get_num_node_memblks (void ) +{ +return num_node_memblks; +} + +static int __init numa_add_memblk (nodeid_t nodeid,paddr_t start,uint64_t size) +{ +if (nodeid >=NR_NODE_MEMBLKS ) +return -EINVAL ;xen/arch/x86/srat.c static struct node node_memblk_range[NR_NODE_MEMBLKS]; · line 82
Quoted 10 lines
xen/arch/x86/srat.c +10
-0+ + node_memblk_range[num_node_memblks].start = start; + node_memblk_range[num_node_memblks].end = start + size; + memblk_nodeid[num_node_memblks] = nodeid; + num_node_memblks++; + +return 0 ; +} + +static inline bool node_found (unsigned int idx,unsigned int pxm)Please don't make unrelated change in the same patch. In this case I don't see why you switch from "unsigned" to "unsigned int".
Quoted 13 lines
xen/arch/x86/srat.c +0
-0{ return ((pxm2node[idx].pxm == pxm) &&(pxm2node[idx].node != NUMA_NO_NODE));xen/arch/x86/srat.c +2
-2@@ -107,11 +145,11 @@ int valid_numa_range(paddr_t start, paddr_t end, nodeid_t node) {int i; -for (i =0 ; i < num_node_memblks; i++) { -struct node *nd = &node_memblk_range[i]; +for (i =0 ; i <get_num_node_memblks (); i++) { +struct node *nd =get_node_memblk_range (i);
Quoted 6 lines
xen/arch/x86/srat.c int valid_numa_range(paddr_t start, paddr_t end, nodeid_t node) · line 152
Quoted 3 lines
xen/arch/x86/srat.c +1
-1if (nd->start <= start && nd->end > end && - memblk_nodeid[i] == node ) +get_memblk_nodeid (i) == node)Why the indentation changed here?
OK. will wrap these changes in other patches.
Quoted 188 lines
Quoted 180 lines
xen/arch/x86/srat.c +2
-2return 1 ; }@@ -122,8 +160,8 @@ static int __init conflicting_memblks(paddr_t start, paddr_t end) {int i; -for (i =0 ; i < num_node_memblks; i++) { -struct node *nd = &node_memblk_range[i]; +for (i =0 ; i <get_num_node_memblks (); i++) { +struct node *nd =get_node_memblk_range (i);if (nd->start == nd->end)continue ;if (nd->end > start && nd->start < end)xen/arch/x86/srat.c +2
-1@@ -136,7 +174,8 @@ static int __init conflicting_memblks(paddr_t start, paddr_t end)static void __init cutoff_node (int i,paddr_t start,paddr_t end) { -struct node *nd = &nodes[i]; +struct node *nd =get_numa_node (i); +if (nd->start < start) { nd->start = start;if (nd->end < nd->start)xen/arch/x86/srat.c +1
-0@@ -278,6 +317,7 @@ acpi_numa_memory_affinity_init(const struct acpi_srat_mem_affinity *ma)unsigned pxm;nodeid_t node;int i; +struct node *memblk;if (srat_disabled ())return;xen/arch/x86/srat.c +1
-1@@ -288,7 +328,7 @@ acpi_numa_memory_affinity_init(const struct acpi_srat_mem_affinity *ma)if (!(ma->flags &ACPI_SRAT_MEM_ENABLED ))return ; -if (num_node_memblks >=NR_NODE_MEMBLKS ) +if (get_num_node_memblks () >=NR_NODE_MEMBLKS ) { dprintk(XENLOG_WARNING,"Too many numa entry, try bigger NR_NODE_MEMBLKS \n");xen/arch/x86/srat.c +1
-1@@ -310,27 +350,31 @@ acpi_numa_memory_affinity_init(const struct acpi_srat_mem_affinity *ma) i =conflicting_memblks (start, end);if (i <0 )/* everything fine */ ; -else if (memblk_nodeid[i] == node) { +else if (get_memblk_nodeid (i) == node) {bool mismatch = !(ma->flags &ACPI_SRAT_MEM_HOT_PLUGGABLE )!=
!test_bit(i, memblk_hotplug);xen/arch/x86/srat.c +2
-0+ memblk =get_node_memblk_range (i); + printk("%sSRAT: PXM %u (%"PRIx64"-%"PRIx64") overlaps withitself (%"PRIx64"-%"PRIx64")\n",
mismatch ?KERN_ERR:KERN_WARNING, pxm, start,
end,
- node_memblk_range[i].start,
node_memblk_range[i].end);xen/arch/x86/srat.c +3
-0+ memblk->start, memblk->end);if (mismatch) {bad_srat ();return ; } } else { + memblk =get_node_memblk_range (i); + printk(KERN_ERR "SRAT: PXM %u (%"PRIx64"-%"PRIx64") overlaps withPXM %u (%"PRIx64"-%"PRIx64")\n",
xen/arch/x86/srat.c +0
-2- pxm, start, end,node_to_pxm (memblk_nodeid[i]), - node_memblk_range[i].start,node_memblk_range[i].end);
xen/arch/x86/srat.c +10
-6+ pxm, start, end,node_to_pxm (get_memblk_nodeid (i)), + memblk->start, memblk->end);bad_srat ();return ; }if (!(ma->flags &ACPI_SRAT_MEM_HOT_PLUGGABLE )) { -struct node *nd = &nodes[node]; +struct node *nd =get_numa_node (node);if (!node_test_and_set (node, memory_nodes_parsed)) { nd->start = start;@@ -346,15 +390,17 @@ acpi_numa_memory_affinity_init(const struct acpi_srat_mem_affinity *ma) node, pxm, start, end, 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; + if (numa_add_memblk(node, start, ma->length)) { +printk (KERN_ERR "SRAT: node-id %u out of range\n" , node); +bad_srat (); +return ; + } +if (ma->flags &ACPI_SRAT_MEM_HOT_PLUGGABLE ) { -__set_bit (num_node_memblks, memblk_hotplug); +__set_bit (get_num_node_memblks (), memblk_hotplug);if (end > mem_hotplug) mem_hotplug = end; } - num_node_memblks++; }/* Sanity check to catch more bad SRATs (they are amazingly common).
xen/arch/x86/srat.c +12
-6@@ -377,17 +423,21 @@ static int __init nodes_cover_memory(void)do { found =0 ;for_each_node_mask (j, memory_nodes_parsed) -if (start < nodes[j].end - && end > nodes[j].start) { -if (start >= nodes[j].start) { - start = nodes[j].end; + { +struct node *nd =get_numa_node (j); + +if (start < nd->end + && end > nd->start) { +if (start >= nd->start) { + start = nd->end; found =1 ; } -if (end <= nodes[j].end) { - end = nodes[j].start; +if (end <= nd->end) { + end = nd->start; found =1 ; } } + } }while (found && start < end);if (start < end) {@@ -457,6 +507,8 @@ int __init acpi_scan_nodes(uint64_t start, uint64_t end) {int i;nodemask_t all_nodes_parsed; +struct node *memblks; +nodeid_t *nodeids;/* First clean up the node list */ for (i = 0; i < MAX_NUMNODES; i++)xen/arch/x86/srat.c +2
-0@@ -470,6 +522,8 @@ int __init acpi_scan_nodes(uint64_t start, uint64_t end)return -1 ; } + memblks =get_node_memblk_range (0 ); + nodeids =get_memblk_nodeid_map ();if (compute_memnode_shift (node_memblk_range, num_node_memblks, memblk_nodeid, &memnode_shift)) {memnode_shift = 0;xen/arch/x86/srat.c +3
-1@@ -484,12 +538,14 @@ int __init acpi_scan_nodes(uint64_t start, uint64_t end)/* Finally register nodes */ for_each_node_mask(i, all_nodes_parsed) { - uint64_t size = nodes[i].end - nodes[i].start; + struct node *nd = get_numa_node(i); + uint64_t size = nd->end - nd->start; + if ( size == 0 ) printk(KERN_WARNING "SRAT: Node %u has no memory."
"BIOS Bug or mis-configured hardware?\n",
i);xen/arch/x86/srat.c int __init acpi_scan_nodes(uint64_t start, uint64_t end) · line 551
Quoted 5 lines
xen/arch/x86/srat.c +1
-1-setup_node_bootmem (i, nodes[i].start, nodes[i].end); +setup_node_bootmem (i, nd->start, nd->end); }for (i =0 ; i < nr_cpu_ids; i++) {if (cpu_to_node[i] ==NUMA_NO_NODE )Cheers,
Quoted 2 lines
--
Julien Grall
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 06/25] x86: NUMA: Add accessors for nodes[] and node_memblk_range[] structs
Quoted 12 lines · Vijay Kilari
Quoted 11 lines · Julien Grall
Hi Vijay,
Quoted 4 lines · On 28/03/17 16:53, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
Add accessor for nodes[] and other static variables and
s/accessor/accessors/
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
used those accessors.
Also, I am not sure to understand the usefulness of those accessors over a global variable.
These are static variables which needs to accessed from other files and later moved to generic file.
101 of a contributor, always explaining in the commit message why you do something. Also, I am quite confused why sometimes you decide to use static and helper, other time you will use global variables.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
RFC PATCH v2 7/25 x86: NUMA: Rename some generic functions
In reply to [email protected]From: Vijaya Kumar K <[email protected]>
Rename some function in ACPI code as follow
- Rename setup_node to acpi_setup_node
- Rename bad_srat to numa_failed
- Rename nodes_cover_memory to arch_sanitize_nodes_memory
- Rename acpi_scan_nodes to numa_scan_nodes
Also introduce reset_pxm2node() to reset pxm2node variable. This avoids exporting pxm2node.
--- xen/arch/x86/numa.c | 2 +- xen/arch/x86/smpboot.c | 2 +- xen/arch/x86/srat.c | 51 ++++++++++++++++++++++++++-------------------- xen/arch/x86/x86_64/mm.c | 2 +- xen/include/asm-x86/acpi.h | 2 +- xen/include/asm-x86/numa.h | 2 +- 6 files changed, 34 insertions(+), 27 deletions(-)
xen/arch/x86/numa.c +1 -1
@@ -298,7 +298,7 @@ void __init numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn)#endif #ifdef CONFIG_ACPI_NUMA -if ( !is_numa_off () && !acpi_scan_nodes ((uint64_t )start_pfn <<PAGE_SHIFT , +if ( !is_numa_off () && !numa_scan_nodes ((uint64_t )start_pfn <<PAGE_SHIFT , (uint64_t )end_pfn <<PAGE_SHIFT ) )return ;#endif
xen/arch/x86/smpboot.c +1 -1
@@ -959,7 +959,7 @@ int cpu_add(uint32_t apic_id, uint32_t acpi_id, uint32_t pxm)if ( !srat_disabled () ) { -nodeid_t node =setup_node (pxm); +nodeid_t node =acpi_setup_node (pxm);if ( node ==NUMA_NO_NODE ) {
xen/arch/x86/srat.c +29 -22
162 lines not on this page · raw message
xen/arch/x86/x86_64/mm.c +1 -1
@@ -1369,7 +1369,7 @@ int memory_add(unsigned long spfn, unsigned long epfn, unsigned int pxm)if ( !mem_hotadd_check (spfn, epfn) )return -EINVAL ; -if ( (node =setup_node (pxm)) ==NUMA_NO_NODE ) +if ( (node =acpi_setup_node (pxm)) ==NUMA_NO_NODE )return -EINVAL ;if ( !valid_numa_range (spfn <<PAGE_SHIFT , epfn <<PAGE_SHIFT , node) )
xen/include/asm-x86/acpi.h +1 -1
@@ -103,7 +103,7 @@ extern void acpi_reserve_bootmem(void);#define ARCH_HAS_POWER_INIT 1 -extern int acpi_scan_nodes (u64 start,u64 end); +extern int numa_scan_nodes (u64 start,u64 end);#define NR_NODE_MEMBLKS (MAX_NUMNODES*2)#ifdef CONFIG_ACPI_SLEEP
xen/include/asm-x86/numa.h +1 -1
@@ -32,7 +32,7 @@ extern void numa_add_cpu(int cpu);extern void numa_init_array (void );extern bool srat_disabled (void );extern void numa_set_node (int cpu,nodeid_t node); -extern nodeid_t setup_node (unsigned int pxm); +extern nodeid_t acpi_setup_node (unsigned int pxm);extern void srat_detect_node (int cpu);extern void setup_node_bootmem (nodeid_t nodeid,paddr_t start,paddr_t end);
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
RFC PATCH v2 8/25 x86: NUMA: Sanitize node distance
In reply to [email protected]From: Vijaya Kumar K <[email protected]>
Introduce acpi_node_distance() and call from __node_distance(). This helps to implement arch specific __node_distance(). Also introduce LOCAL_DISTANCE & REMOTE DISTANCE macros.
--- xen/arch/x86/srat.c | 13 +++++++++---- xen/include/xen/numa.h | 2 ++ 2 files changed, 11 insertions(+), 4 deletions(-)
xen/arch/x86/srat.c +9 -4
@@ -221,9 +221,9 @@ static int __init slit_valid(struct acpi_table_slit *slit)for (j =0 ; j < d; j++) {uint8_t val = slit->entry[d*i + j];if (i == j) { -if (val !=10 ) +if (val !=LOCAL_DISTANCE )return 0 ; - }else if (val <=10 ) + }else if (val <=LOCAL_DISTANCE )return 0 ; } }
@@ -576,13 +576,13 @@ static unsigned node_to_pxm(nodeid_t n)return 0 ; } -uint8_t __node_distance (nodeid_t a,nodeid_t b) +static uint8_t acpi_node_distance (nodeid_t a,nodeid_t b) {unsigned index;uint8_t slit_val;if (!acpi_slit) -return a == b ?10 :20 ; +return a == b ?LOCAL_DISTANCE :REMOTE_DISTANCE ; index = acpi_slit->locality_count *node_to_pxm (a); slit_val = acpi_slit->entry[index +node_to_pxm (b)];
@@ -593,4 +593,9 @@ uint8_t __node_distance(nodeid_t a, nodeid_t b)return slit_val; } +uint8_t __node_distance (nodeid_t a,nodeid_t b) +{ +return acpi_node_distance (a, b); +} +EXPORT_SYMBOL (__node_distance);
xen/include/xen/numa.h +2 -0
@@ -8,6 +8,8 @@#endif #define NUMA_NO_NODE 0xFF +#define LOCAL_DISTANCE 10 +#define REMOTE_DISTANCE 20#define NUMA_NO_DISTANCE 0xFF#define MAX_NUMNODES (1 << NODES_SHIFT)
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
RFC PATCH v2 9/25 ARM: NUMA: Add existing ARM numa code under CONFIG_NUMA
In reply to [email protected]From: Vijaya Kumar K <[email protected]>
Right now CONFIG_NUMA is not enabled for ARM and existing code in asm-arm/numa.h is for !CONFIG_NUMA. Hence put this code under #ifndef CONFIG_NUMA.
This help to make this changes work when CONFIG_NUMA is not enabled.
Also define NODES_SHIFT macro for ARM to value 2. This limits number of NUMA nodes supported to 4. There is not hard restrictions on this value set to 2.
--- xen/include/asm-arm/numa.h | 5 +++++ 1 file changed, 5 insertions(+)
xen/include/asm-arm/numa.h +5 -0
@@ -3,6 +3,10 @@typedef uint8_t nodeid_t ; +/* Limit number of NUMA nodes supported to 4 */ +#define NODES_SHIFT 2 + +#ifndef CONFIG_NUMA /* Fake one node for now. See also node_online_map. */ #define cpu_to_node (cpu) 0#define node_to_cpumask (node) (cpu_online_map)
@@ -16,6 +20,7 @@ static inline __attribute__((pure)) nodeid_t phys_to_nid(paddr_t addr)#define node_spanned_pages (nid) (total_pages)#define node_start_pfn (nid) (pdx_to_pfn(frametable_base_pdx))#define __node_distance (a, b) (20) +#endif /* CONFIG_NUMA */ static inline unsigned int arch_get_dma_bitsize (void ) {
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 09/25] ARM: NUMA: Add existing ARM numa code under CONFIG_NUMA
Hi Vijay,
Quoted 8 lines · On 28/03/17 16:53, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
Right now
CONFIG_NUMAis not enabled for ARM and existing code inasm-arm/numa.his for !CONFIG_NUMA. Hence put this code under #ifndefCONFIG_NUMA.This help to make this changes work when
CONFIG_NUMAis not enabled.
But you always turn NUMA on by default (see patch #24) and there is no possibility to turn off NUMA.
Quoted 4 lines
Also define
NODES_SHIFTmacro for ARM to value 2. This limits number of NUMA nodes supported to 4. There is not hard restrictions on this value set to 2.
Again, why only 2 when x86 is supporting 6?
Furthermore, this is not related to this patch itself and should be part of separate patch.
Lastly, why don't you move that to a Kconfig allowing the user to configure the number of Nodes?
Quoted 11 lines
Signed-off-by Vijaya Kumar K <[email protected]>--- xen/include/asm-arm/numa.h | 5 +++++ 1 file changed, 5 insertions(+)xen/include/asm-arm/numa.h +0
-0
xen/include/asm-arm/numa.h line 7
Quoted 5 lines
xen/include/asm-arm/numa.h +2
-0@@ -3,6 +3,10 @@typedef uint8_t nodeid_t ; +/* Limit number of NUMA nodes supported to 4 */ +#define NODES_SHIFT 2
Why this is not covered by CONFIG_NUMA?
Quoted 7 lines
xen/include/asm-arm/numa.h +2
-0+ +#ifndef CONFIG_NUMA /* Fake one node for now. See also node_online_map. */ #define cpu_to_node (cpu) 0#define node_to_cpumask (node) (cpu_online_map)
xen/include/asm-arm/numa.h static inline __attribute__((pure)) nodeid_t phys_to_nid(paddr_t addr) · line 26
Quoted 7 lines
xen/include/asm-arm/numa.h +1
-0@@ -16,6 +20,7 @@ static inline __attribute__((pure)) nodeid_t phys_to_nid(paddr_t addr)#define node_spanned_pages (nid) (total_pages)#define node_start_pfn (nid) (pdx_to_pfn(frametable_base_pdx))#define __node_distance (a, b) (20) +#endif /* CONFIG_NUMA */ static inline unsigned int arch_get_dma_bitsize (void ) {
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 09/25] ARM: NUMA: Add existing ARM numa code under CONFIG_NUMA
Quoted 10 lines · Julien Grall
Hi Vijay,
Quoted 7 lines · On 28/03/17 16:53, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
Right now
CONFIG_NUMAis not enabled for ARM and existing code inasm-arm/numa.his for !CONFIG_NUMA. Hence put this code under #ifndefCONFIG_NUMA.
Quoted 6 lines
Quoted 2 lines
This help to make this changes work when
CONFIG_NUMAis not enabled.But you always turn NUMA on by default (see patch #24) and there is no possibility to turn off NUMA.
Yes at the end of the series we enable NUMA by default.
But the the intermittent patches of this patch series fails to compile.
Quoted 7 lines
Quoted 5 lines
Also define
NODES_SHIFTmacro for ARM to value 2. This limits number of NUMA nodes supported to 4. There is not hard restrictions on this value set to 2.
Quoted 7 lines
Again, why only 2 when x86 is supporting 6?
Furthermore, this is not related to this patch itself and should be part of separate patch.
Lastly, why don't you move that to a
Kconfigallowing the user to configure the number of Nodes?
ok
Quoted 13 lines
Quoted 13 lines
Signed-off-by Vijaya Kumar K <[email protected]>--- xen/include/asm-arm/numa.h | 5 +++++ 1 file changed, 5 insertions(+)xen/include/asm-arm/numa.h +0
-0@@ -3,6 +3,10 @@
Quoted 7 lines
xen/include/asm-arm/numa.h line 7
Quoted 4 lines
xen/include/asm-arm/numa.h +2
-0typedef uint8_t nodeid_t ; +/* Limit number of NUMA nodes supported to 4 */ +#define NODES_SHIFT 2Why this is not covered by
CONFIG_NUMA?
The below define is used in generic code irrespective of CONFIG_NUMA
#define MAX_NUMNODES (1 << NODES_SHIFT)
Quoted 13 lines
Quoted 13 lines
xen/include/asm-arm/numa.h +3
-0+ +#ifndef CONFIG_NUMA /* Fake one node for now. See also node_online_map. */ #define cpu_to_node (cpu) 0#define node_to_cpumask (node) (cpu_online_map)@@ -16,6 +20,7 @@ static inline __attribute__((pure)) nodeid_t phys_to_nid(paddr_t addr)#define node_spanned_pages (nid) (total_pages)#define node_start_pfn (nid) (pdx_to_pfn(frametable_base_pdx))#define __node_distance (a, b) (20) +#endif /* CONFIG_NUMA */
Quoted 8 lines
Quoted 3 lines
xen/include/asm-arm/numa.h +0
-0static inline unsigned int arch_get_dma_bitsize (void ){
Cheers,
--
Julien Grall
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 09/25] ARM: NUMA: Add existing ARM numa code under CONFIG_NUMA
Quoted 15 lines · Vijay Kilari
Quoted 14 lines · Julien Grall
Hi Vijay,
Quoted 9 lines · On 28/03/17 16:53, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
Right now
CONFIG_NUMAis not enabled for ARM and existing code inasm-arm/numa.his for !CONFIG_NUMA. Hence put this code under #ifndefCONFIG_NUMA.This help to make this changes work when
CONFIG_NUMAis not enabled.
Quoted 5 lines
Quoted 2 lines
But you always turn NUMA on by default (see patch #24) and there is no possibility to turn off NUMA.
Yes at the end of the series we enable NUMA by default.
But the the intermittent patches of this patch series fails to compile.
So for helping this series, you add code that will get rotten???
I don't like this idea at all, we should avoid to add code in Xen that will not be used.
Quoted 38 lines
Quoted 7 lines
Quoted 5 lines
Also define
NODES_SHIFTmacro for ARM to value 2. This limits number of NUMA nodes supported to 4. There is not hard restrictions on this value set to 2.Quoted 7 lines
Again, why only 2 when x86 is supporting 6?
Furthermore, this is not related to this patch itself and should be part of separate patch.
Lastly, why don't you move that to a
Kconfigallowing the user to configure the number of Nodes?ok
Quoted 13 lines
Quoted 13 lines
Signed-off-by Vijaya Kumar K <[email protected]>--- xen/include/asm-arm/numa.h | 5 +++++ 1 file changed, 5 insertions(+)xen/include/asm-arm/numa.h +0
-0@@ -3,6 +3,10 @@Quoted 7 lines
xen/include/asm-arm/numa.h line 7
Quoted 4 lines
xen/include/asm-arm/numa.h +2
-0typedef uint8_t nodeid_t ; +/* Limit number of NUMA nodes supported to 4 */ +#define NODES_SHIFT 2Why this is not covered by
CONFIG_NUMA?
Quoted 3 lines
The below define is used in generic code irrespective of
CONFIG_NUMA#define
MAX_NUMNODES(1 <<NODES_SHIFT)
As you may have noticed NODES_SHIFT currently does not exist on ARM and we are still able to compile the generic code. So why do you need to do it unconditionally?
If you look at the code, xen/numa.h will define NODES_SHIFT to 0 if it has not previously defined. So I still don't see any reason on what you are doing.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
RFC PATCH v2 10/25 x86: NUMA: Move numa code and make it generic
In reply to [email protected]From: Vijaya Kumar K <[email protected]>
Move code from xen/arch/x86/numa.c to xen/common/numa.c so that it can be used by other archs.
Few generic static functions in x86/numa.c is made non-static common/numa.c
The generic contents of header file asm-x86/numa.h are moved to xen/numa.h.
--- xen/arch/x86/numa.c | 456 ------------------------------------------ xen/arch/x86/srat.c | 7 + xen/common/Makefile | 1 + xen/common/numa.c | 488 +++++++++++++++++++++++++++++++++++++++++++++ xen/include/asm-x86/numa.h | 15 -- xen/include/xen/numa.h | 18 ++ 6 files changed, 514 insertions(+), 471 deletions(-)
xen/arch/x86/numa.c +0 -456
@@ -10,286 +10,13 @@#include <xen/ctype.h> #include <xen/nodemask.h> #include <xen/numa.h> -#include <xen/keyhandler.h> #include <xen/time.h> #include <xen/smp.h> #include <xen/pfn.h> #include <asm/acpi.h> -#include <xen/sched.h> -#include <xen/softirq.h> - -static int numa_setup (char *s); -custom_param ("numa" , numa_setup); - -struct node_data node_data[MAX_NUMNODES ]; - -/* Mapping from pdx to node id */ -unsigned int memnode_shift; -static typeof(*memnodemap) _memnodemap[64]; -unsigned long memnodemapsize; -uint8_t *memnodemap; - -nodeid_t __read_mostly cpu_to_node[NR_CPUS ] = { - [0 ...NR_CPUS -1 ] =NUMA_NO_NODE -}; -/* -* Keep BIOS's CPU2node information, should not be used for memory allocaion -*/ -nodeid_t apicid_to_node[MAX_LOCAL_APIC ] = { - [0 ...MAX_LOCAL_APIC -1 ] =NUMA_NO_NODE -}; -cpumask_t __read_mostly node_to_cpumask[MAX_NUMNODES ];nodemask_t __read_mostly node_online_map = { { [0 ] =1UL } }; -static bool numa_off =0 ; -static bool acpi_numa =1 ; - -bool is_numa_off (void ) -{ -return numa_off; -} - -bool get_acpi_numa (void ) -{ -return acpi_numa; -} - -void set_acpi_numa (bool_t val) -{ - acpi_numa = val; -} - -bool srat_disabled (void ) -{ -return numa_off || acpi_numa ==0 ; -} - -/* -* Given a shift value, try to populate memnodemap[] -* Returns : -* 0 if OK -* -EINVAL if memnodmap[] too small (of shift too small) -* OR if node overlap or lost ram (shift too big) -*/ -static int __init populate_memnodemap (const struct node *nodes,int numnodes, -unsigned int shift,nodeid_t *nodeids) -{ -unsigned long spdx, epdx; -int i, res = -EINVAL ; - -memset (memnodemap,NUMA_NO_NODE , memnodemapsize *sizeof (*memnodemap)); -for ( i =0 ; i < numnodes; i++ ) - { - spdx =paddr_to_pdx (nodes[i].start); - epdx =paddr_to_pdx (nodes[i].end -1 ) +1 ; -if ( spdx >= epdx ) -continue ; -if ( (epdx >> shift) >= memnodemapsize ) -return 0 ; -do { -if ( memnodemap[spdx >> shift] !=NUMA_NO_NODE ) -return -EINVAL ; - -if ( !nodeids ) - memnodemap[spdx >> shift] = i; -else - memnodemap[spdx >> shift] = nodeids[i]; - - spdx += (1UL << shift); - }while ( spdx < epdx ); - res =0 ; - } - -return res; -} - -static int __init allocate_cachealigned_memnodemap (void ) -{ -unsigned long size =PFN_UP (memnodemapsize *sizeof (*memnodemap)); -unsigned long mfn =alloc_boot_pages (size,1 ); - -if ( !mfn ) - { -printk (KERN_ERR -"NUMA: Unable to allocate Memory to Node hash map\n" ); - memnodemapsize =0 ; -return -ENOMEM ; - } - - memnodemap =mfn_to_virt (mfn); - mfn <<=PAGE_SHIFT ; - size <<=PAGE_SHIFT ; -printk (KERN_DEBUG "NUMA: Allocated memnodemap from %lx - %lx\n" , - mfn, mfn + size); - memnodemapsize = size /sizeof (*memnodemap); - -return 0 ; -} - -/* -* The LSB of all start and end addresses in the node map is the value of the -* maximum possible shift. -*/ -static unsigned int __init extract_lsb_from_nodes (const struct node *nodes, -int numnodes) -{ -unsigned int i, nodes_used =0 ; -unsigned long spdx, epdx; -unsigned long bitfield =0 , memtop =0 ; - -for ( i =0 ; i < numnodes; i++ ) - { - spdx =paddr_to_pdx (nodes[i].start); - epdx =paddr_to_pdx (nodes[i].end -1 ) +1 ; -if ( spdx >= epdx ) -continue ; - bitfield |= spdx; - nodes_used++; -if ( epdx > memtop ) - memtop = epdx; - } -if ( nodes_used <=1 ) - i =BITS_PER_LONG -1 ; -else - i =find_first_bit (&bitfield,sizeof (unsigned long ) *8 ); - memnodemapsize = (memtop >> i) +1 ; - -return i; -} - -int __init compute_memnode_shift (struct node *nodes,int numnodes, -nodeid_t *nodeids,unsigned int *shift) -{ - *shift =extract_lsb_from_nodes (nodes, numnodes); - -if ( memnodemapsize <=ARRAY_SIZE (_memnodemap) ) - memnodemap = _memnodemap; -else if (allocate_cachealigned_memnodemap () ) -return -ENOMEM ; - -printk (KERN_DEBUG "NUMA: Using %u for the hash shift.\n" , *shift); - -if (populate_memnodemap (nodes, numnodes, *shift, nodeids) ) - { -printk (KERN_INFO "Your memory is not aligned you need to " -"rebuild your hypervisor with a bigger NODEMAPSIZE " -"shift=%u\n" , *shift); -return -EINVAL ; - } - -return 0 ; -} -/* initialize NODE_DATA given nodeid and start/end */ -void __init setup_node_bootmem (nodeid_t nodeid,paddr_t start,paddr_t end) -{ -unsigned long start_pfn, end_pfn; - - start_pfn = start >>PAGE_SHIFT ; - end_pfn = end >>PAGE_SHIFT ; - -NODE_DATA (nodeid)->node_start_pfn = start_pfn; -NODE_DATA (nodeid)->node_spanned_pages = end_pfn - start_pfn; - -node_set_online (nodeid); -} - -void __init numa_init_array (void ) -{ -int rr, i; - -/* There are unfortunately some poorly designed mainboards around -that only connect memory to a single CPU. This breaks the 1:1 cpu->node -mapping. To avoid this fill in the mapping for all possible -CPUs, as the number of CPUs is not known yet. -We round robin the existing nodes. */ - rr =first_node (node_online_map); -for ( i =0 ; i < nr_cpu_ids; i++ ) - { -if ( cpu_to_node[i] !=NUMA_NO_NODE ) -continue ; -numa_set_node (i, rr); - rr =next_node (rr, node_online_map); -if ( rr ==MAX_NUMNODES ) - rr =first_node (node_online_map); - } -} - -#ifdef CONFIG_NUMA_EMU -static int __initdata numa_fake =0 ; -static int get_numa_fake (void ) -{ -return numa_fake; -} - -/* Numa emulation */ -static int __init numa_emulation (uint64_t start_pfn,uint64_t end_pfn) -{ -int i; -struct node nodes[MAX_NUMNODES ]; -uint64_t sz = ((end_pfn - start_pfn) <<PAGE_SHIFT ) /get_numa_fake (); - -/* Kludge needed for the hash function */ -if (hweight64 (sz) >1 ) - { -uint64_t x =1 ; -while ( (x <<1 ) < sz ) - x <<=1 ; -if ( x < sz /2 ) -printk (KERN_ERR -"Numa emulation unbalanced. Complain to maintainer\n" ); - sz = x; - } - -memset (&nodes,0 ,sizeof (nodes)); -for ( i =0 ; i <get_numa_fake (); i++ ) - { - nodes[i].start = (start_pfn <<PAGE_SHIFT ) + i * sz; -if ( i ==get_numa_fake () -1 ) - sz = (end_pfn <<PAGE_SHIFT ) - nodes[i].start; - nodes[i].end = nodes[i].start + sz; -printk (KERN_INFO -"Faking node %d at %" PRIx64"-%" PRIx64" (%" PRIu64"MB)\n" , - i, nodes[i].start, nodes[i].end, - (nodes[i].end - nodes[i].start) >>20 ); -node_set_online (i); - } -if (compute_memnode_shift (nodes,get_numa_fake (),NULL , &memnode_shift) ) - { - memnode_shift =0 ; -printk (KERN_ERR "No NUMA hash function found. Emulation disabled.\n" ); -return -1 ; - } -for_each_online_node ( i ) - setup_node_bootmem(i, nodes[i].start, nodes[i].end); -numa_init_array (); - -return 0 ; -} -#endif - -static void __init numa_dummy_init (unsigned long start_pfn,unsigned long end_pfn) -{ -int i; - -printk (KERN_INFO "%s\n" , -is_numa_off () ?"NUMA turned off" :"No NUMA configuration found" ); - -printk (KERN_INFO "Faking a node at %016" PRIx64"-%016" PRIx64"\n" , - (uint64_t )start_pfn <<PAGE_SHIFT , - (uint64_t )end_pfn <<PAGE_SHIFT ); -/* setup dummy node covering all memory */ - memnode_shift =BITS_PER_LONG -1 ; - memnodemap = _memnodemap; -nodes_clear (node_online_map); -node_set_online (0 ); -for ( i =0 ; i < nr_cpu_ids; i++ ) -numa_set_node (i,0 ); -cpumask_copy (&node_to_cpumask[0 ],cpumask_of (0 )); -setup_node_bootmem (0 , (paddr_t )start_pfn <<PAGE_SHIFT , - (paddr_t )end_pfn <<PAGE_SHIFT ); -} -void __init numa_initmem_init (unsigned long start_pfn,unsigned long end_pfn) {#ifdef CONFIG_NUMA_EMU
@@ -306,43 +33,6 @@ void __init numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn)numa_dummy_init (start_pfn, end_pfn); } -void numa_add_cpu (int cpu) -{ -cpumask_set_cpu (cpu, &node_to_cpumask[cpu_to_node (cpu)]); -} - -void numa_set_node (int cpu,nodeid_t node) -{ - cpu_to_node[cpu] = node; -} - -/* [numa=off] */ -static int __init numa_setup (char *opt) -{ -if ( !strncmp (opt,"off" ,3 ) ) - numa_off =1 ; -if ( !strncmp (opt,"on" ,2 ) ) - numa_off =0 ; -#ifdef CONFIG_NUMA_EMU -if ( !strncmp (opt,"fake=" ,5 ) ) - { - numa_off =0 ; - numa_fake =simple_strtoul (opt+5 ,NULL ,0 ); -if ( numa_fake >=MAX_NUMNODES ) - numa_fake =MAX_NUMNODES ; - } -#endif -#ifdef CONFIG_ACPI_NUMA -if ( !strncmp (opt,"noacpi" ,6 ) ) - { - numa_off =0 ; - acpi_numa =0 ; - } -#endif - -return 1 ; -} -/* * Setup early cpu_to_node. *
@@ -391,149 +81,3 @@ unsigned int __init arch_get_dma_bitsize(void)flsl (node_start_pfn (node) +node_spanned_pages (node) /4 -1 ) + PAGE_SHIFT, 32); } - -static void dump_numa (unsigned char key) -{ -s_time_t now =NOW (); -unsigned int i, j, n; -int err; -struct domain *d; -struct page_info *page; -unsigned int page_num_node[MAX_NUMNODES ]; -const struct vnuma_info *vnuma; - -printk ("'%c' pressed -> dumping numa info (now-0x%X:%08X)\n" , key, - (uint32_t )(now >>32 ), (uint32_t )now); - -for_each_online_node ( i ) - { -paddr_t pa =pfn_to_paddr (node_start_pfn (i) +1 ); - -printk ("NODE%u start->%lu size->%lu free->%lu\n" , - i,node_start_pfn (i),node_spanned_pages (i), -avail_node_heap_pages (i)); -/* sanity check phys_to_nid() */ -if (phys_to_nid (pa) != i ) -printk ("phys_to_nid(%" PRIpaddr") -> %d should be %u\n" , - pa,phys_to_nid (pa), i); - } - - j =cpumask_first (&cpu_online_map); - n =0 ; -for_each_online_cpu ( i ) - { -if ( i != j + n || cpu_to_node[j] != cpu_to_node[i] ) - { -if ( n >1 ) -printk ("CPU%u...%u -> NODE%d\n" , j, j + n -1 , cpu_to_node[j]); -else -printk ("CPU%u -> NODE%d\n" , j, cpu_to_node[j]); - j = i; - n =1 ; - } -else - ++n; - } -if ( n >1 ) -printk ("CPU%u...%u -> NODE%d\n" , j, j + n -1 , cpu_to_node[j]); -else -printk ("CPU%u -> NODE%d\n" , j, cpu_to_node[j]); - -rcu_read_lock (&domlist_read_lock); - -printk ("Memory location of each domain:\n" ); -for_each_domain ( d ) - { -process_pending_softirqs (); - -printk ("Domain %u (total: %u):\n" , d->domain_id, d->tot_pages); - -for_each_online_node ( i ) - page_num_node[i] =0 ; - -spin_lock (&d->page_alloc_lock); -page_list_for_each (page, &d->page_list) - { - i =phys_to_nid ((paddr_t )page_to_mfn (page) <<PAGE_SHIFT ); - page_num_node[i]++; - } -spin_unlock (&d->page_alloc_lock); - - for_each_online_node ( i ) - printk(" Node %u: %u\n", i, page_num_node[i]); - -if ( !read_trylock (&d->vnuma_rwlock) ) -continue ; - -if ( !d->vnuma ) - { -read_unlock (&d->vnuma_rwlock); -continue ; - } - - vnuma = d->vnuma; -printk (" %u vnodes, %u vcpus, guest physical layout:\n" , - vnuma->nr_vnodes, d->max_vcpus); -for ( i =0 ; i < vnuma->nr_vnodes; i++ ) - { -unsigned int start_cpu = ~0U ; - - err =snprintf (keyhandler_scratch,12 ,"%3u" , - vnuma->vnode_to_pnode[i]); -if ( err <0 || vnuma->vnode_to_pnode[i] ==NUMA_NO_NODE ) -strlcpy (keyhandler_scratch,"???" ,sizeof (keyhandler_scratch)); - -printk (" %3u: pnode %s," , i, keyhandler_scratch); - -printk (" vcpus " ); - -for ( j =0 ; j < d->max_vcpus; j++ ) - { -if ( !(j &0x3f ) ) -process_pending_softirqs (); - -if ( vnuma->vcpu_to_vnode[j] == i ) - { -if ( start_cpu == ~0U ) - { -printk ("%d" , j); - start_cpu = j; - } - } -else if ( start_cpu != ~0U ) - { -if ( j -1 != start_cpu ) -printk ("-%d " , j -1 ); -else -printk (" " ); - start_cpu = ~0U ; - } - } - -if ( start_cpu != ~0U && start_cpu != j -1 ) -printk ("-%d" , j -1 ); - -printk ("\n" ); - -for ( j =0 ; j < vnuma->nr_vmemranges; j++ ) - { -if ( vnuma->vmemrange[j].nid == i ) -printk (" %016" PRIx64" - %016" PRIx64"\n" , - vnuma->vmemrange[j].start, - vnuma->vmemrange[j].end); - } - } - -read_unlock (&d->vnuma_rwlock); - } - -rcu_read_unlock (&domlist_read_lock); -} - -static int __init register_numa_trigger (void ) -{ -register_keyhandler ('u' , dump_numa,"dump NUMA info" ,1 ); -return 0 ; -} -__initcall (register_numa_trigger); -
xen/arch/x86/srat.c +7 -0
@@ -27,6 +27,13 @@ static nodemask_t __initdata memory_nodes_parsed;static nodemask_t __initdata processor_nodes_parsed;static struct node __initdata nodes[MAX_NUMNODES ]; +/* +* Keep BIOS's CPU2node information, should not be used for memory allocaion +*/ +nodeid_t apicid_to_node[MAX_LOCAL_APIC ] = { + [0 ...MAX_LOCAL_APIC -1 ] =NUMA_NO_NODE +}; +struct pxm2node {unsigned int pxm;nodeid_t node;
xen/common/Makefile +1 -0
@@ -63,6 +63,7 @@ obj-y += wait.o obj-bin-y += warning.init.o obj-$(CONFIG_XENOPROF) += xenoprof.o obj-y += xmalloc_tlsf.o +obj-$(CONFIG_NUMA) += numa.o obj-bin-$(CONFIG_X86) += $(foreach n,decompress bunzip2 unxz unlzma unlzo unlz4 earlycpio,$(n).init.o)
xen/common/numa.c new file +488 -0
488 lines not on this page · raw message
xen/include/asm-x86/numa.h +0 -15
@@ -17,27 +17,12 @@ extern cpumask_t node_to_cpumask[];#define node_to_first_cpu (node) (__ffs(node_to_cpumask[node]))#define node_to_cpumask (node) (node_to_cpumask[node]) -struct node { -paddr_t start; -paddr_t end; -}; - -extern int compute_memnode_shift (struct node *nodes,int numnodes, -nodeid_t *nodeids,unsigned int *shift);extern nodeid_t pxm_to_node (unsigned int pxm);#define ZONE_ALIGN (1UL << (MAX_ORDER+PAGE_SHIFT))extern void numa_add_cpu (int cpu); -extern void numa_init_array (void ); -extern bool srat_disabled (void ); -extern void numa_set_node (int cpu,nodeid_t node); -extern nodeid_t acpi_setup_node (unsigned int pxm); -extern void srat_detect_node (int cpu); - -extern void setup_node_bootmem (nodeid_t nodeid,paddr_t start,paddr_t end);extern nodeid_t apicid_to_node[]; -extern void init_cpu_to_node (void );/* Simple perfect hash to map pdx to node numbers */ extern unsigned int memnode_shift;
xen/include/xen/numa.h +18 -0
@@ -14,6 +14,21 @@#define MAX_NUMNODES (1 << NODES_SHIFT) +struct node { +paddr_t start; +paddr_t end; +}; + +extern int compute_memnode_shift (struct node *nodes,int numnodes, +nodeid_t *nodeids,unsigned int *shift); +extern void numa_init_array (void ); +extern bool_t srat_disabled (void ); +extern void numa_set_node (int cpu,nodeid_t node); +extern nodeid_t acpi_setup_node (unsigned int pxm); +extern void srat_detect_node (int cpu); +extern void setup_node_bootmem (nodeid_t nodeid,paddr_t start,paddr_t end); +extern void init_cpu_to_node (void ); +#define vcpu_to_node (v) (cpu_to_node((v)->processor))#define domain_to_node (d) \
@@ -23,4 +38,7 @@bool is_numa_off (void );bool get_acpi_numa (void );void set_acpi_numa (bool val); +int get_numa_fake (void ); +extern int numa_emulation (uint64_t start_pfn,uint64_t end_pfn); +extern void numa_dummy_init (uint64_t start_pfn,uint64_t end_pfn);#endif /* _XEN_NUMA_H */
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 10/25] x86: NUMA: Move numa code and make it generic
Hi Vijay,
Quoted 26 lines · On 28/03/17 16:53, [email protected] wrote:
xen/arch/x86/numa.c +0
-14@@ -10,286 +10,13 @@#include <xen/ctype.h> #include <xen/nodemask.h> #include <xen/numa.h> -#include <xen/keyhandler.h> #include <xen/time.h> #include <xen/smp.h> #include <xen/pfn.h> #include <asm/acpi.h> -#include <xen/sched.h> -#include <xen/softirq.h> - -static int numa_setup (char *s); -custom_param ("numa" , numa_setup); - -struct node_data node_data[MAX_NUMNODES ]; - -/* Mapping from pdx to node id */ -unsigned int memnode_shift; -static typeof(*memnodemap) _memnodemap[64]; -unsigned long memnodemapsize; -uint8_t *memnodemap;
xen/arch/x86/numa.c line 40
Quoted 10 lines
xen/arch/x86/numa.c +0
-10- -nodeid_t __read_mostly cpu_to_node[NR_CPUS ] = { - [0 ...NR_CPUS -1 ] =NUMA_NO_NODE -}; -/* -* Keep BIOS's CPU2node information, should not be used for memory allocaion -*/ -nodeid_t apicid_to_node[MAX_LOCAL_APIC ] = { - [0 ...MAX_LOCAL_APIC -1 ] =NUMA_NO_NODE -};
Why this is moved in this patch from here to x86/srat.c?
[...]
Quoted 5 lines
xen/arch/x86/srat.c +0
-0
xen/arch/x86/srat.c static nodemask_t __initdata memory_nodes_parsed; · line 36
Quoted 10 lines
xen/arch/x86/srat.c +7
-0@@ -27,6 +27,13 @@ static nodemask_t __initdata memory_nodes_parsed;static nodemask_t __initdata processor_nodes_parsed;static struct node __initdata nodes[MAX_NUMNODES ]; +/* +* Keep BIOS's CPU2node information, should not be used for memory allocaion +*/ +nodeid_t apicid_to_node[MAX_LOCAL_APIC ] = { + [0 ...MAX_LOCAL_APIC -1 ] =NUMA_NO_NODE +}; +
This does not belong to this patch...
Quoted 3 lines
xen/arch/x86/srat.c +0
-0struct pxm2node {unsigned int pxm;nodeid_t node;
[...]
Quoted 26 lines
xen/common/numa.c new file +20
-0@@ -0,0 +1,488 @@ +/* +* Common NUMA handling functions for x86 and arm. +* Original code extracted from arch/x86/numa.c +* +* This program is free software; you can redistribute it and/or +* modify it under the terms and conditions of the GNU General Public +* License, version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <xen/mm.h> +#include <xen/string.h> +#include <xen/init.h>
xen/common/numa.c line 30
Quoted 10 lines
xen/common/numa.c new file +10
-0+#include <xen/ctype.h> +#include <xen/nodemask.h> +#include <xen/numa.h> +#include <xen/keyhandler.h> +#include <xen/time.h> +#include <xen/smp.h> +#include <xen/pfn.h> +#include <asm/acpi.h> +#include <xen/sched.h> +#include <xen/softirq.h>
Whilst you are moving this in a newfile, please order the includes.
[...]
Quoted 13 lines
xen/common/numa.c new file +13
-0+static unsigned int __init extract_lsb_from_nodes (const struct node *nodes, +int numnodes) +{ +unsigned int i, nodes_used =0 ; +unsigned long spdx, epdx; +unsigned long bitfield =0 , memtop =0 ; + +for ( i =0 ; i < numnodes; i++ ) + { + spdx =paddr_to_pdx (nodes[i].start); + epdx =paddr_to_pdx (nodes[i].end -1 ) +1 ; +if ( spdx >= epdx ) +continue ;
xen/common/numa.c line 159
Quoted 10 lines
xen/common/numa.c new file +10
-0+ bitfield |= spdx; + nodes_used++; +if ( epdx > memtop ) + memtop = epdx; + } +if ( nodes_used <=1 ) + i =BITS_PER_LONG -1 ; +else + i =find_first_bit (&bitfield,sizeof (unsigned long ) *8 ); +
It is interesting to see that newline was added in the process of moving the code.
Quoted 1 line
xen/common/numa.c new file +1
-0+ memnodemapsize = (memtop >> i) +1 ;
[....]
Quoted 12 lines
xen/include/xen/numa.h +4
-0@@ -14,6 +14,21 @@#define MAX_NUMNODES (1 << NODES_SHIFT) +struct node { +paddr_t start; +paddr_t end; +};
xen/include/xen/numa.h line 30
Quoted 10 lines
xen/include/xen/numa.h +10
-0+ +extern int compute_memnode_shift (struct node *nodes,int numnodes, +nodeid_t *nodeids,unsigned int *shift); +extern void numa_init_array (void ); +extern bool_t srat_disabled (void ); +extern void numa_set_node (int cpu,nodeid_t node); +extern nodeid_t acpi_setup_node (unsigned int pxm); +extern void srat_detect_node (int cpu); +extern void setup_node_bootmem (nodeid_t nodeid,paddr_t start,paddr_t end); +extern void init_cpu_to_node (void );
Can you please be consistent with this file and drop the unecessary "extern".
xen/include/xen/numa.h line 43
Quoted 11 lines
xen/include/xen/numa.h +4
-0+#define vcpu_to_node (v) (cpu_to_node((v)->processor))#define domain_to_node (d) \@@ -23,4 +38,7 @@bool is_numa_off (void );bool get_acpi_numa (void );void set_acpi_numa (bool val); +int get_numa_fake (void ); +extern int numa_emulation (uint64_t start_pfn,uint64_t end_pfn); +extern void numa_dummy_init (uint64_t start_pfn,uint64_t end_pfn);
Ditto.
Quoted 2 lines
xen/include/xen/numa.h +0
-0#endif /* _XEN_NUMA_H */
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 10/25] x86: NUMA: Move numa code and make it generic
Quoted 37 lines · Julien Grall
Hi Vijay,
Quoted 33 lines · On 28/03/17 16:53, [email protected] wrote:
xen/arch/x86/numa.c +0
-20@@ -10,286 +10,13 @@#include <xen/ctype.h> #include <xen/nodemask.h> #include <xen/numa.h> -#include <xen/keyhandler.h> #include <xen/time.h> #include <xen/smp.h> #include <xen/pfn.h> #include <asm/acpi.h> -#include <xen/sched.h> -#include <xen/softirq.h> - -static int numa_setup (char *s); -custom_param ("numa" , numa_setup); - -struct node_data node_data[MAX_NUMNODES ]; - -/* Mapping from pdx to node id */ -unsigned int memnode_shift; -static typeof(*memnodemap) _memnodemap[64]; -unsigned long memnodemapsize; -uint8_t *memnodemap; - -nodeid_t __read_mostly cpu_to_node[NR_CPUS ] = { - [0 ...NR_CPUS -1 ] =NUMA_NO_NODE -}; -/* -* Keep BIOS's CPU2node information, should not be used for memory
Quoted 8 lines
xen/arch/x86/numa.c line 40
Quoted 5 lines
allocaion
- */xen/arch/x86/numa.c +0
-3-nodeid_t apicid_to_node[MAX_LOCAL_APIC ] = { - [0 ...MAX_LOCAL_APIC -1 ] =NUMA_NO_NODE -};Why this is moved in this patch from here to
x86/srat.c?
This is x86 specific. I will make a separate patch for this move.
Quoted 11 lines
[...]
Quoted 8 lines
xen/arch/x86/srat.c +0
-0@@ -27,6 +27,13 @@ static nodemask_t __initdata memory_nodes_parsed;static nodemask_t __initdata processor_nodes_parsed;static struct node __initdata nodes[MAX_NUMNODES ];
Quoted 11 lines
xen/arch/x86/srat.c static nodemask_t __initdata memory_nodes_parsed; · line 36
Quoted 8 lines
xen/arch/x86/srat.c +2
-0+/* +* Keep BIOS's CPU2node information, should not be used for memory allocaion
+ */xen/arch/x86/srat.c +4
-0+nodeid_t apicid_to_node[MAX_LOCAL_APIC ] = { + [0 ...MAX_LOCAL_APIC -1 ] =NUMA_NO_NODE +}; +This does not belong to this patch...
Ok
Quoted 40 lines
Quoted 4 lines
struct pxm2node { unsigned int pxm; nodeid_t node;[...]
Quoted 31 lines
xen/common/numa.c new file +25
-0@@ -0,0 +1,488 @@ +/* +* Common NUMA handling functions for x86 and arm. +* Original code extracted from arch/x86/numa.c +* +* This program is free software; you can redistribute it and/or +* modify it under the terms and conditions of the GNU General Public +* License, version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <xen/mm.h> +#include <xen/string.h> +#include <xen/init.h> +#include <xen/ctype.h> +#include <xen/nodemask.h> +#include <xen/numa.h> +#include <xen/keyhandler.h> +#include <xen/time.h>
Quoted 8 lines
xen/common/numa.c line 30
Quoted 5 lines
xen/common/numa.c new file +5
-0+#include <xen/smp.h> +#include <xen/pfn.h> +#include <asm/acpi.h> +#include <xen/sched.h> +#include <xen/softirq.h> Whilst you are moving this in a newfile, please order the includes.
I understand that you don't like any code changes in code movement patch.
Quoted 23 lines
[...]
Quoted 20 lines
+static unsigned int
__initextract_lsb_from_nodes(const struct node *nodes,xen/common/numa.c new file +18
-0+ int numnodes) +{ +unsigned int i, nodes_used =0 ; +unsigned long spdx, epdx; +unsigned long bitfield =0 , memtop =0 ; + +for ( i =0 ; i < numnodes; i++ ) + { + spdx =paddr_to_pdx (nodes[i].start); + epdx =paddr_to_pdx (nodes[i].end -1 ) +1 ; +if ( spdx >= epdx ) +continue ; + bitfield |= spdx; + nodes_used++; +if ( epdx > memtop ) + memtop = epdx; + } +if ( nodes_used <=1 )
Quoted 8 lines
xen/common/numa.c line 159
Quoted 4 lines
xen/common/numa.c new file +4
-0+ i =BITS_PER_LONG -1 ; + else + i =find_first_bit (&bitfield,sizeof (unsigned long ) *8 ); +It is interesting to see that newline was added in the process of moving the code.
OK.
Quoted 25 lines
Quoted 2 lines
+ memnodemapsize = (memtop >> i) + 1;
[....]
Quoted 19 lines
xen/include/xen/numa.h +11
-0@@ -14,6 +14,21 @@#define MAX_NUMNODES (1 << NODES_SHIFT) +struct node { +paddr_t start; +paddr_t end; +}; + +extern int compute_memnode_shift (struct node *nodes,int numnodes, +nodeid_t *nodeids,unsigned int *shift); +extern void numa_init_array (void ); +extern bool_t srat_disabled (void ); +extern void numa_set_node (int cpu,nodeid_t node); +extern nodeid_t acpi_setup_node (unsigned int pxm);
Quoted 8 lines
xen/include/xen/numa.h line 30
Quoted 4 lines
xen/include/xen/numa.h +3
-0+extern void srat_detect_node (int cpu); +extern void setup_node_bootmem (nodeid_t nodeid,paddr_t start,paddr_t end); +extern void init_cpu_to_node (void );Can you please be consistent with this file and drop the unecessary "extern".
I see all the externs are not required here. I will drop
Quoted 17 lines
xen/include/xen/numa.h line 43
Quoted 12 lines
xen/include/xen/numa.h +1
-0+#define vcpu_to_node (v) (cpu_to_node((v)->processor))#define
domain_to_node(d)\xen/include/xen/numa.h +3
-0@@ -23,4 +38,7 @@bool is_numa_off (void );bool get_acpi_numa (void );void set_acpi_numa (bool val); +int get_numa_fake (void ); +extern int numa_emulation (uint64_t start_pfn,uint64_t end_pfn); +extern void numa_dummy_init (uint64_t start_pfn,uint64_t end_pfn);Ditto.
Quoted 5 lines
xen/include/xen/numa.h line 44
Quoted 2 lines
xen/include/xen/numa.h +0
-0#endif /* _XEN_NUMA_H */ --
Julien Grall
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 10/25] x86: NUMA: Move numa code and make it generic
Quoted 47 lines · Vijay Kilari
Quoted 37 lines · Julien Grall
Hi Vijay,
Quoted 33 lines · On 28/03/17 16:53, [email protected] wrote:
xen/arch/x86/numa.c +0
-20@@ -10,286 +10,13 @@#include <xen/ctype.h> #include <xen/nodemask.h> #include <xen/numa.h> -#include <xen/keyhandler.h> #include <xen/time.h> #include <xen/smp.h> #include <xen/pfn.h> #include <asm/acpi.h> -#include <xen/sched.h> -#include <xen/softirq.h> - -static int numa_setup (char *s); -custom_param ("numa" , numa_setup); - -struct node_data node_data[MAX_NUMNODES ]; - -/* Mapping from pdx to node id */ -unsigned int memnode_shift; -static typeof(*memnodemap) _memnodemap[64]; -unsigned long memnodemapsize; -uint8_t *memnodemap; - -nodeid_t __read_mostly cpu_to_node[NR_CPUS ] = { - [0 ...NR_CPUS -1 ] =NUMA_NO_NODE -}; -/* -* Keep BIOS's CPU2node information, should not be used for memory Quoted 8 lines
xen/arch/x86/numa.c line 40
Quoted 5 lines
allocaion
- */xen/arch/x86/numa.c +0
-3-nodeid_t apicid_to_node[MAX_LOCAL_APIC ] = { - [0 ...MAX_LOCAL_APIC -1 ] =NUMA_NO_NODE -};Why this is moved in this patch from here to
x86/srat.c?
Quoted 2 lines
This is x86 specific. I will make a separate patch for this move.
But x86/numa.c is specific specific.... So why do you move it????
Quoted 73 lines
Quoted 12 lines
[...]
Quoted 8 lines
xen/arch/x86/srat.c +0
-0@@ -27,6 +27,13 @@ static nodemask_t __initdata memory_nodes_parsed;static nodemask_t __initdata processor_nodes_parsed;static struct node __initdata nodes[MAX_NUMNODES ];Quoted 11 lines
xen/arch/x86/srat.c static nodemask_t __initdata memory_nodes_parsed; · line 36
Quoted 8 lines
xen/arch/x86/srat.c +2
-0+/* +* Keep BIOS's CPU2node information, should not be used for memory allocaion
+ */xen/arch/x86/srat.c +4
-0+nodeid_t apicid_to_node[MAX_LOCAL_APIC ] = { + [0 ...MAX_LOCAL_APIC -1 ] =NUMA_NO_NODE +}; +This does not belong to this patch...
Ok
Quoted 40 lines
Quoted 4 lines
struct pxm2node { unsigned int pxm; nodeid_t node;[...]
Quoted 31 lines
xen/common/numa.c new file +25
-0@@ -0,0 +1,488 @@ +/* +* Common NUMA handling functions for x86 and arm. +* Original code extracted from arch/x86/numa.c +* +* This program is free software; you can redistribute it and/or +* modify it under the terms and conditions of the GNU General Public +* License, version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <xen/mm.h> +#include <xen/string.h> +#include <xen/init.h> +#include <xen/ctype.h> +#include <xen/nodemask.h> +#include <xen/numa.h> +#include <xen/keyhandler.h> +#include <xen/time.h> Quoted 8 lines
xen/common/numa.c line 30
Quoted 5 lines
xen/common/numa.c new file +5
-0+#include <xen/smp.h> +#include <xen/pfn.h> +#include <asm/acpi.h> +#include <xen/sched.h> +#include <xen/softirq.h> Whilst you are moving this in a newfile, please order the includes.
Quoted 2 lines
I understand that you don't like any code changes in code movement patch.
Are you saying you blindly copied the headers without even checking they are necessary?
Surely, you only added the one necessary which means it would be ok to sort them as if one is missing this would be catch by compilation.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 10/25] x86: NUMA: Move numa code and make it generic
In reply to [email protected]Quoted 35 lines · On 28/03/17 16:53, [email protected] wrote:
xen/common/numa.c new file +29
-0@@ -0,0 +1,488 @@ +/* +* Common NUMA handling functions for x86 and arm. +* Original code extracted from arch/x86/numa.c +* +* This program is free software; you can redistribute it and/or +* modify it under the terms and conditions of the GNU General Public +* License, version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <xen/mm.h> +#include <xen/string.h> +#include <xen/init.h> +#include <xen/ctype.h> +#include <xen/nodemask.h> +#include <xen/numa.h> +#include <xen/keyhandler.h> +#include <xen/time.h> +#include <xen/smp.h> +#include <xen/pfn.h> +#include <asm/acpi.h> +#include <xen/sched.h>
xen/common/numa.c line 39
Quoted 10 lines
xen/common/numa.c new file +10
-0+#include <xen/softirq.h> + +static int numa_setup (char *s); +custom_param ("numa" , numa_setup); + +struct node_data node_data[MAX_NUMNODES ]; + +/* Mapping from pdx to node id */ +unsigned int memnode_shift; +static typeof(*memnodemap) _memnodemap[64];
Also, you move the hardcoded 64 here. But have you checked it is valid for ARM?
Regardless that, this sounds like something that should be turned into a define and require a comment.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 10/25] x86: NUMA: Move numa code and make it generic
Quoted 52 lines · Julien Grall
Quoted 36 lines · On 28/03/17 16:53, [email protected] wrote:
xen/common/numa.c new file +29
-0@@ -0,0 +1,488 @@ +/* +* Common NUMA handling functions for x86 and arm. +* Original code extracted from arch/x86/numa.c +* +* This program is free software; you can redistribute it and/or +* modify it under the terms and conditions of the GNU General Public +* License, version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <xen/mm.h> +#include <xen/string.h> +#include <xen/init.h> +#include <xen/ctype.h> +#include <xen/nodemask.h> +#include <xen/numa.h> +#include <xen/keyhandler.h> +#include <xen/time.h> +#include <xen/smp.h> +#include <xen/pfn.h> +#include <asm/acpi.h> +#include <xen/sched.h> xen/common/numa.c line 39
Quoted 10 lines
xen/common/numa.c new file +10
-0+#include <xen/softirq.h> + +static int numa_setup (char *s); +custom_param ("numa" , numa_setup); + +struct node_data node_data[MAX_NUMNODES ]; + +/* Mapping from pdx to node id */ +unsigned int memnode_shift; +static typeof(*memnodemap) _memnodemap[64];Also, you move the hardcoded 64 here. But have you checked it is valid for ARM?
Quoted 2 lines
Regardless that, this sounds like something that should be turned into a define and require a comment.
64 is good enough. This _memnodemap is used in case of NUMA failed or off, in which case memnode_shift is 63 (BITS_PER_LONG -1).
So all the phys_to_nid() conversion will indexed within limits of _memnodemap[]
Quoted 5 lines
Cheers,
--
Julien Grall
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 10/25] x86: NUMA: Move numa code and make it generic
Quoted 15 lines · Vijay Kilari
Quoted 14 lines · Julien Grall
xen/common/numa.c line 39
Quoted 8 lines · On 28/03/17 16:53, [email protected] wrote:
xen/common/numa.c new file +8
-0+static int numa_setup (char *s); +custom_param ("numa" , numa_setup); + +struct node_data node_data[MAX_NUMNODES ]; + +/* Mapping from pdx to node id */ +unsigned int memnode_shift; +static typeof(*memnodemap) _memnodemap[64];Also, you move the hardcoded 64 here. But have you checked it is valid for ARM?
Quoted 5 lines
Quoted 2 lines
Regardless that, this sounds like something that should be turned into a define and require a comment.
64 is good enough. This
_memnodemapis used in case of NUMA failed or off, in which casememnode_shiftis 63 (BITS_PER_LONG-1).
If it based on BITS_PER_LONG, then you should use BITS_PER_LONG (via a proper define) rather than hardcoding it.
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
RFC PATCH v2 11/25 x86: NUMA: Move common code from srat.c
In reply to [email protected]From: Vijaya Kumar K <[email protected]>
Move code from xen/arch/x86/srat.c to xen/common/numa.c so that it can be used by other archs.
Few generic static functions in x86/srat.c are made non-static common/numa.c
--- xen/arch/x86/srat.c | 152 ++------------------------------------------- xen/common/numa.c | 146 +++++++++++++++++++++++++++++++++++++++++++ xen/include/asm-x86/acpi.h | 3 - xen/include/asm-x86/numa.h | 2 - xen/include/xen/numa.h | 14 +++++ 5 files changed, 164 insertions(+), 153 deletions(-)
xen/arch/x86/srat.c +4 -148
@@ -23,9 +23,8 @@static struct acpi_table_slit *__read_mostly acpi_slit; -static nodemask_t __initdata memory_nodes_parsed; -static nodemask_t __initdata processor_nodes_parsed; -static struct node __initdata nodes[MAX_NUMNODES ]; +extern nodemask_t processor_nodes_parsed; +extern nodemask_t memory_nodes_parsed;/* * Keep BIOS's CPU2node information, should not be used for memory allocaion
@@ -43,49 +42,8 @@ static struct pxm2node __read_mostly pxm2node[MAX_NUMNODES] =static unsigned node_to_pxm (nodeid_t n); -static int num_node_memblks; -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); -static struct node *get_numa_node (int id) -{ -return &nodes[id]; -} - -static nodeid_t get_memblk_nodeid (int id) -{ -return memblk_nodeid[id]; -} - -static nodeid_t *get_memblk_nodeid_map (void ) -{ -return &memblk_nodeid[0 ]; -} - -static struct node *get_node_memblk_range (int memblk) -{ -return &node_memblk_range[memblk]; -} - -static int get_num_node_memblks (void ) -{ -return num_node_memblks; -} - -static int __init numa_add_memblk (nodeid_t nodeid,paddr_t start,uint64_t size) -{ -if (nodeid >=NR_NODE_MEMBLKS ) -return -EINVAL ; - - node_memblk_range[num_node_memblks].start = start; - node_memblk_range[num_node_memblks].end = start + size; - memblk_nodeid[num_node_memblks] = nodeid; - num_node_memblks++; - -return 0 ; -} -static inline bool node_found (unsigned int idx,unsigned int pxm) { return ((pxm2node[idx].pxm == pxm) &&
@@ -156,54 +114,7 @@ nodeid_t acpi_setup_node(unsigned int pxm)return node; } -int valid_numa_range (paddr_t start,paddr_t end,nodeid_t node) -{ -int i; - -for (i =0 ; i <get_num_node_memblks (); i++) { -struct node *nd =get_node_memblk_range (i); - -if (nd->start <= start && nd->end > end && -get_memblk_nodeid (i) == node) -return 1 ; - } - -return 0 ; -} - -static int __init conflicting_memblks (paddr_t start,paddr_t end) -{ -int i; - -for (i =0 ; i <get_num_node_memblks (); i++) { -struct node *nd =get_node_memblk_range (i); -if (nd->start == nd->end) -continue ; -if (nd->end > start && nd->start < end) -return i; -if (nd->end == end && nd->start == start) -return i; - } -return -1 ; -} - -static void __init cutoff_node (int i,paddr_t start,paddr_t end) -{ -struct node *nd =get_numa_node (i); - -if (nd->start < start) { - nd->start = start; -if (nd->end < nd->start) - nd->start = nd->end; - } -if (nd->end > end) { - nd->end = end; -if (nd->start > nd->end) - nd->start = nd->end; - } -} - -static void __init numa_failed (void ) +void __init numa_failed (void ) {int i;printk (KERN_ERR "SRAT: SRAT not used.\n" );
@@ -419,7 +330,7 @@ acpi_numa_memory_affinity_init(const struct acpi_srat_mem_affinity *ma)/* Sanity check to catch more bad SRATs (they are amazingly common). Make sure the PXMs cover all memory. */ -static int __init arch_sanitize_nodes_memory (void ) +int __init arch_sanitize_nodes_memory (void ) {int i;
@@ -516,61 +427,6 @@ void __init srat_parse_regions(uint64_t addr)pfn_pdx_hole_setup (mask >>PAGE_SHIFT ); } -/* Use the information discovered above to actually set up the nodes. */ -int __init numa_scan_nodes (uint64_t start,uint64_t end) -{ -int i; -nodemask_t all_nodes_parsed; -struct node *memblks; -nodeid_t *nodeids; - -/* First clean up the node list */ -for (i =0 ; i <MAX_NUMNODES ; i++) -cutoff_node (i, start, end); - -if (get_acpi_numa () ==0 ) -return -1 ; - -if (!arch_sanitize_nodes_memory ()) { -numa_failed (); -return -1 ; - } - - memblks =get_node_memblk_range (0 ); - nodeids =get_memblk_nodeid_map (); -if (compute_memnode_shift (node_memblk_range, num_node_memblks, - memblk_nodeid, &memnode_shift)) { - memnode_shift =0 ; -printk (KERN_ERR -"SRAT: No NUMA node hash function found. Contact maintainer\n" ); -numa_failed (); -return -1 ; - } - -nodes_or (all_nodes_parsed, memory_nodes_parsed, processor_nodes_parsed); - -/* Finally register nodes */ -for_each_node_mask (i, all_nodes_parsed) - { -struct node *nd =get_numa_node (i); -uint64_t size = nd->end - nd->start; - -if ( size ==0 ) -printk (KERN_WARNING "SRAT: Node %u has no memory. " -"BIOS Bug or mis-configured hardware?\n" , i); - -setup_node_bootmem (i, nd->start, nd->end); - } -for (i =0 ; i < nr_cpu_ids; i++) { -if (cpu_to_node[i] ==NUMA_NO_NODE ) -continue ; -if (!node_isset (cpu_to_node[i], processor_nodes_parsed)) -numa_set_node (i,NUMA_NO_NODE ); - } -numa_init_array (); -return 0 ; -} -static unsigned node_to_pxm (nodeid_t n) {unsigned i;
xen/common/numa.c +146 -0
170 lines not on this page · raw message
xen/include/asm-x86/acpi.h +0 -3
@@ -103,9 +103,6 @@ extern void acpi_reserve_bootmem(void);#define ARCH_HAS_POWER_INIT 1 -extern int numa_scan_nodes (u64 start,u64 end); -#define NR_NODE_MEMBLKS (MAX_NUMNODES*2) -#ifdef CONFIG_ACPI_SLEEP extern struct acpi_sleep_info acpi_sinfo;
xen/include/asm-x86/numa.h +0 -2
@@ -47,8 +47,6 @@ static inline __attribute__((pure)) nodeid_t phys_to_nid(paddr_t addr)#define node_end_pfn (nid) (NODE_DATA(nid)->node_start_pfn + \ NODE_DATA(nid)->node_spanned_pages) -extern int valid_numa_range (paddr_t start,paddr_t end,nodeid_t node); -void srat_parse_regions (uint64_t addr);extern uint8_t __node_distance (nodeid_t a,nodeid_t b);unsigned int arch_get_dma_bitsize (void );
xen/include/xen/numa.h +14 -0
@@ -13,6 +13,7 @@#define NUMA_NO_DISTANCE 0xFF#define MAX_NUMNODES (1 << NODES_SHIFT) +#define NR_NODE_MEMBLKS (MAX_NUMNODES * 2)struct node {paddr_t start;
@@ -28,6 +29,19 @@ extern nodeid_t acpi_setup_node(unsigned int pxm);extern void srat_detect_node (int cpu);extern void setup_node_bootmem (nodeid_t nodeid,paddr_t start,paddr_t end);extern void init_cpu_to_node (void ); +extern int valid_numa_range (paddr_t start,paddr_t end,nodeid_t node); +extern int conflicting_memblks (paddr_t start,paddr_t end); +extern void cutoff_node (int i,paddr_t start,paddr_t end); +extern struct node *get_numa_node (int id); +extern nodeid_t get_memblk_nodeid (int memblk); +extern nodeid_t *get_memblk_nodeid_map (void ); +extern struct node *get_node_memblk_range (int memblk); +extern struct node *get_memblk (int memblk); +extern int numa_add_memblk (nodeid_t nodeid,paddr_t start,uint64_t size); +extern int get_num_node_memblks (void ); +extern int arch_sanitize_nodes_memory (void ); +extern void numa_failed (void ); +extern int numa_scan_nodes (uint64_t start,uint64_t end);#define vcpu_to_node (v) (cpu_to_node((v)->processor))
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 11/25] x86: NUMA: Move common code from srat.c
Hi Vijay,
Quoted 21 lines · On 28/03/17 16:53, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
Move code from
xen/arch/x86/srat.ctoxen/common/numa.cso that it can be used by other archs.
Few generic static functions inx86/srat.care made non-staticcommon/numa.cSigned-off-by Vijaya Kumar K <[email protected]>--- xen/arch/x86/srat.c | 152 ++------------------------------------------- xen/common/numa.c | 146 +++++++++++++++++++++++++++++++++++++++++++ xen/include/asm-x86/acpi.h | 3 - xen/include/asm-x86/numa.h | 2 - xen/include/xen/numa.h | 14 +++++ 5 files changed, 164 insertions(+), 153 deletions(-)xen/arch/x86/srat.c +0
-0
xen/arch/x86/srat.c line 27
Quoted 8 lines
xen/arch/x86/srat.c +2
-3@@ -23,9 +23,8 @@static struct acpi_table_slit *__read_mostly acpi_slit; -static nodemask_t __initdata memory_nodes_parsed; -static nodemask_t __initdata processor_nodes_parsed; -static struct node __initdata nodes[MAX_NUMNODES ]; +extern nodemask_t processor_nodes_parsed; +extern nodemask_t memory_nodes_parsed;
On v1, Jan clearly NAK to changes like this. Declarations belong in header files. It is a different variable compare to v1, but I would have expected you to apply what he said everywhere...
[...]
Quoted 14 lines
xen/common/numa.c +2
-0@@ -32,6 +32,8 @@static int numa_setup (char *s);custom_param ("numa" , numa_setup); +nodemask_t __initdata memory_nodes_parsed; +nodemask_t __initdata processor_nodes_parsed;struct node_data node_data[MAX_NUMNODES ];/* Mapping from pdx to node id */
xen/common/numa.c cpumask_t __read_mostly node_to_cpumask[MAX_NUMNODES]; · line 55
Quoted 7 lines
xen/common/numa.c +4
-0@@ -47,6 +49,10 @@ cpumask_t __read_mostly node_to_cpumask[MAX_NUMNODES];static bool numa_off =0 ;static bool acpi_numa =1 ; +static int num_node_memblks; +static struct node node_memblk_range[NR_NODE_MEMBLKS ]; +static nodeid_t memblk_nodeid[NR_NODE_MEMBLKS ]; +static struct node __initdata nodes[MAX_NUMNODES ];
It would make sense to keep those variables together with {memory,processor}_nodes_parsed.
[...]
xen/common/numa.c bool srat_disabled(void) · line 119
Quoted 5 lines
xen/common/numa.c +5
-0+int valid_numa_range (paddr_t start,paddr_t end,nodeid_t node) +{ +int i; + +for (i =0 ; i <get_num_node_memblks (); i++) {
common/numa.c is using Xen coding style whilst arch/x86/srat.c is using Linux coding style.
You decided to validly switch to soft tab, making quite difficult to check if this patch is only code movement. But you did not go far enough and fix the coding style of the code moved.
Please do it properly and not half of it. For simplicity I would be OK that it is done in this patch. But this needs to be clearly written in the commit message.
Quoted 9 lines
xen/common/numa.c +9
-0+struct node *nd =get_node_memblk_range (i); + +if (nd->start <= start && nd->end > end && +get_memblk_nodeid (i) == node) +return 1 ; + } + +return 0 ; +}
[...]
Quoted 32 lines
xen/include/asm-x86/numa.h +0
-2@@ -47,8 +47,6 @@ static inline __attribute__((pure)) nodeid_t phys_to_nid(paddr_t addr)#define node_end_pfn (nid) (NODE_DATA(nid)->node_start_pfn + \ NODE_DATA(nid)->node_spanned_pages) -extern int valid_numa_range (paddr_t start,paddr_t end,nodeid_t node); -void srat_parse_regions (uint64_t addr);extern uint8_t __node_distance (nodeid_t a,nodeid_t b);unsigned int arch_get_dma_bitsize (void );xen/include/xen/numa.h +4
-0@@ -13,6 +13,7 @@#define NUMA_NO_DISTANCE 0xFF#define MAX_NUMNODES (1 << NODES_SHIFT) +#define NR_NODE_MEMBLKS (MAX_NUMNODES * 2)struct node {paddr_t start;@@ -28,6 +29,19 @@ extern nodeid_t acpi_setup_node(unsigned int pxm);extern void srat_detect_node (int cpu);extern void setup_node_bootmem (nodeid_t nodeid,paddr_t start,paddr_t end);extern void init_cpu_to_node (void ); +extern int valid_numa_range (paddr_t start,paddr_t end,nodeid_t node); +extern int conflicting_memblks (paddr_t start,paddr_t end); +extern void cutoff_node (int i,paddr_t start,paddr_t end);
xen/include/xen/numa.h extern nodeid_t acpi_setup_node(unsigned int pxm); · line 44
Quoted 10 lines
xen/include/xen/numa.h +10
-0+extern struct node *get_numa_node (int id); +extern nodeid_t get_memblk_nodeid (int memblk); +extern nodeid_t *get_memblk_nodeid_map (void ); +extern struct node *get_node_memblk_range (int memblk); +extern struct node *get_memblk (int memblk); +extern int numa_add_memblk (nodeid_t nodeid,paddr_t start,uint64_t size); +extern int get_num_node_memblks (void ); +extern int arch_sanitize_nodes_memory (void ); +extern void numa_failed (void ); +extern int numa_scan_nodes (uint64_t start,uint64_t end);
See my comment on the previous patch.
xen/include/xen/numa.h extern nodeid_t acpi_setup_node(unsigned int pxm);
Quoted 4 lines
xen/include/xen/numa.h +0
-0#define vcpu_to_node (v) (cpu_to_node((v)->processor))
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 11/25] x86: NUMA: Move common code from srat.c
and
Quoted 31 lines · Julien Grall
Hi Vijay,
Quoted 27 lines · On 28/03/17 16:53, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
Move code from
xen/arch/x86/srat.ctoxen/common/numa.cso that it can be used by other archs.
Few generic static functions inx86/srat.care made non-staticcommon/numa.cSigned-off-by Vijaya Kumar K <[email protected]>--- xen/arch/x86/srat.c | 152 ++------------------------------------------- xen/common/numa.c | 146 +++++++++++++++++++++++++++++++++++++++++++ xen/include/asm-x86/acpi.h | 3 - xen/include/asm-x86/numa.h | 2 - xen/include/xen/numa.h | 14 +++++ 5 files changed, 164 insertions(+), 153 deletions(-)xen/arch/x86/srat.c +0
-0@@ -23,9 +23,8 @@static struct acpi_table_slit *__read_mostly acpi_slit;
Quoted 10 lines
xen/arch/x86/srat.c line 27
Quoted 5 lines
xen/arch/x86/srat.c +2
-3-static nodemask_t __initdata memory_nodes_parsed; -static nodemask_t __initdata processor_nodes_parsed; -static struct node __initdata nodes[MAX_NUMNODES ]; +extern nodemask_t processor_nodes_parsed; +extern nodemask_t memory_nodes_parsed;On v1, Jan clearly NAK to changes like this. Declarations belong in header files. It is a different variable compare to v1, but I would have expected you to apply what he said everywhere...
Ok I will move these to header files.
One more change that I made is moved from static to global. because creating accessor functions around these nodesmask_t is tricky because the macros (defined in nodemask.h) does not take pointer parameters.
I will add comment.
Quoted 18 lines
[...]
Quoted 15 lines
xen/common/numa.c +2
-0@@ -32,6 +32,8 @@static int numa_setup (char *s);custom_param ("numa" , numa_setup); +nodemask_t __initdata memory_nodes_parsed; +nodemask_t __initdata processor_nodes_parsed;struct node_data node_data[MAX_NUMNODES ];/* Mapping from pdx to node id */ @@ -47,6 +49,10 @@ cpumask_t __read_mostly node_to_cpumask[MAX_NUMNODES];
Quoted 10 lines
xen/common/numa.c cpumask_t __read_mostly node_to_cpumask[MAX_NUMNODES]; · line 55
Quoted 6 lines
xen/common/numa.c +4
-0static bool numa_off =0 ;static bool acpi_numa =1 ; +static int num_node_memblks; +static struct node node_memblk_range[NR_NODE_MEMBLKS ]; +static nodeid_t memblk_nodeid[NR_NODE_MEMBLKS ]; +static struct node __initdata nodes[MAX_NUMNODES ];It would make sense to keep those variables together with {memory,processor}_nodes_parsed.
ok
Quoted 13 lines
[...]
xen/common/numa.c bool srat_disabled(void) · line 119
Quoted 5 lines
xen/common/numa.c +5
-0+int valid_numa_range (paddr_t start,paddr_t end,nodeid_t node) +{ +int i; + +for (i =0 ; i <get_num_node_memblks (); i++) {
common/numa.cis using Xen coding style whilstarch/x86/srat.cis using Linux coding style.
Quoted 7 lines
You decided to validly switch to soft tab, making quite difficult to check if this patch is only code movement. But you did not go far enough and fix the coding style of the code moved.
Please do it properly and not half of it. For simplicity I would be OK that it is done in this patch. But this needs to be clearly written in the commit message.
I will add in commit message about coding style changes to destination file compared to source file.
Quoted 55 lines
Quoted 10 lines
xen/common/numa.c +9
-0+struct node *nd =get_node_memblk_range (i); + +if (nd->start <= start && nd->end > end && +get_memblk_nodeid (i) == node) +return 1 ; + } + +return 0 ; +}[...]
Quoted 40 lines
xen/include/asm-x86/numa.h +0
-2@@ -47,8 +47,6 @@ static inline __attribute__((pure)) nodeid_t phys_to_nid(paddr_t addr)#define node_end_pfn (nid) (NODE_DATA(nid)->node_start_pfn + \ NODE_DATA(nid)->node_spanned_pages) -extern int valid_numa_range (paddr_t start,paddr_t end,nodeid_t node); -void srat_parse_regions (uint64_t addr);extern uint8_t __node_distance (nodeid_t a,nodeid_t b);unsigned int
arch_get_dma_bitsize(void);xen/include/xen/numa.h +10
-0@@ -13,6 +13,7 @@#define NUMA_NO_DISTANCE 0xFF#define MAX_NUMNODES (1 << NODES_SHIFT) +#define NR_NODE_MEMBLKS (MAX_NUMNODES * 2)struct node {paddr_t start;@@ -28,6 +29,19 @@ extern nodeid_t acpi_setup_node(unsigned int pxm);extern void srat_detect_node (int cpu);extern void setup_node_bootmem (nodeid_t nodeid,paddr_t start,paddr_t end);extern void init_cpu_to_node (void ); +extern int valid_numa_range (paddr_t start,paddr_t end,nodeid_t node); +extern int conflicting_memblks (paddr_t start,paddr_t end); +extern void cutoff_node (int i,paddr_t start,paddr_t end); +extern struct node *get_numa_node (int id); +extern nodeid_t get_memblk_nodeid (int memblk); +extern nodeid_t *get_memblk_nodeid_map (void ); +extern struct node *get_node_memblk_range (int memblk); +extern struct node *get_memblk (int memblk); +extern int numa_add_memblk(nodeid_t nodeid, paddr_t start, uint64_t
Quoted 8 lines
xen/include/xen/numa.h extern nodeid_t acpi_setup_node(unsigned int pxm); · line 44
Quoted 5 lines
xen/include/xen/numa.h +4
-0size); +extern int get_num_node_memblks (void ); +extern int arch_sanitize_nodes_memory (void ); +extern void numa_failed (void ); +extern int numa_scan_nodes (uint64_t start,uint64_t end);See my comment on the previous patch.
I understand that we can drop this extern
Quoted 10 lines
xen/include/xen/numa.h extern nodeid_t acpi_setup_node(unsigned int pxm); · line 46
Quoted 5 lines
xen/include/xen/numa.h +0
-0#define vcpu_to_node (v) (cpu_to_node((v)->processor))Cheers,
--
Julien Grall
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
RFC PATCH v2 12/25 ARM: NUMA: Parse CPU NUMA information
In reply to [email protected]From: Vijaya Kumar K <[email protected]>
Parse CPU node and fetch numa-node-id information. For each node-id found, update nodemask_t mask. Refer to /Documentation/devicetree/bindings/numa.txt.
--- xen/arch/arm/Makefile | 1 + xen/arch/arm/bootfdt.c | 16 ++++++++-- xen/arch/arm/numa/Makefile | 2 ++ xen/arch/arm/numa/dt_numa.c | 78 +++++++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/numa/numa.c | 50 +++++++++++++++++++++++++++++ xen/arch/arm/setup.c | 4 +++ xen/include/asm-arm/numa.h | 10 +++++- xen/include/asm-arm/setup.h | 4 ++- 8 files changed, 161 insertions(+), 4 deletions(-)
xen/arch/arm/Makefile +1 -0
@@ -3,6 +3,7 @@ subdir-$(CONFIG_ARM_64) += arm64 subdir-y += platforms subdir-$(CONFIG_ARM_64) += efi subdir-$(CONFIG_ACPI) += acpi +subdir-$(CONFIG_NUMA) += numa obj-$(CONFIG_HAS_ALTERNATIVE) += alternative.o obj-y += bootfdt.init.o
xen/arch/arm/bootfdt.c +14 -2
@@ -62,8 +62,20 @@ static void __init device_tree_get_reg(const __be32 **cell, u32 address_cells, *size =dt_next_cell (size_cells, cell); } -static u32 __init device_tree_get_u32 (const void *fdt,int node, -const char *prop_name,u32 dflt) +bool_t __init device_tree_type_matches (const void *fdt,int node, +const char *match) +{ +const void *prop; + + prop =fdt_getprop (fdt, node,"device_type" ,NULL ); +if ( prop ==NULL ) +return 0 ; + +return strcmp (prop, match) ==0 ?1 :0 ; +} + +u32 __init device_tree_get_u32 (const void *fdt,int node, +const char *prop_name,u32 dflt) {const struct fdt_property *prop;
xen/arch/arm/numa/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +obj-y += dt_numa.o +obj-y += numa.o
xen/arch/arm/numa/dt_numa.c new file +78 -0
78 lines not on this page · raw message
xen/arch/arm/numa/numa.c new file +50 -0
50 lines not on this page · raw message
xen/arch/arm/setup.c +4 -0
@@ -38,6 +38,7 @@#include <xen/libfdt/libfdt.h> #include <xen/acpi.h> #include <asm/alternative.h> +#include <xen/numa.h> #include <asm/page.h> #include <asm/current.h> #include <asm/setup.h>
@@ -758,6 +759,9 @@ void __init start_xen(unsigned long boot_phys_offset,else printk ("Booting using ACPI\n" ); +/* numa_init parses acpi tables. So call after acpi init */ +numa_init (); +end_boot_allocator ();vm_init ();
xen/include/asm-arm/numa.h +9 -1
@@ -6,7 +6,15 @@ typedef uint8_t nodeid_t;/* Limit number of NUMA nodes supported to 4 */ #define NODES_SHIFT 2 -#ifndef CONFIG_NUMA +#ifdef CONFIG_NUMA +extern void numa_init (void ); +extern int dt_numa_init (void ); +#else +static inline void numa_init (void ) +{ +return ; +} +/* Fake one node for now. See also node_online_map. */ #define cpu_to_node (cpu) 0#define node_to_cpumask (node) (cpu_online_map)
xen/include/asm-arm/setup.h +3 -1
@@ -79,7 +79,9 @@ struct bootmodule *add_boot_module(bootmodule_kind kind, const char *cmdline);struct bootmodule *boot_module_find_by_kind (bootmodule_kind kind);const char *__init boot_module_kind_as_string (bootmodule_kind kind); - +u32 device_tree_get_u32 (const void *fdt,int node, +const char *prop_name,u32 dflt); +bool_t device_tree_type_matches (const void *fdt,int node,const char *match);#endif /* * Local variables:
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 12/25] ARM: NUMA: Parse CPU NUMA information
Hi Vijay,
The title likely needs to have the work device-tree/DT in it.
Quoted 5 lines · On 28/03/17 16:53, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
Parse CPU node and fetch numa-node-id information. For each node-id found, update
nodemask_tmask. Refer to /Documentation/devicetree/bindings/numa.txt.
In which repository?
Quoted 37 lines
Signed-off-by Vijaya Kumar K <[email protected]>--- xen/arch/arm/Makefile | 1 + xen/arch/arm/bootfdt.c | 16 ++++++++-- xen/arch/arm/numa/Makefile | 2 ++ xen/arch/arm/numa/dt_numa.c | 78 +++++++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/numa/numa.c | 50 +++++++++++++++++++++++++++++ xen/arch/arm/setup.c | 4 +++ xen/include/asm-arm/numa.h | 10 +++++- xen/include/asm-arm/setup.h | 4 ++- 8 files changed, 161 insertions(+), 4 deletions(-)xen/arch/arm/Makefile +1
-0@@ -3,6 +3,7 @@ subdir-$(CONFIG_ARM_64) += arm64 subdir-y += platforms subdir-$(CONFIG_ARM_64) += efi subdir-$(CONFIG_ACPI) += acpi +subdir-$(CONFIG_NUMA) += numa obj-$(CONFIG_HAS_ALTERNATIVE) += alternative.o obj-y += bootfdt.init.oxen/arch/arm/bootfdt.c +2
-2@@ -62,8 +62,20 @@ static void __init device_tree_get_reg(const __be32 **cell, u32 address_cells, *size =dt_next_cell (size_cells, cell); } -static u32 __init device_tree_get_u32 (const void *fdt,int node, -const char *prop_name,u32 dflt) +bool_t __init device_tree_type_matches (const void *fdt,int node, +const char *match)
xen/arch/arm/bootfdt.c static void __init device_tree_get_reg(const __be32 **cell, u32 address_cells, · line 76
Quoted 10 lines
xen/arch/arm/bootfdt.c +10
-0+{ +const void *prop; + + prop =fdt_getprop (fdt, node,"device_type" ,NULL ); +if ( prop ==NULL ) +return 0 ; + +return strcmp (prop, match) ==0 ?1 :0 ; +} +
This change is not explained in the patch and does not belong to it anyway.
xen/arch/arm/bootfdt.c static void __init device_tree_get_reg(const __be32 **cell, u32 address_cells, · line 78
Quoted 2 lines
xen/arch/arm/bootfdt.c +2
-0+u32 __init device_tree_get_u32 (const void *fdt,int node, +const char *prop_name,u32 dflt)
Ditto. I would recommend to read [1] for tips to break down a patch.
Quoted 29 lines
xen/arch/arm/bootfdt.c +0
-0{const struct fdt_property *prop;xen/arch/arm/numa/Makefile new file +2
-0@@ -0,0 +1,2 @@ +obj-y += dt_numa.o +obj-y += numa.oxen/arch/arm/numa/dt_numa.c new file +12
-0@@ -0,0 +1,78 @@ +/* +* OF NUMA Parsing support. +* +* Copyright (C) 2015 - 2016 Cavium Inc. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
xen/arch/arm/numa/dt_numa.c line 22
Quoted 10 lines
xen/arch/arm/numa/dt_numa.c new file +10
-0+* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <xen/libfdt/libfdt.h> +#include <xen/mm.h> +#include <xen/nodemask.h> +#include <asm/mm.h>
This is already included by xen/mm.h
xen/arch/arm/numa/dt_numa.c line 25
Quoted 3 lines
xen/arch/arm/numa/dt_numa.c new file +3
-0+#include <xen/numa.h> +#include <xen/device_tree.h> +#include <asm/setup.h>
Please order the include.
xen/arch/arm/numa/dt_numa.c line 27
Quoted 2 lines
xen/arch/arm/numa/dt_numa.c new file +2
-0+ +extern nodemask_t processor_nodes_parsed;
See my comment on patch #11. I may miss of them and hoping you will fix all the occurrence in the next version.
Quoted 20 lines
xen/arch/arm/numa/dt_numa.c new file +20
-0+ +/* +* Even though we connect cpus to numa domains later in SMP +* init, we need to know the node ids now for all cpus. +*/ +static int __init dt_numa_process_cpu_node (const void *fdt,int node, +const char *name, +uint32_t address_cells, +uint32_t size_cells) +{ +uint32_t nid; + + nid =device_tree_get_u32 (fdt, node,"numa-node-id" ,MAX_NUMNODES ); + +if ( nid >=MAX_NUMNODES ) +printk (XENLOG_WARNING "NUMA: Node id %u exceeds maximum value\n" , nid); +else +node_set (nid, processor_nodes_parsed); + +return 0 ;
xen/arch/arm/numa/dt_numa.c line 57
Quoted 10 lines
xen/arch/arm/numa/dt_numa.c new file +10
-0+} + +static int __init dt_numa_scan_cpu_node (const void *fdt,int node, +const char *name,int depth, +uint32_t address_cells, +uint32_t size_cells,void *data) +{ +if (device_tree_type_matches (fdt, node,"cpu" ) ) +return dt_numa_process_cpu_node (fdt, node, name, address_cells, + size_cells);
As said on v1, this code is wrong. CPUs nodes can only be in /cpus and you cannot rely on the name to be "cpu" (see binding in Documentation/devicetree/bindings/arm/cpu.txt). The only way to check if it is a CPU is to look for the property device_type.
Cheers,
[1] https://wiki.xenproject.org/wiki/Submitting_Xen_Project_Patches
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 12/25] ARM: NUMA: Parse CPU NUMA information
Quoted 60 lines · Julien Grall
Hi Vijay,
The title likely needs to have the work device-tree/DT in it.
Quoted 6 lines · On 28/03/17 16:53, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
Parse CPU node and fetch numa-node-id information. For each node-id found, update
nodemask_tmask. Refer to /Documentation/devicetree/bindings/numa.txt.In which repository?
Quoted 44 lines
Signed-off-by Vijaya Kumar K <[email protected]>--- xen/arch/arm/Makefile | 1 + xen/arch/arm/bootfdt.c | 16 ++++++++-- xen/arch/arm/numa/Makefile | 2 ++ xen/arch/arm/numa/dt_numa.c | 78 +++++++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/numa/numa.c | 50 +++++++++++++++++++++++++++++ xen/arch/arm/setup.c | 4 +++ xen/include/asm-arm/numa.h | 10 +++++- xen/include/asm-arm/setup.h | 4 ++- 8 files changed, 161 insertions(+), 4 deletions(-)xen/arch/arm/Makefile +1
-0@@ -3,6 +3,7 @@ subdir-$(CONFIG_ARM_64) += arm64 subdir-y += platforms subdir-$(CONFIG_ARM_64) += efi subdir-$(CONFIG_ACPI) += acpi +subdir-$(CONFIG_NUMA) += numa obj-$(CONFIG_HAS_ALTERNATIVE) += alternative.o obj-y += bootfdt.init.oxen/arch/arm/bootfdt.c +7
-2@@ -62,8 +62,20 @@ static void __init device_tree_get_reg(const __be32 **cell, u32 address_cells, *size =dt_next_cell (size_cells, cell); } -static u32 __init device_tree_get_u32 (const void *fdt,int node, -const char *prop_name,u32 dflt) +bool_t __init device_tree_type_matches (const void *fdt,int node, +const char *match) +{ +const void *prop; + + prop =fdt_getprop (fdt, node,"device_type" ,NULL ); +if ( prop ==NULL )
Quoted 8 lines
xen/arch/arm/bootfdt.c static void __init device_tree_get_reg(const __be32 **cell, u32 address_cells, · line 76
Quoted 5 lines
xen/arch/arm/bootfdt.c +5
-0+return 0 ; + +return strcmp (prop, match) ==0 ?1 :0 ; +} +This change is not explained in the patch and does not belong to it anyway.
OK.
Quoted 95 lines
xen/arch/arm/bootfdt.c static void __init device_tree_get_reg(const __be32 **cell, u32 address_cells, · line 78
Quoted 3 lines
xen/arch/arm/bootfdt.c +2
-0+u32 __init device_tree_get_u32 (const void *fdt,int node, +const char *prop_name,u32 dflt)Ditto. I would recommend to read [1] for tips to break down a patch.
Quoted 29 lines
xen/arch/arm/bootfdt.c +0
-0{const struct fdt_property *prop;xen/arch/arm/numa/Makefile new file +2
-0@@ -0,0 +1,2 @@ +obj-y += dt_numa.o +obj-y += numa.oxen/arch/arm/numa/dt_numa.c new file +12
-0@@ -0,0 +1,78 @@ +/* +* OF NUMA Parsing support. +* +* Copyright (C) 2015 - 2016 Cavium Inc. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the xen/arch/arm/numa/dt_numa.c line 22
Quoted 10 lines
xen/arch/arm/numa/dt_numa.c new file +10
-0+* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <xen/libfdt/libfdt.h> +#include <xen/mm.h> +#include <xen/nodemask.h> +#include <asm/mm.h> This is already included by
xen/mm.hxen/arch/arm/numa/dt_numa.c line 25
Quoted 3 lines
xen/arch/arm/numa/dt_numa.c new file +3
-0+#include <xen/numa.h> +#include <xen/device_tree.h> +#include <asm/setup.h> Please order the include.
xen/arch/arm/numa/dt_numa.c line 27
Quoted 2 lines
xen/arch/arm/numa/dt_numa.c new file +2
-0+ +extern nodemask_t processor_nodes_parsed;See my comment on patch #11. I may miss of them and hoping you will fix all the occurrence in the next version.
Quoted 29 lines
xen/arch/arm/numa/dt_numa.c new file +16
-0+ +/* +* Even though we connect cpus to numa domains later in SMP +* init, we need to know the node ids now for all cpus. +*/ +static int __init dt_numa_process_cpu_node (const void *fdt,int node, +const char *name, +uint32_t address_cells, +uint32_t size_cells) +{ +uint32_t nid; + + nid =device_tree_get_u32 (fdt, node,"numa-node-id" ,MAX_NUMNODES ); + +if ( nid >=MAX_NUMNODES ) + printk(XENLOG_WARNING "NUMA: Node id %u exceeds maximum value\n",nid);
xen/arch/arm/numa/dt_numa.c new file +12
-0+else +node_set (nid, processor_nodes_parsed); + +return 0 ; +} + +static int __init dt_numa_scan_cpu_node (const void *fdt,int node, +const char *name,int depth, +uint32_t address_cells, +uint32_t size_cells,void *data) +{ +if (device_tree_type_matches (fdt, node,"cpu" ) )
Quoted 8 lines
xen/arch/arm/numa/dt_numa.c line 57
Quoted 2 lines
xen/arch/arm/numa/dt_numa.c new file +2
-0+return dt_numa_process_cpu_node (fdt, node, name, address_cells, + size_cells);As said on v1, this code is wrong. CPUs nodes can only be in /cpus and you cannot rely on the name to be "cpu" (see binding in
Documentation/devicetree/bindings/arm/cpu.txt). The only way to check if it is a CPU is to look for the propertydevice_type.
The function device_tree_type_matches() isn't looking for device_type?. Below is dt info on device_type. Anything missing?
cpu@10101 {
compatible = "cavium,thunder", "arm,armv8";
device_type = "cpu";
....
};Quoted 7 lines
Cheers,
[1] https://wiki.xenproject.org/wiki/Submitting_Xen_Project_Patches
--
Julien Grall
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 12/25] ARM: NUMA: Parse CPU NUMA information
Hi,
Quoted 16 lines · Vijay Kilari
Quoted 6 lines · Julien Grall
Quoted 6 lines
xen/arch/arm/numa/dt_numa.c new file +6
-0+static int __init dt_numa_scan_cpu_node (const void *fdt,int node, +const char *name,int depth, +uint32_t address_cells, +uint32_t size_cells,void *data) +{ +if (device_tree_type_matches (fdt, node,"cpu" ) )Quoted 8 lines
xen/arch/arm/numa/dt_numa.c line 57
Quoted 2 lines
xen/arch/arm/numa/dt_numa.c new file +2
-0+return dt_numa_process_cpu_node (fdt, node, name, address_cells, + size_cells);As said on v1, this code is wrong. CPUs nodes can only be in /cpus and you cannot rely on the name to be "cpu" (see binding in
Documentation/devicetree/bindings/arm/cpu.txt). The only way to check if it is a CPU is to look for the propertydevice_type.
Quoted 8 lines
The function
device_tree_type_matches()isn't looking fordevice_type?. Below is dt info ondevice_type. Anything missing?cpu@10101 { compatible = "cavium,thunder", "arm,armv8"; device_type = "cpu"; .... };
You only cover one part of my comment and still miss "CPUS nodes can only be in /cpus".
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
RFC PATCH v2 13/25 ARM: NUMA: Parse memory NUMA information
In reply to [email protected]From: Vijaya Kumar K <[email protected]>
Parse memory node and fetch numa-node-id information. For each memory range, store in node_memblk_range[] along with node id.
When booting in UEFI mode, UEFI passes memory information to Dom0 using EFI memory descriptor table and deletes the memory nodes from the host DT. However to fetch the memory numa node id, memory DT node should not be deleted by EFI stub. With this patch, do not delete memory node from FDT.
NUMA info of memory is extracted from process_memory_node() instead of parsing the DT again during numa_init().
--- xen/arch/arm/bootfdt.c | 24 ++++++++++++++++++++---- xen/arch/arm/efi/efi-boot.h | 25 ------------------------- xen/arch/arm/numa/dt_numa.c | 33 +++++++++++++++++++++++++++++++++ xen/arch/arm/numa/numa.c | 9 +++++++++ xen/include/asm-arm/numa.h | 2 ++ 5 files changed, 64 insertions(+), 29 deletions(-)
xen/arch/arm/bootfdt.c +20 -4
@@ -13,6 +13,7 @@#include <xen/init.h> #include <xen/device_tree.h> #include <xen/libfdt/libfdt.h> +#include <xen/efi.h> #include <xsm/xsm.h> #include <asm/setup.h>
@@ -146,6 +147,9 @@ static void __init process_memory_node(const void *fdt, int node,const __be32 *cell;paddr_t start, size;u32 reg_cells = address_cells + size_cells; +#ifdef CONFIG_NUMA +uint32_t nid; +#endif if ( address_cells <1 || size_cells <1 ) {
@@ -154,24 +158,36 @@ static void __init process_memory_node(const void *fdt, int node,return ; } +#ifdef CONFIG_NUMA + nid =device_tree_get_u32 (fdt, node,"numa-node-id" ,NR_NODE_MEMBLKS ); +#endif prop =fdt_get_property (fdt, node,"reg" ,NULL );if ( !prop ) {printk ("fdt: node `%s': missing `reg' property\n" , name); +#ifdef CONFIG_NUMA +numa_failed (); +#endif return ; } cell = (const __be32 *)prop->data; banks =fdt32_to_cpu (prop->len) / (reg_cells *sizeof (u32)); -for ( i =0 ; i < banks && bootinfo.mem.nr_banks <NR_MEM_BANKS ; i++ ) +for ( i =0 ; i < banks; i++ ) {device_tree_get_reg (&cell, address_cells, size_cells, &start, &size);if ( !size )continue ; - bootinfo.mem.bank[bootinfo.mem.nr_banks].start = start; - bootinfo.mem.bank[bootinfo.mem.nr_banks].size = size; - bootinfo.mem.nr_banks++; +if ( !efi_enabled (EFI_BOOT ) && bootinfo.mem.nr_banks <NR_MEM_BANKS ) + { + bootinfo.mem.bank[bootinfo.mem.nr_banks].start = start; + bootinfo.mem.bank[bootinfo.mem.nr_banks].size = size; + bootinfo.mem.nr_banks++; + } +#ifdef CONFIG_NUMA +dt_numa_process_memory_node (nid, start, size); +#endif } }
xen/arch/arm/efi/efi-boot.h +0 -25
@@ -194,33 +194,8 @@ EFI_STATUS __init fdt_add_uefi_nodes(EFI_SYSTEM_TABLE *sys_table,int status;u32 fdt_val32;u64 fdt_val64; -int prev;int num_rsv; -/* -* Delete any memory nodes present. The EFI memory map is the only -* memory description provided to Xen. -*/ - prev =0 ; -for (;;) - { -const char *type; -int len; - - node =fdt_next_node (fdt, prev,NULL ); -if ( node <0 ) -break ; - - type =fdt_getprop (fdt, node,"device_type" , &len); -if ( type &&strncmp (type,"memory" , len) ==0 ) - { -fdt_del_node (fdt, node); -continue ; - } - - prev = node; - } -/* * Delete all memory reserve map entries. When booting via UEFI, * kernel will use the UEFI memory map to find reserved regions.
xen/arch/arm/numa/dt_numa.c +33 -0
@@ -25,6 +25,7 @@#include <asm/setup.h> extern nodemask_t processor_nodes_parsed; +extern nodemask_t memory_nodes_parsed;/* * Even though we connect cpus to numa domains later in SMP
@@ -59,6 +60,38 @@ static int __init dt_numa_scan_cpu_node(const void *fdt, int node,return 0 ; } +void __init dt_numa_process_memory_node (uint32_t nid,paddr_t start, +paddr_t size) +{ +struct node *nd; +int i; + + i =conflicting_memblks (start, start + size); +if ( i <0 ) + { +if (numa_add_memblk (nid, start, size) ) + { +printk (XENLOG_WARNING "DT: NUMA: node-id %u overflow \n" , nid); +numa_failed (); +return ; + } + } +else + { + nd =get_node_memblk_range (i); +printk (XENLOG_ERR +"NUMA DT: node %u (%" PRIx64"-%" PRIx64") overlaps with %d (%" PRIx64"-%" PRIx64")\n" , + nid, start, start + size, i, nd->start, nd->end); + +numa_failed (); +return ; + } + +node_set (nid, memory_nodes_parsed); + +return ; +} +int __init dt_numa_init (void ) {int ret;
xen/arch/arm/numa/numa.c +9 -0
@@ -23,6 +23,12 @@#include <asm/acpi.h> extern nodemask_t processor_nodes_parsed; +static bool_t dt_numa =1 ; + +void numa_failed (void ) +{ + dt_numa =0 ; +}void __init numa_init (void ) {
@@ -32,6 +38,9 @@ void __init numa_init(void)if (is_numa_off () ) goto no_numa; +if ( !dt_numa ) + goto no_numa; + ret =dt_numa_init ();if ( ret )printk (XENLOG_WARNING "DT NUMA init failed\n" );
xen/include/asm-arm/numa.h +2 -0
@@ -6,6 +6,8 @@ typedef uint8_t nodeid_t;/* Limit number of NUMA nodes supported to 4 */ #define NODES_SHIFT 2 +extern void dt_numa_process_memory_node (uint32_t nid,paddr_t start, +paddr_t size);#ifdef CONFIG_NUMA extern void numa_init (void );extern int dt_numa_init (void );
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
RFC PATCH v2 14/25 ARM: NUMA: Parse NUMA distance information
In reply to [email protected]From: Vijaya Kumar K <[email protected]>
Parse distance-matrix and fetch node distance information. Store distance information in node_distance[].
Register dt_node_distance() function pointer with the ARM numa code. This approach can be later used for ACPI.
--- xen/arch/arm/bootfdt.c | 4 +- xen/arch/arm/numa/dt_numa.c | 133 ++++++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/numa/numa.c | 21 +++++++ xen/include/asm-arm/numa.h | 3 + xen/include/asm-arm/setup.h | 2 + 5 files changed, 161 insertions(+), 2 deletions(-)
xen/arch/arm/bootfdt.c +2 -2
@@ -17,8 +17,8 @@#include <xsm/xsm.h> #include <asm/setup.h> -static bool_t __init device_tree_node_matches (const void *fdt,int node, -const char *match) +bool_t __init device_tree_node_matches (const void *fdt,int node, +const char *match) {const char *name;size_t match_len;
xen/arch/arm/numa/dt_numa.c +133 -0
157 lines not on this page · raw message
xen/arch/arm/numa/numa.c +21 -0
@@ -21,13 +21,33 @@#include <asm/mm.h> #include <xen/numa.h> #include <asm/acpi.h> +#include <xen/errno.h> + +static uint8_t (*node_distance_fn)(nodeid_t a,nodeid_t b);extern nodemask_t processor_nodes_parsed;static bool_t dt_numa =1 ; +uint8_t __node_distance (nodeid_t a,nodeid_t b) +{ +if ( node_distance_fn !=NULL ); +return node_distance_fn (a, b); + +return a == b ?LOCAL_DISTANCE :REMOTE_DISTANCE ; +} + +EXPORT_SYMBOL (__node_distance); + +void register_node_distance (uint8_t (fn )(nodeid_t a,nodeid_t b)) +{ + node_distance_fn = fn; +} +void numa_failed (void ) { dt_numa =0 ; +init_dt_numa_distance (); + node_distance_fn =NULL ; }void __init numa_init (void )
@@ -35,6 +55,7 @@ void __init numa_init(void)int ret =0 ;nodes_clear (processor_nodes_parsed); +init_dt_numa_distance ();if (is_numa_off () ) goto no_numa;
xen/include/asm-arm/numa.h +3 -0
@@ -8,6 +8,9 @@ typedef uint8_t nodeid_t;extern void dt_numa_process_memory_node (uint32_t nid,paddr_t start,paddr_t size); +extern void register_node_distance (uint8_t (fn )(nodeid_t a,nodeid_t b)); +extern void init_dt_numa_distance (void ); +extern uint8_t __node_distance (nodeid_t a,nodeid_t b);#ifdef CONFIG_NUMA extern void numa_init (void );extern int dt_numa_init (void );
xen/include/asm-arm/setup.h +2 -0
@@ -82,6 +82,8 @@ const char * __init boot_module_kind_as_string(bootmodule_kind kind);u32 device_tree_get_u32 (const void *fdt,int node,const char *prop_name,u32 dflt);bool_t device_tree_type_matches (const void *fdt,int node,const char *match); +bool_t __init device_tree_node_matches (const void *fdt,int node, +const char *match);#endif /* * Local variables:
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
RFC PATCH v2 15/25 ARM: NUMA: Add CPU NUMA support
In reply to [email protected]From: Vijaya Kumar K <[email protected]>
For each cpu, update cpu_to_node[] with node id from the numa-node-id DT property. Also, initialize cpu_to_node[] with node 0.
Add macros to access cpu_to_node[] information.
--- xen/arch/arm/numa/numa.c | 21 +++++++++++++++++++++ xen/arch/arm/smpboot.c | 25 ++++++++++++++++++++++++- xen/include/asm-arm/numa.h | 24 ++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-)
xen/arch/arm/numa/numa.c +21 -0
@@ -28,6 +28,25 @@ static uint8_t (*node_distance_fn)(nodeid_t a, nodeid_t b);extern nodemask_t processor_nodes_parsed;static bool_t dt_numa =1 ; +/* +* Setup early cpu_to_node. +*/ +void __init init_cpu_to_node (void ) +{ +int i; + +for ( i =0 ; i <NR_CPUS ; i++ ) +numa_set_node (i,0 ); +} + +void __init numa_set_cpu_node (int cpu,unsigned int nid) +{ +if ( !node_isset (nid, processor_nodes_parsed) || nid >=MAX_NUMNODES ) + nid =0 ; + +numa_set_node (cpu, nid); +} +uint8_t __node_distance (nodeid_t a,nodeid_t b) {if ( node_distance_fn !=NULL );
@@ -48,6 +67,7 @@ void numa_failed(void) dt_numa =0 ;init_dt_numa_distance (); node_distance_fn =NULL ; +init_cpu_to_node (); }void __init numa_init (void )
@@ -55,6 +75,7 @@ void __init numa_init(void)int ret =0 ;nodes_clear (processor_nodes_parsed); +init_cpu_to_node ();init_dt_numa_distance ();if (is_numa_off () ) goto no_numa;
xen/arch/arm/smpboot.c +24 -1
@@ -29,6 +29,7 @@#include <xen/timer.h> #include <xen/irq.h> #include <xen/console.h> +#include <xen/numa.h> #include <asm/cpuerrata.h> #include <asm/gic.h> #include <asm/psci.h>
@@ -106,6 +107,7 @@ static void __init dt_smp_init_cpus(void) [0 ... NR_CPUS - 1] = MPIDR_INVALID };bool_t bootcpu_valid =0 ; +nodeid_t *cpu_to_nodemap;int rc; mpidr = boot_cpu_data.mpidr.bits &MPIDR_HWID_MASK ;
@@ -117,11 +119,18 @@ static void __init dt_smp_init_cpus(void)return ; } + cpu_to_nodemap =xzalloc_array (nodeid_t,NR_CPUS ); +if ( !cpu_to_nodemap ) + { +printk (XENLOG_WARNING "Failed to allocate memory for cpu_to_nodemap\n" ); +return ; + } +dt_for_each_child_node ( cpus, cpu ) {const __be32 *prop;u64 addr; -u32 reg_len; +u32 reg_len, nid;register_t hwid;if ( !dt_device_type_is_equal (cpu,"cpu" ) )
@@ -146,6 +155,15 @@ static void __init dt_smp_init_cpus(void)continue ; } +if ( !dt_property_read_u32 (cpu,"numa-node-id" , &nid) ) + { +printk (XENLOG_WARNING "cpu node `%s`: numa-node-id not found\n" , +dt_node_full_name (cpu)); + nid =0 ; + } + + cpu_to_nodemap[cpuidx] = nid; + addr =dt_read_number (prop,dt_n_addr_cells (cpu)); hwid = addr;
@@ -224,6 +242,7 @@ static void __init dt_smp_init_cpus(void) {printk (XENLOG_WARNING "DT missing boot CPU MPIDR[23:0]\n" "Using only 1 CPU\n" ); +xfree (cpu_to_nodemap);return ; }
@@ -233,7 +252,10 @@ static void __init dt_smp_init_cpus(void)continue ;cpumask_set_cpu (i, &cpu_possible_map);cpu_logical_map (i) = tmp_map[i]; +numa_set_cpu_node (i, cpu_to_nodemap[i]); } + +xfree (cpu_to_nodemap); }void __init smp_init_cpus (void )
@@ -313,6 +335,7 @@ void start_secondary(unsigned long boot_phys_offset,*/ smp_wmb (); +numa_add_cpu (cpuid);/* Now report this CPU is up */ cpumask_set_cpu (cpuid, &cpu_online_map);
xen/include/asm-arm/numa.h +24 -0
@@ -14,12 +14,36 @@ extern uint8_t __node_distance(nodeid_t a, nodeid_t b);#ifdef CONFIG_NUMA extern void numa_init (void );extern int dt_numa_init (void ); +extern void numa_set_cpu_node (int cpu,unsigned int nid); +extern void numa_add_cpu (int cpu); + +extern nodeid_t cpu_to_node[NR_CPUS ]; +extern cpumask_t node_to_cpumask[]; +/* Simple perfect hash to map pdx to node numbers */ +extern unsigned int memnode_shift; +extern uint8_t *memnodemap; + +#define cpu_to_node (cpu) (cpu_to_node[cpu]) +#define parent_node (node) (node) +#define node_to_first_cpu (node) (__ffs(node_to_cpumask[node])) +#define node_to_cpumask (node) (node_to_cpumask[node]) +#else static inline void numa_init (void ) {return ; } +static inline void numa_set_cpu_node (int cpu,unsigned int nid) +{ +return ; +} + +static inline void numa_add_cpu (int cpu) +{ +return ; +} +/* Fake one node for now. See also node_online_map. */ #define cpu_to_node (cpu) 0#define node_to_cpumask (node) (cpu_online_map)
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
RFC PATCH v2 16/25 ARM: NUMA: Add memory NUMA support
In reply to [email protected]From: Vijaya Kumar K <[email protected]>
Implement arch_sanitize_nodes_memory() which looks at all banks in bootinfo.mem, update nodes[] with corresponding nodeid. Call numa_scan_nodes() generic function with ram start and end address, which takes care of further computing memnodeshift and populating memnodemap[] using generic implementation.
--- xen/arch/arm/numa/numa.c | 79 +++++++++++++++++++++++++++++++++++++++++++++- xen/common/numa.c | 14 ++++++++ xen/include/asm-arm/numa.h | 19 +++++++++++ xen/include/xen/numa.h | 1 + 4 files changed, 112 insertions(+), 1 deletion(-)
xen/arch/arm/numa/numa.c +78 -1
@@ -70,9 +70,74 @@ void numa_failed(void)init_cpu_to_node (); } +int __init arch_sanitize_nodes_memory (void ) +{ +nodemask_t mem_nodes_parsed; +int bank, nodeid; +struct node *nd; +paddr_t start, size, end; + +nodes_clear (mem_nodes_parsed); +for ( bank =0 ; bank < bootinfo.mem.nr_banks; bank++ ) + { + start = bootinfo.mem.bank[bank].start; + size = bootinfo.mem.bank[bank].size; + end = start + size; + + nodeid =get_mem_nodeid (start, end); +if ( nodeid >=NUMA_NO_NODE ) + { +printk (XENLOG_WARNING +"NUMA: node for mem bank start 0x%lx - 0x%lx not found\n" , + start, end); + +return 0 ; + } + + nd =get_numa_node (nodeid); +if ( !node_test_and_set (nodeid, mem_nodes_parsed) ) + { + nd->start = start; + nd->end = end; + } +else + { +if ( start < nd->start ) + nd->start = start; +if ( nd->end < end ) + nd->end = end; + } + } + +return 1 ; +} + +static bool_t __init numa_initmem_init (paddr_t ram_start,paddr_t ram_end) +{ +int i; +struct node *nd; +/* +* In arch_sanitize_nodes_memory() we update nodes[] with properly. +* Hence we reset the nodes[] before calling numa_scan_nodes(). +*/ +for ( i =0 ; i <MAX_NUMNODES ; i++ ) + { + nd =get_numa_node (i); + nd->start =0 ; + nd->end =0 ; + } + +if ( !numa_scan_nodes (ram_start, ram_end) ) +return 0 ; + +return 1 ; +} +void __init numa_init (void ) { -int ret =0 ; +int ret =0 , bank; +paddr_t ram_start = ~0 ; +paddr_t ram_end =0 ;nodes_clear (processor_nodes_parsed);init_cpu_to_node ();
@@ -87,6 +152,18 @@ void __init numa_init(void)if ( ret )printk (XENLOG_WARNING "DT NUMA init failed\n" ); +for ( bank =0 ; bank < bootinfo.mem.nr_banks; bank++ ) + { +paddr_t bank_start = bootinfo.mem.bank[bank].start; +paddr_t bank_end = bank_start + bootinfo.mem.bank[bank].size; + + ram_start =min (ram_start, bank_start); + ram_end =max (ram_end, bank_end); + } + +if ( !ret ) + ret =numa_initmem_init (ram_start, ram_end); + no_numa:return ; }
xen/common/numa.c +14 -0
@@ -84,6 +84,20 @@ nodeid_t get_memblk_nodeid(int id)return memblk_nodeid[id]; } +int __init get_mem_nodeid (paddr_t start,paddr_t end) +{ +unsigned int i; + +for ( i =0 ; i <get_num_node_memblks (); i++ ) + { +if ( start >= node_memblk_range[i].start && + end <= node_memblk_range[i].end ) +return memblk_nodeid[i]; + } + +return -EINVAL ; +} +nodeid_t *get_memblk_nodeid_map (void ) {return &memblk_nodeid[0 ];
xen/include/asm-arm/numa.h +19 -0
@@ -1,6 +1,8 @@#ifndef __ARCH_ARM_NUMA_H#define __ARCH_ARM_NUMA_H +#include <xen/mm.h> +typedef uint8_t nodeid_t ;/* Limit number of NUMA nodes supported to 4 */
@@ -28,6 +30,23 @@ extern uint8_t *memnodemap;#define node_to_first_cpu (node) (__ffs(node_to_cpumask[node]))#define node_to_cpumask (node) (node_to_cpumask[node]) +static inline __attribute__((pure))nodeid_t phys_to_nid (paddr_t addr) +{ +return memnodemap[paddr_to_pdx (addr) >> memnode_shift]; +} + +struct node_data { +unsigned long node_start_pfn; +unsigned long node_spanned_pages; +}; + +extern struct node_data node_data[]; +#define NODE_DATA (nid) (&(node_data[nid])) + +#define node_start_pfn (nid) (NODE_DATA(nid)->node_start_pfn) +#define node_spanned_pages (nid) (NODE_DATA(nid)->node_spanned_pages) +#define node_end_pfn (nid) (NODE_DATA(nid)->node_start_pfn + \ +#else static inline void numa_init (void ) {
xen/include/xen/numa.h +1 -0
@@ -38,6 +38,7 @@ extern nodeid_t *get_memblk_nodeid_map(void);extern struct node *get_node_memblk_range (int memblk);extern struct node *get_memblk (int memblk);extern int numa_add_memblk (nodeid_t nodeid,paddr_t start,uint64_t size); +extern int get_mem_nodeid (paddr_t start,paddr_t end);extern int get_num_node_memblks (void );extern int arch_sanitize_nodes_memory (void );extern void numa_failed (void );
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
RFC PATCH v2 17/25 ARM: NUMA: Add fallback on NUMA failure
In reply to [email protected]From: Vijaya Kumar K <[email protected]>
On NUMA initialization failure, reset all the
NUMA structures to emulate as single node.
--- xen/arch/arm/numa/numa.c | 6 ++++++ 1 file changed, 6 insertions(+)
xen/arch/arm/numa/numa.c +6 -0
@@ -22,6 +22,7 @@#include <xen/numa.h> #include <asm/acpi.h> #include <xen/errno.h> +#include <xen/pfn.h> static uint8_t (*node_distance_fn)(nodeid_t a,nodeid_t b);
@@ -164,7 +165,12 @@ void __init numa_init(void)if ( !ret ) ret =numa_initmem_init (ram_start, ram_end); +if ( !ret ) +return ; + no_numa: +numa_dummy_init (PFN_UP (ram_start),PFN_DOWN (ram_end)); +return ; }
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
RFC PATCH v2 18/25 ARM: NUMA: Do not expose numa info to DOM0
In reply to [email protected]From: Vijaya Kumar K <[email protected]>
Delete numa-node-id and distance map from DOM0 DT so that NUMA information is not exposed to DOM0. This helps particularly to boot Node 1 devices
as if booting on Node0.
However this approach has limitation where memory allocation for the devices should be local.
Also, do not expose numa distance node to DOM0.
--- xen/arch/arm/domain_build.c | 9 +++++++++ 1 file changed, 9 insertions(+)
xen/arch/arm/domain_build.c +9 -0
@@ -421,6 +421,10 @@ static int write_properties(struct domain *d, struct kernel_info *kinfo, } } +/* Don't expose the property numa to the guest */ +if (dt_property_name_is_equal (prop,"numa-node-id" ) ) +continue ; +/* Don't expose the property "xen,passthrough" to the guest */ if (dt_property_name_is_equal (prop,"xen,passthrough" ) )continue ;
@@ -1173,6 +1177,11 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo,DT_MATCH_TYPE ("memory" ),/* The memory mapped timer is not supported by Xen. */ DT_MATCH_COMPATIBLE ("arm,armv7-timer-mem" ), +/* +* NUMA info is not exposed to Dom0. +* So, skip distance-map infomation +*/ + DT_MATCH_COMPATIBLE("numa-distance-map-v1"), { /* sentinel */ }, }; static const struct dt_device_match timer_matches[] __initconst =
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
RFC PATCH v2 19/25 ACPI: Refactor acpi SRAT and SLIT table handling code
In reply to [email protected]From: Vijaya Kumar K <[email protected]>
Move SRAT handling code which is common across architecture is moved to new file xen/drivers/acpi/srat.c from xen/arch/x86/srat.c file. New header file srat.h is introduced.
--- xen/arch/x86/dom0_build.c | 1 + xen/arch/x86/mm.c | 2 - xen/arch/x86/physdev.c | 1 + xen/arch/x86/setup.c | 1 + xen/arch/x86/smpboot.c | 1 + xen/arch/x86/srat.c | 250 +----------------------------- xen/arch/x86/x86_64/mm.c | 1 + xen/drivers/acpi/Makefile | 1 + xen/drivers/acpi/srat.c | 299 ++++++++++++++++++++++++++++++++++++ xen/drivers/passthrough/vtd/iommu.c | 1 + xen/include/acpi/srat.h | 24 +++ xen/include/asm-x86/mm.h | 1 - xen/include/asm-x86/numa.h | 4 - xen/include/xen/mm.h | 2 + xen/include/xen/numa.h | 1 - 15 files changed, 333 insertions(+), 257 deletions(-)
xen/arch/x86/dom0_build.c +1 -0
@@ -11,6 +11,7 @@#include <xen/sched.h> #include <xen/sched-if.h> #include <xen/softirq.h> +#include <acpi/srat.h> #include <asm/dom0_build.h> #include <asm/hpet.h>
xen/arch/x86/mm.c +0 -2
@@ -137,8 +137,6 @@ l1_pgentry_t __section(".bss.page_aligned") __aligned(PAGE_SIZE)#define PTE_UPDATE_WITH_CMPXCHG #endif -paddr_t __read_mostly mem_hotplug; -/* Private domain structs for DOMID_XEN and DOMID_IO. */ struct domain *dom_xen, *dom_io, *dom_cow;
xen/arch/x86/physdev.c +1 -0
@@ -8,6 +8,7 @@#include <xen/guest_access.h> #include <xen/iocap.h> #include <xen/serial.h> +#include <acpi/srat.h> #include <asm/current.h> #include <asm/io_apic.h> #include <asm/msi.h>
xen/arch/x86/setup.c +1 -0
@@ -27,6 +27,7 @@#include <xen/tmem_xen.h> #include <xen/virtual_region.h> #include <xen/watchdog.h> +#include <acpi/srat.h> #include <public/version.h> #include <compat/platform.h> #include <compat/xen.h>
xen/arch/x86/smpboot.c +1 -0
@@ -33,6 +33,7 @@#include <xen/serial.h> #include <xen/numa.h> #include <xen/cpu.h> +#include <acpi/srat.h> #include <asm/current.h> #include <asm/mc146818rtc.h> #include <asm/desc.h>
xen/arch/x86/srat.c +1 -249
285 lines not on this page · raw message
xen/arch/x86/x86_64/mm.c +1 -0
@@ -27,6 +27,7 @@ asm(".file \"" __FILE__ "\"");#include <xen/guest_access.h> #include <xen/hypercall.h> #include <xen/mem_access.h> +#include <acpi/srat.h> #include <asm/current.h> #include <asm/asm_defns.h> #include <asm/page.h>
xen/drivers/acpi/Makefile +1 -0
@@ -4,6 +4,7 @@ subdir-$(CONFIG_X86) += apei obj-bin-y += tables.init.o obj-$(CONFIG_NUMA) += numa.o +obj-$(CONFIG_NUMA) += srat.o obj-y += osl.o obj-$(CONFIG_HAS_CPUFREQ) += pmstat.o
xen/drivers/acpi/srat.c new file +299 -0
299 lines not on this page · raw message
xen/drivers/passthrough/vtd/iommu.c +1 -0
@@ -30,6 +30,7 @@#include <xen/pci.h> #include <xen/pci_regs.h> #include <xen/keyhandler.h> +#include <acpi/srat.h> #include <asm/msi.h> #include <asm/irq.h> #include <asm/hvm/vmx/vmx.h>
xen/include/acpi/srat.h new file +24 -0
@@ -0,0 +1,24 @@ +#ifndef __XEN_SRAT_H__ +#define __XEN_SRAT_H__ + +extern int srat_rev; +struct pxm2node { +unsigned int pxm; +nodeid_t node; +}; + +extern nodeid_t pxm_to_node (unsigned pxm); +extern nodeid_t acpi_setup_node (unsigned pxm); +extern unsigned int node_to_pxm (nodeid_t n); +extern uint8_t acpi_node_distance (nodeid_t a,nodeid_t b); +extern void reset_pxm2node (void ); +#endif /* __XEN_SRAT_H__ */ + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
xen/include/asm-x86/mm.h +0 -1
@@ -405,7 +405,6 @@ static inline int get_page_and_type(struct page_info *page,int check_descriptor (const struct domain *,struct desc_struct *d);extern bool_t opt_allow_superpage; -extern paddr_t mem_hotplug;/****************************************************************************** * With shadow pagetables, the different kinds of address start
xen/include/asm-x86/numa.h +0 -4
@@ -7,8 +7,6 @@typedef uint8_t nodeid_t ; -extern int srat_rev; -extern nodeid_t cpu_to_node[NR_CPUS ];extern cpumask_t node_to_cpumask[];
@@ -17,8 +15,6 @@ extern cpumask_t node_to_cpumask[];#define node_to_first_cpu (node) (__ffs(node_to_cpumask[node]))#define node_to_cpumask (node) (node_to_cpumask[node]) -extern nodeid_t pxm_to_node (unsigned int pxm); -#define ZONE_ALIGN (1UL << (MAX_ORDER+PAGE_SHIFT))extern void numa_add_cpu (int cpu);
xen/include/xen/mm.h +2 -0
@@ -63,6 +63,8 @@ TYPE_SAFE(unsigned long, mfn);#undef mfn_t#endif +extern paddr_t mem_hotplug; +static inline mfn_t mfn_add (mfn_t mfn,unsigned long i) {return _mfn (mfn_x (mfn) + i);
xen/include/xen/numa.h +0 -1
@@ -25,7 +25,6 @@ extern int compute_memnode_shift(struct node *nodes, int numnodes,extern void numa_init_array (void );extern bool_t srat_disabled (void );extern void numa_set_node (int cpu,nodeid_t node); -extern nodeid_t acpi_setup_node (unsigned int pxm);extern void srat_detect_node (int cpu);extern void setup_node_bootmem (nodeid_t nodeid,paddr_t start,paddr_t end);extern void init_cpu_to_node (void );
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
RFC PATCH v2 20/25 ARM: NUMA: Extract MPIDR from MADT table
In reply to [email protected]From: Vijaya Kumar K <[email protected]>
Parse MADT table and extract MPIDR for all
CPU IDs in MADT ACPI_MADT_TYPE_GENERIC_INTERRUPT entries and store in cpuid_to_hwid_map[]
This mapping is used by SRAT table parsing to
extract MPIDR of the CPU ID.
--- xen/arch/arm/numa/Makefile | 1 + xen/arch/arm/numa/acpi_numa.c | 94 +++++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/numa/numa.c | 6 +++ 3 files changed, 101 insertions(+)
xen/arch/arm/numa/Makefile +1 -0
@@ -1,2 +1,3 @@ obj-y += dt_numa.o obj-y += numa.o +obj-$(CONFIG_ACPI_NUMA) += acpi_numa.o
xen/arch/arm/numa/acpi_numa.c new file +94 -0
94 lines not on this page · raw message
xen/arch/arm/numa/numa.c +6 -0
@@ -23,6 +23,7 @@#include <asm/acpi.h> #include <xen/errno.h> #include <xen/pfn.h> +#include <acpi/srat.h> static uint8_t (*node_distance_fn)(nodeid_t a,nodeid_t b);
@@ -69,6 +70,11 @@ void numa_failed(void)init_dt_numa_distance (); node_distance_fn =NULL ;init_cpu_to_node (); + +#ifdef CONFIG_ACPI_NUMA +set_acpi_numa (0 ); +reset_pxm2node (); +#endif }int __init arch_sanitize_nodes_memory (void )
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
RFC PATCH v2 21/25 ACPI: Move arch specific SRAT parsing
In reply to [email protected]From: Vijaya Kumar K <[email protected]>
SRAT's X2APIC_CPU_AFFINITY and CPU_AFFINITY types are not used by ARM. Hence move handling of this SRAT types to arch specific file and handle them under arch_table_parse_srat().
--- xen/arch/arm/numa/acpi_numa.c | 5 +++++ xen/arch/x86/srat.c | 44 +++++++++++++++++++++++++++++++++++++++++++ xen/drivers/acpi/numa.c | 43 ++---------------------------------------- xen/include/xen/acpi.h | 6 ++++++ 4 files changed, 57 insertions(+), 41 deletions(-)
xen/arch/arm/numa/acpi_numa.c +5 -0
@@ -82,6 +82,11 @@ void __init acpi_map_uid_to_mpidr(void) acpi_parse_madt_handler, NR_CPUS); } +void __init arch_table_parse_srat (void ) +{ +return ; +} +void __init acpi_numa_arch_fixup (void ) {}/*
xen/arch/x86/srat.c +44 -0
47 lines not on this page · raw message
xen/drivers/acpi/numa.c +2 -41
58 lines not on this page · raw message
xen/include/xen/acpi.h +6 -0
@@ -95,7 +95,13 @@ void acpi_numa_slit_init (struct acpi_table_slit *slit);void acpi_numa_processor_affinity_init (const struct acpi_srat_cpu_affinity *);void acpi_numa_x2apic_affinity_init (const struct acpi_srat_x2apic_cpu_affinity *);void acpi_numa_memory_affinity_init (const struct acpi_srat_mem_affinity *); +#ifdef CONFIG_ACPI_NUMA void acpi_numa_arch_fixup (void ); +void arch_table_parse_srat (void ); +#else +static inline void acpi_numa_arch_fixup (void ) { } +static inline void arch_table_parse_srat (void ) { } +#endif #ifdef CONFIG_ACPI_HOTPLUG_CPU /* Arch dependent functions for cpu hotplug support */
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
RFC PATCH v2 22/25 ARM: NUMA: Extract proximity from SRAT table
In reply to [email protected]From: Vijaya Kumar K <[email protected]>
Register SRAT entry handler for typeACPI_SRAT_TYPE_GICC_AFFINITY to parse SRAT table
and extract proximity for all CPU IDs.
--- xen/arch/arm/acpi/boot.c | 2 + xen/arch/arm/numa/acpi_numa.c | 126 +++++++++++++++++++++++++++++++++++++++++- xen/drivers/acpi/numa.c | 15 +++++ xen/include/acpi/actbl1.h | 17 +++++- xen/include/asm-arm/numa.h | 9 +++ xen/include/xen/numa.h | 4 ++ 6 files changed, 171 insertions(+), 2 deletions(-)
xen/arch/arm/acpi/boot.c +2 -0
@@ -31,6 +31,7 @@#include <acpi/actables.h> #include <xen/mm.h> #include <xen/device_tree.h> +#include <xen/numa.h> #include <asm/acpi.h> #include <asm/smp.h>
@@ -117,6 +118,7 @@ acpi_map_gic_cpu_interface(struct acpi_madt_generic_interrupt *processor)return ; } +numa_set_node (enabled_cpus,acpi_get_nodeid (mpidr));/* map the logical cpu id to cpu MPIDR */ cpu_logical_map (enabled_cpus) = mpidr;
xen/arch/arm/numa/acpi_numa.c +125 -1
159 lines not on this page · raw message
xen/drivers/acpi/numa.c +15 -0
@@ -104,6 +104,21 @@ void __init acpi_table_print_srat_entry(struct acpi_subtable_header * header) }#endif /* ACPI_DEBUG_OUTPUT */ break ; +case ACPI_SRAT_TYPE_GICC_AFFINITY : +#ifdef ACPI_DEBUG_OUTPUT + { +struct acpi_srat_gicc_affinity *p = + (struct acpi_srat_gicc_affinity *)header; +ACPI_DEBUG_PRINT ((ACPI_DB_INFO , +"SRAT Processor (acpi id[0x%04x]) in" +" proximity domain %d %s\n" , + p->acpi_processor_uid, + p->proximity_domain, + (p->flags &ACPI_SRAT_GICC_ENABLED ) ? + "enabled" : "disabled"); + } +#endif /* ACPI_DEBUG_OUTPUT */ +break ;default : printk(KERN_WARNING PREFIX "Found unsupported SRAT entry (type = %#x)\n",
xen/include/acpi/actbl1.h +16 -1
@@ -949,7 +949,8 @@ enum acpi_srat_type {ACPI_SRAT_TYPE_CPU_AFFINITY =0 ,ACPI_SRAT_TYPE_MEMORY_AFFINITY =1 ,ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY =2 , - ACPI_SRAT_TYPE_RESERVED = 3 /* 3 and greater are reserved */ +ACPI_SRAT_TYPE_GICC_AFFINITY =3 , + ACPI_SRAT_TYPE_RESERVED = 4 /* 4 and greater are reserved */ };/*
@@ -1007,6 +1008,20 @@ struct acpi_srat_x2apic_cpu_affinity {#define ACPI_SRAT_CPU_ENABLED (1)/* 00: Use affinity structure */ +/* 3: GICC Affinity (ACPI 5.1) */ + +struct acpi_srat_gicc_affinity { +struct acpi_subtable_header header; +u32 proximity_domain; +u32 acpi_processor_uid; +u32 flags; +u32 clock_domain; +}; + +/* Flags for struct acpi_srat_gicc_affinity */ + +#define ACPI_SRAT_GICC_ENABLED (1)/* 00: Use affinity structure */ +/* Reset to default packing */ #pragma pack()
xen/include/asm-arm/numa.h +9 -0
@@ -13,6 +13,15 @@ extern void dt_numa_process_memory_node(uint32_t nid,paddr_t start,extern void register_node_distance (uint8_t (fn )(nodeid_t a,nodeid_t b));extern void init_dt_numa_distance (void );extern uint8_t __node_distance (nodeid_t a,nodeid_t b); +#ifdef CONFIG_ACPI_NUMA +nodeid_t acpi_get_nodeid (uint64_t hwid); +#else +static inline nodeid_t acpi_get_nodeid (uint64_t hwid) +{ +return 0 ; +} +#endif /* CONFIG_ACPI_NUMA */ +#ifdef CONFIG_NUMA extern void numa_init (void );extern int dt_numa_init (void );
xen/include/xen/numa.h +4 -0
@@ -24,7 +24,11 @@ extern int compute_memnode_shift(struct node *nodes, int numnodes, nodeid_t *nodeids, unsigned int *shift);extern void numa_init_array (void );extern bool_t srat_disabled (void ); +#ifdef CONFIG_NUMA extern void numa_set_node (int cpu,nodeid_t node); +#else +static inline void numa_set_node (int cpu,nodeid_t node) { } +#endif extern void srat_detect_node (int cpu);extern void setup_node_bootmem (nodeid_t nodeid,paddr_t start,paddr_t end);extern void init_cpu_to_node (void );
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
RFC PATCH v2 23/25 ARM: NUMA: Initialize ACPI NUMA
In reply to [email protected]From: Vijaya Kumar K <[email protected]>
Call ACPI NUMA initialization under CONFIG_ACPI_NUMA.
--- xen/arch/arm/numa/acpi_numa.c | 28 +++++++++++++++++++++++++++- xen/arch/arm/numa/numa.c | 6 ++++++ xen/common/numa.c | 14 ++++++++++++++ xen/include/asm-arm/numa.h | 1 + xen/include/xen/numa.h | 1 + 5 files changed, 49 insertions(+), 1 deletion(-)
xen/arch/arm/numa/acpi_numa.c +27 -1
@@ -29,6 +29,7 @@#include <asm/acpi.h> extern nodemask_t processor_nodes_parsed; +extern nodemask_t memory_nodes_parsed;/* Holds CPUID to MPIDR mapping read from MADT table. */ struct cpuid_to_hwid {
@@ -183,7 +184,7 @@ acpi_numa_gicc_affinity_init(const struct acpi_srat_gicc_affinity *pa) pxm, mpidr, node); } -void __init acpi_map_uid_to_mpidr (void ) +static void __init acpi_map_uid_to_mpidr (void ) {acpi_table_parse_madt (ACPI_MADT_TYPE_GENERIC_INTERRUPT , acpi_parse_madt_handler,NR_CPUS );
@@ -211,6 +212,31 @@ void __init arch_table_parse_srat(void) acpi_parse_gicc_affinity, NR_CPUS); } +bool_t __init arch_acpi_numa_init (void ) +{ +int ret; + +if ( !acpi_disabled ) + { +/* +* If firmware has DT, process_memory_node() call +* would have added memory blocks. So reset it before +* ACPI numa init. +*/ +numa_clear_memblks (); +nodes_clear (memory_nodes_parsed); +acpi_map_uid_to_mpidr (); + ret =acpi_numa_init (); +if ( ret ||srat_disabled () ) +return 1 ; + +/* Register acpi node_distance handler */ +register_node_distance (&acpi_node_distance); + } + +return 0 ; +} +void __init acpi_numa_arch_fixup (void ) {}/*
xen/arch/arm/numa/numa.c +6 -0
@@ -152,12 +152,18 @@ void __init numa_init(void)if (is_numa_off () ) goto no_numa; +#ifdef CONFIG_ACPI_NUMA + ret =arch_acpi_numa_init (); +if ( ret ) +printk (XENLOG_WARNING "ACPI NUMA init failed\n" ); +#else if ( !dt_numa ) goto no_numa; ret =dt_numa_init ();if ( ret )printk (XENLOG_WARNING "DT NUMA init failed\n" ); +#endif for ( bank =0 ; bank < bootinfo.mem.nr_banks; bank++ ) {
xen/common/numa.c +14 -0
@@ -84,6 +84,20 @@ nodeid_t get_memblk_nodeid(int id)return memblk_nodeid[id]; } +void __init numa_clear_memblks (void ) +{ +unsigned int i; + +for ( i =0 ; i <get_num_node_memblks (); i++ ) + { + node_memblk_range[i].start =0 ; + node_memblk_range[i].end =0 ; + memblk_nodeid[i] =NUMA_NO_NODE ; + } + + num_node_memblks =0 ; +} +int __init get_mem_nodeid (paddr_t start,paddr_t end) {unsigned int i;
xen/include/asm-arm/numa.h +1 -0
@@ -24,6 +24,7 @@ static inline nodeid_t acpi_get_nodeid(uint64_t hwid)#ifdef CONFIG_NUMA extern void numa_init (void ); +extern bool_t arch_acpi_numa_init (void );extern int dt_numa_init (void );extern void numa_set_cpu_node (int cpu,unsigned int nid);extern void numa_add_cpu (int cpu);
xen/include/xen/numa.h +1 -0
@@ -59,4 +59,5 @@ void set_acpi_numa(bool val);int get_numa_fake (void );extern int numa_emulation (uint64_t start_pfn,uint64_t end_pfn);extern void numa_dummy_init (uint64_t start_pfn,uint64_t end_pfn); +extern void numa_clear_memblks (void );#endif /* _XEN_NUMA_H */
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
RFC PATCH v2 24/25 NUMA: Move CONFIG_NUMA to common Kconfig
In reply to [email protected]From: Vijaya Kumar K <[email protected]>
CONFIG_NUMA is defined in xen/drivers/acpi/Kconfig. Move to common/Kconfig and enabled by default. Also, NUMA feature uses PDX for physical address to memory node mapping. Hence make HAS_PDX dependent for NUMA.
--- xen/common/Kconfig | 4 ++++ xen/drivers/acpi/Kconfig | 3 --- 2 files changed, 4 insertions(+), 3 deletions(-)
xen/common/Kconfig +4 -0
@@ -41,6 +41,10 @@ config HAS_GDBSX config HAS_IOPORTS bool +config NUMA + def_bool y + depends on HAS_PDX + config HAS_BUILD_ID string option env="XEN_HAS_BUILD_ID"
xen/drivers/acpi/Kconfig +0 -3
@@ -4,6 +4,3 @@ config ACPI config ACPI_LEGACY_TABLES_LOOKUP bool - -config NUMA - bool
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 24/25] NUMA: Move CONFIG_NUMA to common Kconfig
xen/common/Kconfig config HAS_GDBSX · line 46
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 28.03.17 at 17:53, <[email protected]> wrote:
xen/common/Kconfig +3
-0@@ -41,6 +41,10 @@ config HAS_GDBSX config HAS_IOPORTS bool +config NUMA + def_bool y + depends on HAS_PDX
What makes necessary this dependency?
xen/drivers/acpi/Kconfig config ACPI · line 9
Quoted 9 lines
xen/drivers/acpi/Kconfig +0
-3@@ -4,6 +4,3 @@ config ACPI config ACPI_LEGACY_TABLES_LOOKUP bool - -config NUMA - bool
This makes clear that so far this is an option which architectures are expected to select. I think we want it to remain that way, but if we didn't you should remove the existing select(s).
Also, does it really matter much whether this is under drivers/acpi/ or common/? After all ACPI appears to be a prereq on ARM too.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 24/25] NUMA: Move CONFIG_NUMA to common Kconfig
Hi Jan,
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 28.03.17 at 17:53, <[email protected]> wrote:
xen/common/Kconfig +0
-0@@ -41,6 +41,10 @@ config HAS_GDBSX config HAS_IOPORTS bool
Quoted 5 lines
xen/common/Kconfig config HAS_GDBSX · line 46
Quoted 3 lines
xen/common/Kconfig +3
-0+config NUMA + def_bool y + depends on HAS_PDXWhat makes necessary this dependency?
IIRC, this is because the numa code is using PDX helpers.
Quoted 15 lines
xen/drivers/acpi/Kconfig config ACPI · line 9
Quoted 10 lines
xen/drivers/acpi/Kconfig +0
-3@@ -4,6 +4,3 @@ config ACPI config ACPI_LEGACY_TABLES_LOOKUP bool - -config NUMA - boolThis makes clear that so far this is an option which architectures are expected to select. I think we want it to remain that way, but if we didn't you should remove the existing select(s).
Quoted 2 lines
Also, does it really matter much whether this is under
drivers/acpi/or common/? After all ACPI appears to be a prereq on ARM too.
ACPI is not a prereq for NUMA. You can use it with Device Tree too.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 24/25] NUMA: Move CONFIG_NUMA to common Kconfig
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 31.05.17 at 12:18, <[email protected]> wrote:
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 28.03.17 at 17:53, <[email protected]> wrote:
xen/common/Kconfig +0
-0@@ -41,6 +41,10 @@ config HAS_GDBSX config HAS_IOPORTS bool
Quoted 7 lines
Quoted 5 lines
xen/common/Kconfig config HAS_GDBSX · line 46
Quoted 3 lines
xen/common/Kconfig +3
-0+config NUMA + def_bool y + depends on HAS_PDXWhat makes necessary this dependency?
IIRC, this is because the numa code is using PDX helpers.
Well, these helpers should have 1:1 translation equivalents for the non-PDX case; I don't see the need for the dependency.
Quoted 14 lines
Quoted 14 lines
xen/drivers/acpi/Kconfig config ACPI · line 9
Quoted 9 lines
xen/drivers/acpi/Kconfig +0
-3@@ -4,6 +4,3 @@ config ACPI config ACPI_LEGACY_TABLES_LOOKUP bool - -config NUMA - boolThis makes clear that so far this is an option which architectures are expected to select. I think we want it to remain that way, but if we didn't you should remove the existing select(s).
Quoted 4 lines
Quoted 2 lines
Also, does it really matter much whether this is under
drivers/acpi/or common/? After all ACPI appears to be a prereq on ARM too.ACPI is not a prereq for NUMA. You can use it with Device Tree too.
Oh, okay. That should be said in the commit message then.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 24/25] NUMA: Move CONFIG_NUMA to common Kconfig
Quoted 15 lines · Jan Beulich
Quoted 15 lines
Quoted 1 line
Quoted 1 line · On 31.05.17 at 12:18, <[email protected]> wrote:
Quoted 12 lines · Jan Beulich
xen/common/Kconfig config HAS_GDBSX · line 46
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 28.03.17 at 17:53, <[email protected]> wrote:
xen/common/Kconfig +3
-0@@ -41,6 +41,10 @@ config HAS_GDBSX config HAS_IOPORTS bool +config NUMA + def_bool y + depends on HAS_PDXWhat makes necessary this dependency?
Quoted 4 lines
Quoted 1 line
IIRC, this is because the numa code is using PDX helpers.
Well, these helpers should have 1:1 translation equivalents for the non-PDX case; I don't see the need for the dependency.
PDX is necessary. Without that xen fails to compile for ARM. IMO, there is no equivalent non-PDX support available.
As it is mandatory config, I propose to remove this dependency with NUMA config. ok?
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
xen/drivers/acpi/Kconfig config ACPI · line 9
Quoted 10 lines
xen/drivers/acpi/Kconfig +0
-3@@ -4,6 +4,3 @@ config ACPI config ACPI_LEGACY_TABLES_LOOKUP bool - -config NUMA - boolThis makes clear that so far this is an option which architectures are expected to select. I think we want it to remain that way, but if we didn't you should remove the existing select(s).
Quoted 9 lines
Quoted 4 lines
Quoted 2 lines
Also, does it really matter much whether this is under
drivers/acpi/or common/? After all ACPI appears to be a prereq on ARM too.ACPI is not a prereq for NUMA. You can use it with Device Tree too.
Oh, okay. That should be said in the commit message then.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 24/25] NUMA: Move CONFIG_NUMA to common Kconfig
Hi Vijay,
Quoted 16 lines · Vijay Kilari
Quoted 15 lines · Jan Beulich
Quoted 15 lines
Quoted 1 line
Quoted 1 line · On 31.05.17 at 12:18, <[email protected]> wrote:
Quoted 12 lines · Jan Beulich
xen/common/Kconfig config HAS_GDBSX · line 46
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 28.03.17 at 17:53, <[email protected]> wrote:
xen/common/Kconfig +3
-0@@ -41,6 +41,10 @@ config HAS_GDBSX config HAS_IOPORTS bool +config NUMA + def_bool y + depends on HAS_PDXWhat makes necessary this dependency?
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
IIRC, this is because the numa code is using PDX helpers.
Well, these helpers should have 1:1 translation equivalents for the non-PDX case; I don't see the need for the dependency.
PDX is necessary. Without that xen fails to compile for ARM. IMO, there is no equivalent non-PDX support available.
I am well aware that ARM requires PDX... This is because, all the memory is not contiguous on ARM and we don't want to waste space in the frametable.
But this is not the point of the discussion. A new architecture may decide that PDX is not necessary but still want to use NUMA. Hence why Jan suggested 1:1 helpers for the non-PDX case.
Quoted 3 lines
As it is mandatory config, I propose to remove this dependency with NUMA config. ok?
This is what Jan suggested and I am happy with that.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
RFC PATCH v2 25/25 NUMA: Enable ACPI_NUMA config
In reply to [email protected]From: Vijaya Kumar K <[email protected]>
Add CONFIG_ACPI_NUMA to xen/drivers/acpi/Kconfig and drop CONFIG_ACPI_NUMA set in asm-x86/config.h.
--- xen/drivers/acpi/Kconfig | 4 ++++ xen/include/asm-x86/config.h | 1 - 2 files changed, 4 insertions(+), 1 deletion(-)
xen/drivers/acpi/Kconfig +4 -0
@@ -4,3 +4,7 @@ config ACPI config ACPI_LEGACY_TABLES_LOOKUP bool + +config ACPI_NUMA + def_bool y + depends on ACPI && NUMA
xen/include/asm-x86/config.h +0 -1
@@ -37,7 +37,6 @@#define CONFIG_X86_L1_CACHE_SHIFT 7#define CONFIG_ACPI_SLEEP 1 -#define CONFIG_ACPI_NUMA 1#define CONFIG_ACPI_SRAT 1#define CONFIG_ACPI_CSTATE 1
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [RFC PATCH v2 25/25] NUMA: Enable ACPI_NUMA config
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 28.03.17 at 17:53, <[email protected]> wrote:
xen/drivers/acpi/Kconfig +4
-0@@ -4,3 +4,7 @@ config ACPI config ACPI_LEGACY_TABLES_LOOKUP bool + +config ACPI_NUMA + def_bool y + depends on ACPI && NUMA
xen/include/asm-x86/config.h line 41
Quoted 6 lines
xen/include/asm-x86/config.h +0
-1@@ -37,7 +37,6 @@#define CONFIG_X86_L1_CACHE_SHIFT 7#define CONFIG_ACPI_SLEEP 1 -#define CONFIG_ACPI_NUMA 1#define CONFIG_ACPI_SRAT 1#define CONFIG_ACPI_CSTATE 1
I'm not convinced the better approach wouldn't be to simply drop CONFIG_ACPI_NUMA, suitable replacing the few uses.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel