x86/platform/uv: UV support for sub-NUMA clustering
Subsystems (2)
Steve Wahl
maintainerPATCH v4 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 | 318 ++++++++++++++++++----------- 2 files changed, 215 insertions(+), 135 deletions(-)
v2: Include the subsystem name (x86/platform/uv:) on the first line of the commit (subject line).
v3: Use return from WARN_ON_ONCE() to simplify the code, remove memory leaks from memory allocation failure conditions, and remove an unnecessary set of curly braces, per comments from Ingo Molnar.
v4: Testing found that some configurations required adding a check for "uv_blade_to_node(bid) == SOCK_EMPTY" in uv_system_init_hub(). Testing also found that some uv3 configurations didn't work correctly with the new blade number handling. The range of blade numbers is now needed, not just the count, so calc_mmioh_map() and boot_init_possible_blades() needed some adjustment. And a reviewer suggested using INT_MAX instead of 999999.
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 +194 -124
515 lines not on this page · raw message
Signature · 1 line
2.26.2
Steve Wahl
maintainerQuoted 3 lines · Steve Wahl
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.
Gentle ping, does anyone have comments for me on this patch?
Thanks,
--> Steve Wahl, <[email protected]>
Quoted 26 lines · Steve Wahl
arch/x86/kernel/apic/x2apic_uv_x.c +16
-1+if (np) { + s = ((i *64 ) +__ffs (np)) & s_mask; +if (sock_min > s) + sock_min = s; + s = ((i *64 ) +__fls (np)) & s_mask; +if (sock_max < s) + sock_max = s; + } } }if (UVH_NODE_PRESENT_0 ) { np =uv_read_local_mmr (UVH_NODE_PRESENT_0 );pr_info ("UV: NODE_PRESENT_0 = 0x%016lx\n" , np); - uv_pb +=hweight64 (np); +if (np) { + s =__ffs (np) & s_mask; +if (sock_min > s) + sock_min = s; + s =__fls (np) & s_mask; +if (sock_max < s) + sock_max = s; + } }if (UVH_NODE_PRESENT_1 ) { np =uv_read_local_mmr (UVH_NODE_PRESENT_1 );pr_info ("UV: NODE_PRESENT_1 = 0x%016lx\n" , np);
arch/x86/kernel/apic/x2apic_uv_x.c static __init void boot_init_possible_blades(struct uv_hub_info_s *hub_info) · line 1519
Quoted 10 lines
arch/x86/kernel/apic/x2apic_uv_x.c +9
-1- uv_pb +=hweight64 (np); +if (np) { + s = (64 +__ffs (np)) & s_mask; +if (sock_min > s) + sock_min = s; + s = (64 +__fls (np)) & s_mask; +if (sock_max < s) + sock_max = s; + } + }
I guess this patch is modifying code that very few people care about. But, this is kinda a mess. This patch does a *TON* of different things and makes almost no effort to refactor the code before diving into the changes.
I quoted the above text because whatever that code is doing, it's gloriously uncommented. That kind of thing demands a helper even if it's just used once so that a read can have _some_ idea what it's doing logically.
Could you please take another pass at this? I think it demands to be broken up into at _least_ 5-10 individual patches.
For instance, you could introduce and use uv_pnode_to_socket() in one patch.
Or this:
Quoted 9 lines
arch/x86/kernel/apic/x2apic_uv_x.c +4
-1- nasid_mask =UVH_RH_GAM_MMIOH_OVERLAY_CONFIG0_BASE_MASK ; + nasid_mask = +is_uv (UV4A ) ?UV4AH_RH_GAM_MMIOH_REDIRECT_CONFIG0_NASID_MASK : +is_uv (UV4 ) ?UV4H_RH_GAM_MMIOH_REDIRECT_CONFIG0_NASID_MASK : +UV3H_RH_GAM_MMIOH_REDIRECT_CONFIG0_NASID_MASK ; n =UVH_RH_GAM_MMIOH_REDIRECT_CONFIG0_DEPTH ; min_nasid = min_pnode *2 ; max_nasid = max_pnode *2 ;
arch/x86/kernel/apic/x2apic_uv_x.c static void __init calc_mmioh_map(enum mmioh_arch index, · line 1056
Quoted 8 lines
arch/x86/kernel/apic/x2apic_uv_x.c +4
-1@@ -1046,7 +1050,10 @@ static void __init calc_mmioh_map(enum mmioh_arch index,break ;case UVX_MMIOH1 : mmr =UVH_RH_GAM_MMIOH_REDIRECT_CONFIG1 ; - nasid_mask =UVH_RH_GAM_MMIOH_OVERLAY_CONFIG1_BASE_MASK ; + nasid_mask = +is_uv (UV4A ) ?UV4AH_RH_GAM_MMIOH_REDIRECT_CONFIG0_NASID_MASK : +is_uv (UV4 ) ?UV4H_RH_GAM_MMIOH_REDIRECT_CONFIG1_NASID_MASK : +UV3H_RH_GAM_MMIOH_REDIRECT_CONFIG1_NASID_MASK ;
That could use a helper to reduce the duplication and add clarity and be done in a separate patch.
Steve Wahl
maintainerDave,
Thank you for taking the time to review. I will create another version, doing my best to clarify and simplify.
--> Steve
Quoted 75 lines · Dave Hansen
Quoted 26 lines · Steve Wahl
arch/x86/kernel/apic/x2apic_uv_x.c +16
-1+if (np) { + s = ((i *64 ) +__ffs (np)) & s_mask; +if (sock_min > s) + sock_min = s; + s = ((i *64 ) +__fls (np)) & s_mask; +if (sock_max < s) + sock_max = s; + } } }if (UVH_NODE_PRESENT_0 ) { np =uv_read_local_mmr (UVH_NODE_PRESENT_0 );pr_info ("UV: NODE_PRESENT_0 = 0x%016lx\n" , np); - uv_pb +=hweight64 (np); +if (np) { + s =__ffs (np) & s_mask; +if (sock_min > s) + sock_min = s; + s =__fls (np) & s_mask; +if (sock_max < s) + sock_max = s; + } }if (UVH_NODE_PRESENT_1 ) { np =uv_read_local_mmr (UVH_NODE_PRESENT_1 );pr_info ("UV: NODE_PRESENT_1 = 0x%016lx\n" , np);arch/x86/kernel/apic/x2apic_uv_x.c static __init void boot_init_possible_blades(struct uv_hub_info_s *hub_info) · line 1519
Quoted 10 lines
arch/x86/kernel/apic/x2apic_uv_x.c +9
-1- uv_pb +=hweight64 (np); +if (np) { + s = (64 +__ffs (np)) & s_mask; +if (sock_min > s) + sock_min = s; + s = (64 +__fls (np)) & s_mask; +if (sock_max < s) + sock_max = s; + } + }I guess this patch is modifying code that very few people care about. But, this is kinda a mess. This patch does a *TON* of different things and makes almost no effort to refactor the code before diving into the changes.
I quoted the above text because whatever that code is doing, it's gloriously uncommented. That kind of thing demands a helper even if it's just used once so that a read can have _some_ idea what it's doing logically.
Could you please take another pass at this? I think it demands to be broken up into at _least_ 5-10 individual patches.
For instance, you could introduce and use
uv_pnode_to_socket()in one patch.Or this:
Quoted 9 lines
arch/x86/kernel/apic/x2apic_uv_x.c +4
-1- nasid_mask =UVH_RH_GAM_MMIOH_OVERLAY_CONFIG0_BASE_MASK ; + nasid_mask = +is_uv (UV4A ) ?UV4AH_RH_GAM_MMIOH_REDIRECT_CONFIG0_NASID_MASK : +is_uv (UV4 ) ?UV4H_RH_GAM_MMIOH_REDIRECT_CONFIG0_NASID_MASK : +UV3H_RH_GAM_MMIOH_REDIRECT_CONFIG0_NASID_MASK ; n =UVH_RH_GAM_MMIOH_REDIRECT_CONFIG0_DEPTH ; min_nasid = min_pnode *2 ; max_nasid = max_pnode *2 ;arch/x86/kernel/apic/x2apic_uv_x.c static void __init calc_mmioh_map(enum mmioh_arch index, · line 1056
Quoted 8 lines
arch/x86/kernel/apic/x2apic_uv_x.c +4
-1@@ -1046,7 +1050,10 @@ static void __init calc_mmioh_map(enum mmioh_arch index,break ;case UVX_MMIOH1 : mmr =UVH_RH_GAM_MMIOH_REDIRECT_CONFIG1 ; - nasid_mask =UVH_RH_GAM_MMIOH_OVERLAY_CONFIG1_BASE_MASK ; + nasid_mask = +is_uv (UV4A ) ?UV4AH_RH_GAM_MMIOH_REDIRECT_CONFIG0_NASID_MASK : +is_uv (UV4 ) ?UV4H_RH_GAM_MMIOH_REDIRECT_CONFIG1_NASID_MASK : +UV3H_RH_GAM_MMIOH_REDIRECT_CONFIG1_NASID_MASK ;That could use a helper to reduce the duplication and add clarity and be done in a separate patch.
Signature · 1 line
Steve Wahl, Hewlett Packard Enterprise