ACPI SRAT: Disregard reserved PXM bits
Subsystems (5)
cover ACPI SRAT: Disregard reserved PXM bits
Hi,
this has been submitted thrice already -- and while it found a bit of friendly feedback, it has not been merged. It should be IMVHO, and I hope this time the right eyes see this flying by ...
I should mention that it fixes a real problem (wrong affinities reported in sysfs and thus userspace high-perf compute code taking wrong decisions) and that this has been part of SUSE enterprise kernels since a few years now.
It should also go right into stable IMVHO.
Original description to follow ...
ACPI specification says that the OS must disregard reserved bits. The x86_64 SRAT parser does not discard the upper 24 bits of the proximity_domain (pxm) in the acpi_srat_mem_affinity entries for SRAT v1 tables. (v2 has 32 bits wide fields, v1 only 8 bits.) This can lead to problems with poor BIOS implementations that failed to set reserved bytes to zero. (The ACPI spec is a bit vague here unfortunately.)
This was also inconsistent: On x86-64 (srat_64.c), the _cpu_affinity does only use the low 8 bits of pxm, while the full 32 bits of _mem_affinity are consumed.
In srat_32.c (x86), only 8bits are used (which is OK, a 32bit system with >256 PXMs does not seem reasonable at all).
On ia64, the support of more than 8 bits was consistent between mem and cpu affinity entries, however it was dependent on "sn2" platform.
The patch series has the following goals:
* Make the kernel support consistently 8bits or 32bits for the proximity domain
* Make this dependent on the SRAT version; v1 => 8bits, v2 => 32bits.
Overview over the patches:
- [1/3] Store the SRAT table version value in acpi_srat_revision
- [2/3] x86-64: Discard the upper 24 bits in mem_affinity if rev <= 1 and use upper 24bits in cpu_affinity if rev >= 2
- [3/3] ia64: Also use upper 8/24bits if rev >= 2 (but leave logic to enable on sn2 as well -- I don't know if sn2 reports v1 or v2 SRAT) Also add two __init decls in ia64 pxm accessors.
Patch is against current git.
Note: If you respond to this mail, please keep me in Cc -- I'm not subscribed to LKML these days.
Cheers,
Signature · 1 line
Kurt Garloff <[email protected]> [Koeln/Greven]
PATCH 1/3 : Store SRAT revision
Hi,
This patch stores the SRAT table revision for later consumption by arch specific __init functions.
This is patch 1/3.
Signature · 1 line
Kurt Garloff <[email protected]> [Koeln/Greven]
From: Kurt Garloff <[email protected]>
Subject: Store SRAT table revision
References: bnc#503038
In SRAT v1, we had 8bit proximity domain (PXM) fields; SRAT v2 provides 32bits for these. The new fields were reserved before. According to the ACPI spec, the OS must disregrard reserved fields. In order to know whether or not, we must know what version the SRAT table has.
This patch stores the SRAT table revision for later consumption by arch specific __init functions.
This is patch 1/3.
--- drivers/acpi/numa.c | 3 +++ include/acpi/acpi_numa.h | 1 + 2 files changed, 4 insertions(+)
drivers/acpi/numa.c +6 -0
@@ -44,8 +44,10 @@ static int pxm_to_node_map[MAX_PXM_DOMAI = { [0 ...MAX_PXM_DOMAINS -1 ] =NUMA_NO_NODE };static int node_to_pxm_map[MAX_NUMNODES ] = { [0 ...MAX_NUMNODES -1 ] =PXM_INVAL }; +unsigned char acpi_srat_revision__initdata ; +int pxm_to_node (int pxm) {if (pxm <0 )return NUMA_NO_NODE ;
@@ -254,11 +256,15 @@ acpi_parse_memory_affinity(struct acpi_s }static int __init acpi_parse_srat (struct acpi_table_header *table) { +struct acpi_table_srat *srat;if (!table)return -EINVAL ; + srat = (struct acpi_table_srat *)table; + acpi_srat_revision = srat->header.revision; +/* Real work done in acpi_table_parse_srat below. */ return 0 ; }
include/acpi/acpi_numa.h +1 -0
@@ -14,7 +14,8 @@extern int pxm_to_node (int );extern int node_to_pxm (int );extern void __acpi_map_pxm_to_node (int ,int );extern int acpi_map_pxm_to_node (int ); +extern unsigned char acpi_srat_revision;#endif /* CONFIG_ACPI_NUMA */ #endif /* __ACP_NUMA_H */
PATCH 2/3 : x86-64: Handle SRAT v1 and v2 consistently
In reply to Kurt GarloffHi,
x86-64 was rather inconsistent prior to this patch; it used 8 bits for the pxm field in cpu_affinity, but 32 bits in mem_affinity. This patch makes it consistent: Either use 8 bits consistently (SRAT rev 1 or lower) or 32 bits (SRAT rev 2 or higher).
This is patch 2/3.
Signature · 1 line
Kurt Garloff <[email protected]> [Koeln/Greven]
From: Kurt Garloff <[email protected]>
Subject: Use SRAT table rev to use 8bit or 32bit PXM fields (x86/x86-64)
References: bnc#503038
In SRAT v1, we had 8bit proximity domain (PXM) fields; SRAT v2 provides 32bits for these. The new fields were reserved before. According to the ACPI spec, the OS must disregrard reserved fields.
x86/x86-64 was rather inconsistent prior to this patch; it used 8 bits for the pxm field in cpu_affinity, but 32 bits in mem_affinity. This patch makes it consistent: Either use 8 bits consistently (SRAT rev 1 or lower) or 32 bits (SRAT rev 2 or higher).
This is patch 2/3.
--- arch/x86/mm/srat.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/x86/mm/srat.c +4 -0
@@ -108,8 +108,10 @@ acpi_numa_processor_affinity_init(struct }if ((pa->flags &ACPI_SRAT_CPU_ENABLED ) ==0 )return ; pxm = pa->proximity_domain_lo; +if (acpi_srat_revision >=2 ) + pxm |= *((unsigned int *)pa->proximity_domain_hi) <<8 ; node =setup_node (pxm);if (node <0 ) {printk (KERN_ERR "SRAT: Too many proximity domains %x\n" , pxm);bad_srat ();
@@ -159,8 +161,10 @@ acpi_numa_memory_affinity_init(struct acreturn ; start = ma->base_address; end = start + ma->length; pxm = ma->proximity_domain; +if (acpi_srat_revision <=1 ) + pxm &=0xff ; node =setup_node (pxm);if (node <0 ) {printk (KERN_ERR "SRAT: Too many proximity domains.\n" );bad_srat ();
PATCH 3/3 : Consider SRAT rev on ia64
In reply to Kurt GarloffHi,
ia64 did handle the PXM fields almost consistently, but depending on sgi's sn2 platform. This patch leaves the sn2 logic in, but does also use 16/32 bits for PXM if the SRAT has rev 2 or higher.
This is patch 3/3.
Signature · 1 line
Kurt Garloff <[email protected]> [Koeln/Greven]
From: Kurt Garloff <[email protected]>
Subject: Use SRAT table rev to use 8bit or 16/32bit PXM fields (ia64)
References: bnc#503038
In SRAT v1, we had 8bit proximity domain (PXM) fields; SRAT v2 provides 32bits for these. The new fields were reserved before. According to the ACPI spec, the OS must disregrard reserved fields.
ia64 did handle the PXM fields almost consistently, but depending on sgi's sn2 platform. This patch leaves the sn2 logic in, but does also use 16/32 bits for PXM if the SRAT has rev 2 or higher.
The patch also adds __init to the two pxm accessor functions, as they access __initdata now and are called from an __init function only anyway.
Note that the code only uses 16 bits for the PXM field in the processor proximity field; the patch does not address this as 16 bits are more than enough.
This is patch 3/3.
--- arch/ia64/kernel/acpi.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
arch/ia64/kernel/acpi.c +6 -4
@@ -428,24 +428,26 @@ static u32 __devinitdata pxm_flag[PXM_FL#define pxm_bit_test (bit) (test_bit(bit,(void *)pxm_flag))static struct acpi_table_slit __initdata *slit_table;cpumask_t early_cpu_possible_map =CPU_MASK_NONE ; -static int get_processor_proximity_domain (struct acpi_srat_cpu_affinity *pa) +static int __init +get_processor_proximity_domain (struct acpi_srat_cpu_affinity *pa) {int pxm; pxm = pa->proximity_domain_lo; -if (ia64_platform_is ("sn2" )) +if (ia64_platform_is ("sn2" ) || acpi_srat_revision >=2 ) pxm += pa->proximity_domain_hi[0 ] <<8 ;return pxm; } -static int get_memory_proximity_domain (struct acpi_srat_mem_affinity *ma) +static int __init +get_memory_proximity_domain (struct acpi_srat_mem_affinity *ma) {int pxm; pxm = ma->proximity_domain; -if (!ia64_platform_is ("sn2" )) +if (!ia64_platform_is ("sn2" ) && acpi_srat_revision <=1 ) pxm &=0xff ;return pxm; }
Re: [PATCH 1/3]: Store SRAT revision
In reply to Kurt GarloffQuoted 32 lines · Kurt Garloff
Hi,
This patch stores the SRAT table revision for later consumption by arch specific
__initfunctions.This is patch 1/3.
Signature · 24 lines
Kurt Garloff <[email protected]> [Koeln/Greven] From: Kurt Garloff <[email protected]> Subject: Store SRAT table revision References: bnc#503038 In SRAT v1, we had 8bit proximity domain (PXM) fields; SRAT v2 provides 32bits for these. The new fields were reserved before. According to the ACPI spec, the OS must disregrard reserved fields. In order to know whether or not, we must know what version the SRAT table has. This patch stores the SRAT table revision for later consumption by arch specific __init functions. This is patch 1/3. Signed-off-by: Kurt Garloff <[email protected]> --- drivers/acpi/numa.c | 3 +++ include/acpi/acpi_numa.h | 1 + 2 files changed, 4 insertions(+)
<formletter>
This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read Documentation/stable_kernel_rules.txt for how to do this properly.
</formletter>
Len Brown
reviewerRe: [PATCH 1/3]: Store SRAT revision
In reply to Kurt Garlofflooks fine to me.
as #2 (x86) and #3 (ia64) depend on #1, which is ACPI, I can send this via the ACPI tree.
thanks,
-Len Brown, Intel Open Source Technology Center
Re: [PATCH 1/3]: Store SRAT revision
Len,
Quoted 3 lines · Len Brown
looks fine to me.
as #2 (x86) and #3 (ia64) depend on #1, which is ACPI, I can send this via the ACPI tree.
Thanks for reviewing this!
I'll wait for the git commits then and resubmit to stable (forgot to add a Cc line in the signed-off section, as GKH thankfully pointed out).
Thx,
Signature · 6 lines
Kurt Garloff <[email protected]> [Köln/Greven] (Sent from Android phone with K-9 Mail.) -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html