x86/platform/uv: UV support for sub-NUMA clustering
Subsystems (2)
Steve Wahl
maintainerPATCH v2 1/1 x86/platform/uv: UV support for sub-NUMA clustering
Sub-NUMA clustering (SNC) invalidates previous assumptions of a 1:1 relationship between blades, sockets, and nodes. Fix these assumptions and build tables correctly when SNC is enabled.
Also replace uses of BUG() and BUG_ON() with WARN_ON() and recovery.
--- arch/x86/include/asm/uv/uv_hub.h | 32 ++-- arch/x86/kernel/apic/x2apic_uv_x.c | 245 ++++++++++++++++------------- 2 files changed, 160 insertions(+), 117 deletions(-)
v2: Include the subsystem name (x86/platform/uv:) on the first line of the commit (subject line).
arch/x86/include/asm/uv/uv_hub.h +21 -11
@@ -177,6 +177,7 @@ struct uv_hub_info_s {unsigned short nr_possible_cpus;unsigned short nr_online_cpus;short memory_nid; +unsigned short *node_to_socket; };/* CPU specific info with a pointer to the hub common info struct */
@@ -519,25 +520,30 @@ static inline int uv_socket_to_node(int socket)return _uv_socket_to_node (socket, uv_hub_info->socket_to_node); } +static inline int uv_pnode_to_socket (int pnode) +{ +unsigned short *p2s = uv_hub_info->pnode_to_socket; + +return p2s ? p2s[pnode - uv_hub_info->min_pnode] : pnode; +} +/* pnode, offset --> socket virtual */ static inline void *uv_pnode_offset_to_vaddr (int pnode,unsigned long offset) {unsigned int m_val = uv_hub_info->m_val;unsigned long base; -unsigned short sockid, node, *p2s; +unsigned short sockid;if (m_val)return __va (((unsigned long )pnode << m_val) | offset); - p2s = uv_hub_info->pnode_to_socket; - sockid = p2s ? p2s[pnode - uv_hub_info->min_pnode] : pnode; - node =uv_socket_to_node (sockid); + sockid =uv_pnode_to_socket (pnode);/* limit address of previous socket is our base, except node 0 is 0 */ -if (!node) +if (sockid ==0 )return __va ((unsigned long )offset); - base = (unsigned long )(uv_hub_info->gr_table[node -1 ].limit); + base = (unsigned long )(uv_hub_info->gr_table[sockid -1 ].limit);return __va (base <<UV_GAM_RANGE_SHFT | offset); }
@@ -644,7 +650,7 @@ static inline int uv_cpu_blade_processor_id(int cpu)/* Blade number to Node number (UV2..UV4 is 1:1) */ static inline int uv_blade_to_node (int blade) { -return blade; +return uv_socket_to_node (blade); }/* Blade number of current cpu. Numnbered 0 .. <#blades -1> */
@@ -656,23 +662,27 @@ static inline int uv_numa_blade_id(void)/* * Convert linux node number to the UV blade number. * .. Currently for UV2 thru UV4 the node and the blade are identical. -* .. If this changes then you MUST check references to this function! +* .. UV5 needs conversion when sub-numa clustering is enabled. */ static inline int uv_node_to_blade_id (int nid) { -return nid; +unsigned short *n2s = uv_hub_info->node_to_socket; + +return n2s ? n2s[nid] : nid; }/* Convert a CPU number to the UV blade number */ static inline int uv_cpu_to_blade_id (int cpu) { -return uv_node_to_blade_id (cpu_to_node (cpu)); +return uv_cpu_hub_info (cpu)->numa_blade_id; }/* Convert a blade id to the PNODE of the blade */ static inline int uv_blade_to_pnode (int bid) { -return uv_hub_info_list (uv_blade_to_node (bid))->pnode; +unsigned short *s2p = uv_hub_info->socket_to_pnode; + +return s2p ? s2p[bid] : bid; }/* Nid of memory node on blade. -1 if no blade-local memory */
arch/x86/kernel/apic/x2apic_uv_x.c +139 -106
392 lines not on this page · raw message
Signature · 1 line
2.26.2
arch/x86/kernel/apic/x2apic_uv_x.c static __init void boot_init_possible_blades(struct uv_hub_info_s *hub_info) · line 1505
Quoted 10 lines · Steve Wahl
arch/x86/kernel/apic/x2apic_uv_x.c +10
-0+static int __init alloc_conv_table (int num_elem,unsigned short **table) +{ +int i; +size_t bytes; + + bytes = num_elem *sizeof (*table[0 ]); + *table =kmalloc (bytes,GFP_KERNEL ); +WARN_ON_ONCE (!*table); +if (!*table) +return -ENOMEM ;
WARN_ON_ONCE() is pass-through on the condition, so you can write this in a shorter form:
if (!WARN_ON_ONCE(!*table)) return -ENOMEM;
arch/x86/kernel/apic/x2apic_uv_x.c static void __init uv_system_init_hub(void) · line 1760
Quoted 4 lines
arch/x86/kernel/apic/x2apic_uv_x.c +4
-0+ uv_hub_info_list_blade =kzalloc (bytes,GFP_KERNEL ); +WARN_ON_ONCE (!uv_hub_info_list_blade); +if (!uv_hub_info_list_blade) +return ;
Ditto.
arch/x86/kernel/apic/x2apic_uv_x.c static void __init uv_system_init_hub(void) · line 1771
Quoted 3 lines
arch/x86/kernel/apic/x2apic_uv_x.c +3
-0+WARN_ON_ONCE (!new_hub); +if (!new_hub) +return ;
Same. Also a memory leak of at least uv_hub_info_list_blade?
arch/x86/kernel/apic/x2apic_uv_x.c static void __init uv_system_init_hub(void) · line 1796
Quoted 3 lines
arch/x86/kernel/apic/x2apic_uv_x.c +3
-0+WARN_ON_ONCE (!__uv_hub_info_list); +if (!__uv_hub_info_list) +return ;
Same.
arch/x86/kernel/apic/x2apic_uv_x.c static void __init uv_system_init_hub(void) · line 1800
Quoted 4 lines
arch/x86/kernel/apic/x2apic_uv_x.c +4
-0+ +for_each_node (nodeid) { + __uv_hub_info_list[nodeid] = uv_hub_info_list_blade[uv_node_to_blade_id (nodeid)]; + }
Unnecessary curly braces.
Looks good otherwise - presumably it's both tested and backwards compatible with older UV hardware?
Thanks,
Ingo
Steve Wahl
maintainerQuoted 17 lines · Ingo Molnar
arch/x86/kernel/apic/x2apic_uv_x.c static __init void boot_init_possible_blades(struct uv_hub_info_s *hub_info) · line 1505
Quoted 10 lines · Steve Wahl
arch/x86/kernel/apic/x2apic_uv_x.c +10
-0+static int __init alloc_conv_table (int num_elem,unsigned short **table) +{ +int i; +size_t bytes; + + bytes = num_elem *sizeof (*table[0 ]); + *table =kmalloc (bytes,GFP_KERNEL ); +WARN_ON_ONCE (!*table); +if (!*table) +return -ENOMEM ;
WARN_ON_ONCE()is pass-through on the condition, so you can write this in a shorter form:
Quoted 2 lines
if (!WARN_ON_ONCE(!*table)) return -ENOMEM;
That is nicer. I will incorporate this (including all the repeats).
...
Quoted 6 lines
arch/x86/kernel/apic/x2apic_uv_x.c static void __init uv_system_init_hub(void) · line 1771
Quoted 4 lines
arch/x86/kernel/apic/x2apic_uv_x.c +3
-0+WARN_ON_ONCE (!new_hub); +if (!new_hub) +return ;Same. Also a memory leak of at least
uv_hub_info_list_blade?
You're right, and this is not the only place. I will rework.
...
Quoted 6 lines
arch/x86/kernel/apic/x2apic_uv_x.c static void __init uv_system_init_hub(void) · line 1800
Quoted 4 lines
arch/x86/kernel/apic/x2apic_uv_x.c +4
-0+ +for_each_node (nodeid) { + __uv_hub_info_list[nodeid] = uv_hub_info_list_blade[uv_node_to_blade_id (nodeid)]; + }Unnecessary curly braces.
I will fix.
Quoted 2 lines
Looks good otherwise - presumably it's both tested and backwards compatible with older UV hardware?
Yes, in fact there was a major re-work before letting it escape to the world because the previous version didn't function on older hardware.
Thank you for taking the time to review!
--> Steve
Signature · 1 line
Steve Wahl, Hewlett Packard Enterprise