Skip to contentSkip to conversation

x86: UV SGI, Don't track GRU space in PAT

PATCH Superseded Jack Steiner 3 participants 13 messages Oct 29, 2009 – Dec 1, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: UV SGI, Don't track GRU space in PAT

GRU space is always mapped as WB in the page table. There is no need to track the mappings in the PAT. This also eliminates the "freeing invalid memtype" messages when the GRU space is unmapped.

---

(resend of patch sent on 9/9. Seems to have fallen thru the cracks...)

 arch/x86/include/asm/uv/uv.h       |    2 ++
 arch/x86/kernel/apic/x2apic_uv_x.c |   11 ++++++++++-
 arch/x86/mm/pat.c                  |    5 +++--
 3 files changed, 15 insertions(+), 3 deletions(-)
arch/x86/include/asm/uv/uv.h +2 -0
Index: linux/arch/x86/include/asm/uv/uv.h
===================================================================
@@ -8,6 +8,7 @@ struct mm_struct;
 
 #ifdef CONFIG_X86_UV
 
+extern int is_GRU_range(u64 start, u64 end);
 extern enum uv_system_type get_uv_system_type(void);
 extern int is_uv_system(void);
 extern void uv_cpu_init(void);
@@ -19,6 +20,7 @@ extern const struct cpumask *uv_flush_tl
 
 #else	/* X86_UV */
 
+static inline int is_GRU_range(u64 start, u64 end)	{ return 0; }
 static inline enum uv_system_type get_uv_system_type(void) { return UV_NONE; }
 static inline int is_uv_system(void)	{ return 0; }
 static inline void uv_cpu_init(void)	{ }
arch/x86/kernel/apic/x2apic_uv_x.c +10 -1
Index: linux/arch/x86/kernel/apic/x2apic_uv_x.c
===================================================================
@@ -34,6 +34,7 @@
 DEFINE_PER_CPU(int, x2apic_extra_bits);
 
 static enum uv_system_type uv_system_type;
+static u64 gru_start_paddr, gru_end_paddr;
 
 static int early_get_nodeid(void)
 {
@@ -68,6 +69,11 @@ enum uv_system_type get_uv_system_type(v
 	return uv_system_type;
 }
 
+int is_GRU_range(u64 start, u64 end)
+{
+	return start >= gru_start_paddr && end < gru_end_paddr;
+}
+
 int is_uv_system(void)
 {
 	return uv_system_type != UV_NONE;
@@ -385,8 +391,11 @@ static __init void map_gru_high(int max_
 	int shift = UVH_RH_GAM_GRU_OVERLAY_CONFIG_MMR_BASE_SHFT;
 
 	gru.v = uv_read_local_mmr(UVH_RH_GAM_GRU_OVERLAY_CONFIG_MMR);
-	if (gru.s.enable)
+	if (gru.s.enable) {
 		map_high("GRU", gru.s.base, shift, max_pnode, map_wb);
+		gru_start_paddr = ((u64)gru.s.base << shift);
+		gru_end_paddr = gru_start_paddr + (1UL << shift) * (max_pnode + 1);
+	}
 }
 
 static __init void map_mmr_high(int max_pnode)
arch/x86/mm/pat.c +3 -2
Index: linux/arch/x86/mm/pat.c
===================================================================
@@ -28,6 +28,7 @@
 #include <asm/msr.h>
 #include <asm/pat.h>
 #include <asm/io.h>
+#include <asm/uv/uv.h>
 
 #ifdef CONFIG_X86_PAT
 int __read_mostly pat_enabled = 1;
@@ -388,7 +389,7 @@ int reserve_memtype(u64 start, u64 end, 
 	}
 
 	/* Low ISA region is always mapped WB in page table. No need to track */
-	if (is_ISA_range(start, end - 1)) {
+	if (is_ISA_range(start, end - 1) || is_GRU_range(start, end - 1)) {
 		if (new_type)
 			*new_type = _PAGE_CACHE_WB;
 		return 0;
@@ -499,7 +500,7 @@ int free_memtype(u64 start, u64 end)
 		return 0;
 
 	/* Low ISA region is always mapped WB. No need to track */
-	if (is_ISA_range(start, end - 1))
+	if (is_ISA_range(start, end - 1) || is_GRU_range(start, end - 1))
 		return 0;
 
 	is_range_ram = pat_pagerange_is_ram(start, end);
#1 lore raw
Quoted 96 lines · Jack Steiner

GRU space is always mapped as WB in the page table. There is no need to track the mappings in the PAT. This also eliminates the "freeing invalid memtype" messages when the GRU space is unmapped.

---

(resend of patch sent on 9/9. Seems to have fallen thru the cracks...)

 arch/x86/include/asm/uv/uv.h       |    2 ++
 arch/x86/kernel/apic/x2apic_uv_x.c |   11 ++++++++++-
 arch/x86/mm/pat.c                  |    5 +++--
 3 files changed, 15 insertions(+), 3 deletions(-)

Index: linux/arch/x86/include/asm/uv/uv.h
===================================================================

arch/x86/include/asm/uv/uv.h +2 -0
@@ -8,6 +8,7 @@ struct mm_struct;
 
 #ifdef CONFIG_X86_UV
 
+extern int is_GRU_range(u64 start, u64 end);
 extern enum uv_system_type get_uv_system_type(void);
 extern int is_uv_system(void);
 extern void uv_cpu_init(void);
@@ -19,6 +20,7 @@ extern const struct cpumask *uv_flush_tl
 
 #else	/* X86_UV */
 
+static inline int is_GRU_range(u64 start, u64 end)	{ return 0; }
 static inline enum uv_system_type get_uv_system_type(void) { return UV_NONE; }
 static inline int is_uv_system(void)	{ return 0; }
 static inline void uv_cpu_init(void)	{ }

Index: linux/arch/x86/kernel/apic/x2apic_uv_x.c
===================================================================

arch/x86/kernel/apic/x2apic_uv_x.c +10 -1
@@ -34,6 +34,7 @@
 DEFINE_PER_CPU(int, x2apic_extra_bits);
 
 static enum uv_system_type uv_system_type;
+static u64 gru_start_paddr, gru_end_paddr;
 
 static int early_get_nodeid(void)
 {
@@ -68,6 +69,11 @@ enum uv_system_type get_uv_system_type(v
 	return uv_system_type;
 }
 
+int is_GRU_range(u64 start, u64 end)
+{
+	return start >= gru_start_paddr && end < gru_end_paddr;
+}
+
 int is_uv_system(void)
 {
 	return uv_system_type != UV_NONE;
@@ -385,8 +391,11 @@ static __init void map_gru_high(int max_
 	int shift = UVH_RH_GAM_GRU_OVERLAY_CONFIG_MMR_BASE_SHFT;
 
 	gru.v = uv_read_local_mmr(UVH_RH_GAM_GRU_OVERLAY_CONFIG_MMR);
-	if (gru.s.enable)
+	if (gru.s.enable) {
 		map_high("GRU", gru.s.base, shift, max_pnode, map_wb);
+		gru_start_paddr = ((u64)gru.s.base << shift);
+		gru_end_paddr = gru_start_paddr + (1UL << shift) * (max_pnode + 1);
+	}
 }
 
 static __init void map_mmr_high(int max_pnode)

Index: linux/arch/x86/mm/pat.c
===================================================================

arch/x86/mm/pat.c +2 -1
@@ -28,6 +28,7 @@
 #include <asm/msr.h>
 #include <asm/pat.h>
 #include <asm/io.h>
+#include <asm/uv/uv.h>
 
 #ifdef CONFIG_X86_PAT
 int __read_mostly pat_enabled = 1;
@@ -388,7 +389,7 @@ int reserve_memtype(u64 start, u64 end, 
 	}
 
 	/* Low ISA region is always mapped WB in page table. No need to track */
-	if (is_ISA_range(start, end - 1)) {
+	if (is_ISA_range(start, end - 1) || is_GRU_range(start, end - 1)) {
 		if (new_type)
 			*new_type = _PAGE_CACHE_WB;
 		return 0;

arch/x86/mm/pat.c int free_memtype(u64 start, u64 end) · line 504

Quoted 6 lines
arch/x86/mm/pat.c +1 -1
@@ -499,7 +500,7 @@ int free_memtype(u64 start, u64 end)
 		return 0;
 
 	/* Low ISA region is always mapped WB. No need to track */
-	if (is_ISA_range(start, end - 1))
+	if (is_ISA_range(start, end - 1) || is_GRU_range(start, end - 1))
 		return 0;

Hm, that's quite ugly - we used to have is_ISA_range() exceptions, now is_GRU_range() is added too.

We should instead have an x86_platform vector for PAT exceptions, which SGI/UV (and ISA) would fill in automatically, agreed?

Ingo

#2 lore raw

...

Quoted 10 lines

Review

Quoted 4 lines
(quoted diff) +1 -1
 	/* Low ISA region is always mapped WB. No need to track */
-	if (is_ISA_range(start, end - 1))
+	if (is_ISA_range(start, end - 1) || is_GRU_range(start, end - 1))
 		return 0;

Hm, that's quite ugly - we used to have is_ISA_range() exceptions, now is_GRU_range() is added too.

We should instead have an x86_platform vector for PAT exceptions, which SGI/UV (and ISA) would fill in automatically, agreed?

Could you point me to some code to clone - I'm not sure exactly what you have in mind.

Is this close (untested)?? If so, I'll clean it up,test it & post a real patch.

--- jack

arch/x86/mm/pat.c +9 -3
Index: linux/arch/x86/mm/pat.c
===================================================================
@@ -353,6 +353,12 @@ static int free_ram_pages_type(u64 start
 	return 0;
 }
 
+static int default_is_untracked_pat_range(u64 start, u64 end)
+{
+	return is_ISA_range(start, end);
+}
+int (*is_untracked_pat_range)(u64 start, u64 end) = default_is_untracked_pat_range;
+
 /*
  * req_type typically has one of the:
  * - _PAGE_CACHE_WB
@@ -393,7 +399,7 @@ int reserve_memtype(u64 start, u64 end, 
 	}
 
 	/* Low ISA region is always mapped WB in page table. No need to track */
-	if (is_ISA_range(start, end - 1)) {
+	if (is_untracked_pat_range(start, end - 1)) {
 		if (new_type)
 			*new_type = _PAGE_CACHE_WB;
 		return 0;
@@ -504,7 +510,7 @@ int free_memtype(u64 start, u64 end)
 		return 0;
 
 	/* Low ISA region is always mapped WB. No need to track */
-	if (is_ISA_range(start, end - 1))
+	if (default_is_untracked_pat_range(start, end - 1))
 		return 0;
 
 	is_range_ram = pat_pagerange_is_ram(start, end);
@@ -587,7 +593,7 @@ static unsigned long lookup_memtype(u64 
 	int rettype = _PAGE_CACHE_WB;
 	struct memtype *entry;
 
-	if (is_ISA_range(paddr, paddr + PAGE_SIZE - 1))
+	if (is_untracked_pat_range(paddr, paddr + PAGE_SIZE - 1))
 		return rettype;
 
 	if (pat_pagerange_is_ram(paddr, paddr + PAGE_SIZE)) {
arch/x86/include/asm/pat.h +2 -0
Index: linux/arch/x86/include/asm/pat.h
===================================================================
@@ -24,4 +24,6 @@ int io_reserve_memtype(resource_size_t s
 
 void io_free_memtype(resource_size_t start, resource_size_t end);
 
+extern int (*is_untracked_pat_range)(u64 start, u64 end);
+
 #endif /* _ASM_X86_PAT_H */
arch/x86/kernel/apic/x2apic_uv_x.c +18 -1
Index: linux/arch/x86/kernel/apic/x2apic_uv_x.c
===================================================================
@@ -30,10 +30,22 @@
 #include <asm/apic.h>
 #include <asm/ipi.h>
 #include <asm/smp.h>
+#include <asm/pat.h>
 
 DEFINE_PER_CPU(int, x2apic_extra_bits);
 
 static enum uv_system_type uv_system_type;
+static u64 gru_start_paddr, gru_end_paddr;
+
+static int is_GRU_range(u64 start, u64 end)
+{
+	return start >= gru_start_paddr && end < gru_end_paddr;
+}
+
+static int uv_is_untracked_pat_range(u64 start, u64 end)
+{
+	return is_ISA_range(start, end) || is_GRU_range(start, end);
+}
 
 static int early_get_nodeid(void)
 {
@@ -49,6 +61,7 @@ static int early_get_nodeid(void)
 static int __init uv_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
 {
 	if (!strcmp(oem_id, "SGI")) {
+		is_untracked_pat_range =  uv_is_untracked_pat_range;
 		if (!strcmp(oem_table_id, "UVL"))
 			uv_system_type = UV_LEGACY_APIC;
 		else if (!strcmp(oem_table_id, "UVX"))
@@ -388,8 +401,12 @@ static __init void map_gru_high(int max_
 	int shift = UVH_RH_GAM_GRU_OVERLAY_CONFIG_MMR_BASE_SHFT;
 
 	gru.v = uv_read_local_mmr(UVH_RH_GAM_GRU_OVERLAY_CONFIG_MMR);
-	if (gru.s.enable)
+	if (gru.s.enable) {
 		map_high("GRU", gru.s.base, shift, max_pnode, map_wb);
+		gru_start_paddr = ((u64)gru.s.base << shift);
+		gru_end_paddr = gru_start_paddr + (1UL << shift) * (max_pnode + 1);
+
+	}
 }
 
 static __init void map_mmr_high(int max_pnode)
#3 lore raw
In reply to Ingo Molnar

GRU space is always mapped as WB in the page table. There is no need to track the mappings in the PAT. This also eliminates the "freeing invalid memtype" messages when the GRU space is unmapped.

---
Version 2 with changes suggested by Ingo (at least I think I understood what he wanted).

 arch/x86/include/asm/pat.h         |    2 ++
 arch/x86/kernel/apic/x2apic_uv_x.c |   19 ++++++++++++++++++-
 arch/x86/mm/pat.c                  |   12 +++++++++---
 3 files changed, 29 insertions(+), 4 deletions(-)
arch/x86/include/asm/pat.h +2 -0
Index: linux/arch/x86/include/asm/pat.h
===================================================================
@@ -24,4 +24,6 @@ int io_reserve_memtype(resource_size_t s
 
 void io_free_memtype(resource_size_t start, resource_size_t end);
 
+extern int (*is_untracked_pat_range)(u64 start, u64 end);
+
 #endif /* _ASM_X86_PAT_H */
arch/x86/kernel/apic/x2apic_uv_x.c +18 -1
Index: linux/arch/x86/kernel/apic/x2apic_uv_x.c
===================================================================
@@ -30,10 +30,22 @@
 #include <asm/apic.h>
 #include <asm/ipi.h>
 #include <asm/smp.h>
+#include <asm/pat.h>
 
 DEFINE_PER_CPU(int, x2apic_extra_bits);
 
 static enum uv_system_type uv_system_type;
+static u64 gru_start_paddr, gru_end_paddr;
+
+static int is_GRU_range(u64 start, u64 end)
+{
+	return start >= gru_start_paddr && end < gru_end_paddr;
+}
+
+static int uv_is_untracked_pat_range(u64 start, u64 end)
+{
+	return is_ISA_range(start, end) || is_GRU_range(start, end);
+}
 
 static int early_get_nodeid(void)
 {
@@ -49,6 +61,7 @@ static int early_get_nodeid(void)
 static int __init uv_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
 {
 	if (!strcmp(oem_id, "SGI")) {
+		is_untracked_pat_range =  uv_is_untracked_pat_range;
 		if (!strcmp(oem_table_id, "UVL"))
 			uv_system_type = UV_LEGACY_APIC;
 		else if (!strcmp(oem_table_id, "UVX"))
@@ -386,8 +399,12 @@ static __init void map_gru_high(int max_
 	int shift = UVH_RH_GAM_GRU_OVERLAY_CONFIG_MMR_BASE_SHFT;
 
 	gru.v = uv_read_local_mmr(UVH_RH_GAM_GRU_OVERLAY_CONFIG_MMR);
-	if (gru.s.enable)
+	if (gru.s.enable) {
 		map_high("GRU", gru.s.base, shift, max_pnode, map_wb);
+		gru_start_paddr = ((u64)gru.s.base << shift);
+		gru_end_paddr = gru_start_paddr + (1UL << shift) * (max_pnode + 1);
+
+	}
 }
 
 static __init void map_mmr_high(int max_pnode)
arch/x86/mm/pat.c +9 -3
Index: linux/arch/x86/mm/pat.c
===================================================================
@@ -348,6 +348,12 @@ static int free_ram_pages_type(u64 start
 	return 0;
 }
 
+static int default_is_untracked_pat_range(u64 start, u64 end)
+{
+	return is_ISA_range(start, end);
+}
+int (*is_untracked_pat_range)(u64 start, u64 end) = default_is_untracked_pat_range;
+
 /*
  * req_type typically has one of the:
  * - _PAGE_CACHE_WB
@@ -383,7 +389,7 @@ int reserve_memtype(u64 start, u64 end, 
 	}
 
 	/* Low ISA region is always mapped WB in page table. No need to track */
-	if (is_ISA_range(start, end - 1)) {
+	if (is_untracked_pat_range(start, end - 1)) {
 		if (new_type)
 			*new_type = _PAGE_CACHE_WB;
 		return 0;
@@ -494,7 +500,7 @@ int free_memtype(u64 start, u64 end)
 		return 0;
 
 	/* Low ISA region is always mapped WB. No need to track */
-	if (is_ISA_range(start, end - 1))
+	if (default_is_untracked_pat_range(start, end - 1))
 		return 0;
 
 	is_range_ram = pat_pagerange_is_ram(start, end);
@@ -577,7 +583,7 @@ static unsigned long lookup_memtype(u64 
 	int rettype = _PAGE_CACHE_WB;
 	struct memtype *entry;
 
-	if (is_ISA_range(paddr, paddr + PAGE_SIZE - 1))
+	if (is_untracked_pat_range(paddr, paddr + PAGE_SIZE - 1))
 		return rettype;
 
 	if (pat_pagerange_is_ram(paddr, paddr + PAGE_SIZE)) {
#4 lore raw
Quoted 9 lines · Jack Steiner

GRU space is always mapped as WB in the page table. There is no need to track the mappings in the PAT. This also eliminates the "freeing invalid memtype" messages when the GRU space is unmapped.

---
Version 2 with changes suggested by Ingo (at least I think I understood what he wanted).

Looks good, except I think is_untracked_pat_range() probably should me a member in the x86_platform structure -- as, probably, should x86_platform_ipi_callback.

-hpa

#5 lore raw

PATCH v3 1/1 x86: UV SGI, Don't track GRU space in PAT

GRU space is always mapped as WB in the page table. There is no need to track the mappings in the PAT. This also eliminates the "freeing invalid memtype" messages when the GRU space is unmapped.

---
Version 2 with changes suggested by Ingo (at least I think I understood what he wanted).

Version 3 with changes suggested by Peter to make the new function a member of the x86_platform structure.

 arch/x86/include/asm/pat.h         |    2 ++
 arch/x86/include/asm/x86_init.h    |    1 +
 arch/x86/kernel/apic/x2apic_uv_x.c |   19 ++++++++++++++++++-
 arch/x86/kernel/x86_init.c         |    2 ++
 arch/x86/mm/pat.c                  |   11 ++++++++---
 5 files changed, 31 insertions(+), 4 deletions(-)
arch/x86/include/asm/pat.h +2 -0
Index: linux/arch/x86/include/asm/pat.h
===================================================================
@@ -24,4 +24,6 @@ int io_reserve_memtype(resource_size_t s
 
 void io_free_memtype(resource_size_t start, resource_size_t end);
 
+int default_is_untracked_pat_range(u64 start, u64 end);
+
 #endif /* _ASM_X86_PAT_H */
arch/x86/include/asm/x86_init.h +1 -0
Index: linux/arch/x86/include/asm/x86_init.h
===================================================================
@@ -131,6 +131,7 @@ struct x86_platform_ops {
 	unsigned long (*get_wallclock)(void);
 	int (*set_wallclock)(unsigned long nowtime);
 	void (*iommu_shutdown)(void);
+	int (*is_untracked_pat_range)(u64 start, u64 end);
 };
 
 extern struct x86_init_ops x86_init;
arch/x86/kernel/apic/x2apic_uv_x.c +18 -1
Index: linux/arch/x86/kernel/apic/x2apic_uv_x.c
===================================================================
@@ -30,10 +30,22 @@
 #include <asm/apic.h>
 #include <asm/ipi.h>
 #include <asm/smp.h>
+#include <asm/x86_init.h>
 
 DEFINE_PER_CPU(int, x2apic_extra_bits);
 
 static enum uv_system_type uv_system_type;
+static u64 gru_start_paddr, gru_end_paddr;
+
+static int is_GRU_range(u64 start, u64 end)
+{
+	return start >= gru_start_paddr && end < gru_end_paddr;
+}
+
+static int uv_is_untracked_pat_range(u64 start, u64 end)
+{
+	return is_ISA_range(start, end) || is_GRU_range(start, end);
+}
 
 static int early_get_nodeid(void)
 {
@@ -49,6 +61,7 @@ static int early_get_nodeid(void)
 static int __init uv_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
 {
 	if (!strcmp(oem_id, "SGI")) {
+		x86_platform.is_untracked_pat_range =  uv_is_untracked_pat_range;
 		if (!strcmp(oem_table_id, "UVL"))
 			uv_system_type = UV_LEGACY_APIC;
 		else if (!strcmp(oem_table_id, "UVX"))
@@ -386,8 +399,12 @@ static __init void map_gru_high(int max_
 	int shift = UVH_RH_GAM_GRU_OVERLAY_CONFIG_MMR_BASE_SHFT;
 
 	gru.v = uv_read_local_mmr(UVH_RH_GAM_GRU_OVERLAY_CONFIG_MMR);
-	if (gru.s.enable)
+	if (gru.s.enable) {
 		map_high("GRU", gru.s.base, shift, max_pnode, map_wb);
+		gru_start_paddr = ((u64)gru.s.base << shift);
+		gru_end_paddr = gru_start_paddr + (1UL << shift) * (max_pnode + 1);
+
+	}
 }
 
 static __init void map_mmr_high(int max_pnode)
arch/x86/kernel/x86_init.c +2 -0
Index: linux/arch/x86/kernel/x86_init.c
===================================================================
@@ -15,6 +15,7 @@
 #include <asm/irq.h>
 #include <asm/tsc.h>
 #include <asm/iommu.h>
+#include <asm/pat.h>
 
 void __cpuinit x86_init_noop(void) { }
 void __init x86_init_uint_noop(unsigned int unused) { }
@@ -80,4 +81,5 @@ struct x86_platform_ops x86_platform = {
 	.get_wallclock			= mach_get_cmos_time,
 	.set_wallclock			= mach_set_rtc_mmss,
 	.iommu_shutdown			= iommu_shutdown_noop,
+	.is_untracked_pat_range		= default_is_untracked_pat_range,
 };
arch/x86/mm/pat.c +8 -3
Index: linux/arch/x86/mm/pat.c
===================================================================
@@ -348,6 +348,11 @@ static int free_ram_pages_type(u64 start
 	return 0;
 }
 
+int default_is_untracked_pat_range(u64 start, u64 end)
+{
+	return is_ISA_range(start, end);
+}
+
 /*
  * req_type typically has one of the:
  * - _PAGE_CACHE_WB
@@ -383,7 +388,7 @@ int reserve_memtype(u64 start, u64 end, 
 	}
 
 	/* Low ISA region is always mapped WB in page table. No need to track */
-	if (is_ISA_range(start, end - 1)) {
+	if (x86_platform.is_untracked_pat_range(start, end - 1)) {
 		if (new_type)
 			*new_type = _PAGE_CACHE_WB;
 		return 0;
@@ -494,7 +499,7 @@ int free_memtype(u64 start, u64 end)
 		return 0;
 
 	/* Low ISA region is always mapped WB. No need to track */
-	if (is_ISA_range(start, end - 1))
+	if (x86_platform.is_untracked_pat_range(start, end - 1))
 		return 0;
 
 	is_range_ram = pat_pagerange_is_ram(start, end);
@@ -577,7 +582,7 @@ static unsigned long lookup_memtype(u64 
 	int rettype = _PAGE_CACHE_WB;
 	struct memtype *entry;
 
-	if (is_ISA_range(paddr, paddr + PAGE_SIZE - 1))
+	if (x86_platform.is_untracked_pat_range(paddr, paddr + PAGE_SIZE - 1))
 		return rettype;
 
 	if (pat_pagerange_is_ram(paddr, paddr + PAGE_SIZE)) {
#6 lore raw
Quoted 4 lines · Jack Steiner

GRU space is always mapped as WB in the page table. There is no need to track the mappings in the PAT. This also eliminates the "freeing invalid memtype" messages when the GRU space is unmapped.

Quoted 8 lines

---
Version 2 with changes suggested by Ingo (at least I think I understood what he wanted).

Version 3 with changes suggested by Peter to make the new function a member of the x86_platform structure.

thanks, it looks much cleaner now. I've applied it to tip:x86/mm.

Ingo

#7 lore raw

[tip:x86/mm] x86: UV SGI: Don't track GRU space in PAT

In reply to Jack Steiner
Commit-ID:  fd12a0d69aee6d90fa9b9890db24368a897f8423
Gitweb:     http://git.kernel.org/tip/fd12a0d69aee6d90fa9b9890db24368a897f8423
Author:     Jack Steiner <[email protected]>
AuthorDate: Thu, 19 Nov 2009 14:23:41 -0600
Committer:  Ingo Molnar <[email protected]>
CommitDate: Mon, 23 Nov 2009 19:47:42 +0100

x86: UV SGI: Don't track GRU space in PAT

GRU space is always mapped as WB in the page table. There is no need to track the mappings in the PAT. This also eliminates the "freeing invalid memtype" messages when the GRU space is unmapped.

LKML-Reference: <[email protected]>

[ v2: fix build failure ]
---
 arch/x86/include/asm/pat.h         |    2 ++
 arch/x86/include/asm/x86_init.h    |    2 ++
 arch/x86/kernel/apic/x2apic_uv_x.c |   19 ++++++++++++++++++-
 arch/x86/kernel/x86_init.c         |    2 ++
 arch/x86/mm/pat.c                  |   12 +++++++++---
 5 files changed, 33 insertions(+), 4 deletions(-)
arch/x86/include/asm/pat.h +2 -0
index e2c1668..4c35dd0 100644
@@ -24,4 +24,6 @@ int io_reserve_memtype(resource_size_t start, resource_size_t end,
 
 void io_free_memtype(resource_size_t start, resource_size_t end);
 
+int default_is_untracked_pat_range(u64 start, u64 end);
+
 #endif /* _ASM_X86_PAT_H */
arch/x86/include/asm/x86_init.h +2 -0
index 2c756fd..8112ed7 100644
@@ -113,11 +113,13 @@ struct x86_cpuinit_ops {
 
 /**
  * struct x86_platform_ops - platform specific runtime functions
+ * @is_untracked_pat_range	exclude from PAT logic
  * @calibrate_tsc:		calibrate TSC
  * @get_wallclock:		get time from HW clock like RTC etc.
  * @set_wallclock:		set time back to HW clock
  */
 struct x86_platform_ops {
+	int (*is_untracked_pat_range)(u64 start, u64 end);
 	unsigned long (*calibrate_tsc)(void);
 	unsigned long (*get_wallclock)(void);
 	int (*set_wallclock)(unsigned long nowtime);
arch/x86/kernel/apic/x2apic_uv_x.c +18 -1
index f5f5886..2477c9f 100644
@@ -30,10 +30,22 @@
 #include <asm/apic.h>
 #include <asm/ipi.h>
 #include <asm/smp.h>
+#include <asm/x86_init.h>
 
 DEFINE_PER_CPU(int, x2apic_extra_bits);
 
 static enum uv_system_type uv_system_type;
+static u64 gru_start_paddr, gru_end_paddr;
+
+static int is_GRU_range(u64 start, u64 end)
+{
+	return start >= gru_start_paddr && end < gru_end_paddr;
+}
+
+static int uv_is_untracked_pat_range(u64 start, u64 end)
+{
+	return is_ISA_range(start, end) || is_GRU_range(start, end);
+}
 
 static int early_get_nodeid(void)
 {
@@ -49,6 +61,7 @@ static int early_get_nodeid(void)
 static int __init uv_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
 {
 	if (!strcmp(oem_id, "SGI")) {
+		x86_platform.is_untracked_pat_range =  uv_is_untracked_pat_range;
 		if (!strcmp(oem_table_id, "UVL"))
 			uv_system_type = UV_LEGACY_APIC;
 		else if (!strcmp(oem_table_id, "UVX"))
@@ -385,8 +398,12 @@ static __init void map_gru_high(int max_pnode)
 	int shift = UVH_RH_GAM_GRU_OVERLAY_CONFIG_MMR_BASE_SHFT;
 
 	gru.v = uv_read_local_mmr(UVH_RH_GAM_GRU_OVERLAY_CONFIG_MMR);
-	if (gru.s.enable)
+	if (gru.s.enable) {
 		map_high("GRU", gru.s.base, shift, max_pnode, map_wb);
+		gru_start_paddr = ((u64)gru.s.base << shift);
+		gru_end_paddr = gru_start_paddr + (1UL << shift) * (max_pnode + 1);
+
+	}
 }
 
 static __init void map_mmr_high(int max_pnode)
arch/x86/kernel/x86_init.c +2 -0
index 4449a4a..bcc749e 100644
@@ -13,6 +13,7 @@
 #include <asm/e820.h>
 #include <asm/time.h>
 #include <asm/irq.h>
+#include <asm/pat.h>
 #include <asm/tsc.h>
 
 void __cpuinit x86_init_noop(void) { }
@@ -69,6 +70,7 @@ struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
 };
 
 struct x86_platform_ops x86_platform = {
+	.is_untracked_pat_range		= default_is_untracked_pat_range,
 	.calibrate_tsc			= native_calibrate_tsc,
 	.get_wallclock			= mach_get_cmos_time,
 	.set_wallclock			= mach_set_rtc_mmss,
arch/x86/mm/pat.c +9 -3
index e78cd0e..38a66ef 100644
@@ -20,6 +20,7 @@
 #include <asm/cacheflush.h>
 #include <asm/processor.h>
 #include <asm/tlbflush.h>
+#include <asm/x86_init.h>
 #include <asm/pgtable.h>
 #include <asm/fcntl.h>
 #include <asm/e820.h>
@@ -348,6 +349,11 @@ static int free_ram_pages_type(u64 start, u64 end)
 	return 0;
 }
 
+int default_is_untracked_pat_range(u64 start, u64 end)
+{
+	return is_ISA_range(start, end);
+}
+
 /*
  * req_type typically has one of the:
  * - _PAGE_CACHE_WB
@@ -388,7 +394,7 @@ int reserve_memtype(u64 start, u64 end, unsigned long req_type,
 	}
 
 	/* Low ISA region is always mapped WB in page table. No need to track */
-	if (is_ISA_range(start, end - 1)) {
+	if (x86_platform.is_untracked_pat_range(start, end - 1)) {
 		if (new_type)
 			*new_type = _PAGE_CACHE_WB;
 		return 0;
@@ -499,7 +505,7 @@ int free_memtype(u64 start, u64 end)
 		return 0;
 
 	/* Low ISA region is always mapped WB. No need to track */
-	if (is_ISA_range(start, end - 1))
+	if (x86_platform.is_untracked_pat_range(start, end - 1))
 		return 0;
 
 	is_range_ram = pat_pagerange_is_ram(start, end);
@@ -582,7 +588,7 @@ static unsigned long lookup_memtype(u64 paddr)
 	int rettype = _PAGE_CACHE_WB;
 	struct memtype *entry;
 
-	if (is_ISA_range(paddr, paddr + PAGE_SIZE - 1))
+	if (x86_platform.is_untracked_pat_range(paddr, paddr + PAGE_SIZE - 1))
 		return rettype;
 
 	if (pat_pagerange_is_ram(paddr, paddr + PAGE_SIZE)) {
#8 lore raw

[tip:x86/mm] x86, mm: Call is_untracked_pat_range() rather than is_ISA_range()

In reply to Jack Steiner
Commit-ID:  55a6ca25472ee01574bfc24d23b7f5fa09cc38cf
Gitweb:     http://git.kernel.org/tip/55a6ca25472ee01574bfc24d23b7f5fa09cc38cf
Author:     H. Peter Anvin <[email protected]>
AuthorDate: Mon, 23 Nov 2009 15:12:07 -0800
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Mon, 23 Nov 2009 17:09:59 -0800

x86, mm: Call is_untracked_pat_range() rather than is_ISA_range()

Checkin fd12a0d69aee6d90fa9b9890db24368a897f8423 made the PAT untracked range a platform configurable, but missed on occurrence of is_ISA_range() which still refers to PAT-untracked memory, and therefore should be using the configurable.

Cc Jack Steiner <[email protected]>
Cc Suresh Siddha <[email protected]>

LKML-Reference: <[email protected]>

---
 arch/x86/include/asm/pgtable.h |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
arch/x86/include/asm/pgtable.h +4 -2
index af6fd36..1de2094 100644
@@ -16,6 +16,8 @@
 
 #ifndef __ASSEMBLY__
 
+#include <asm/x86_init.h>
+
 /*
  * ZERO_PAGE is a global shared page that is always zero: used
  * for zero-mapped memory areas etc..
@@ -270,9 +272,9 @@ static inline int is_new_memtype_allowed(u64 paddr, unsigned long size,
 					 unsigned long new_flags)
 {
 	/*
-	 * PAT type is always WB for ISA. So no need to check.
+	 * PAT type is always WB for untracked ranges, so no need to check.
 	 */
-	if (is_ISA_range(paddr, paddr + size - 1))
+	if (x86_platform.is_untracked_pat_range(paddr, paddr + size - 1))
 		return 1;
 
 	/*
#9 lore raw

[tip:x86/mm] x86, mm: is_untracked_pat_range() takes a normal semiclosed range

In reply to Jack Steiner
Commit-ID:  8a27138924f64d2f30c1022f909f74480046bc3f
Gitweb:     http://git.kernel.org/tip/8a27138924f64d2f30c1022f909f74480046bc3f
Author:     H. Peter Anvin <[email protected]>
AuthorDate: Mon, 23 Nov 2009 14:49:20 -0800
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Mon, 23 Nov 2009 17:09:59 -0800

x86, mm: is_untracked_pat_range() takes a normal semiclosed range

is_untracked_pat_range() -- like its components, is_ISA_range() and is_GRU_range(), takes a normal semiclosed interval (>=, <) whereas the PAT code called it as if it took a closed range (>=, <=). Fix.

Although this is a bug, I believe it is non-manifest, simply because none of the callers will call this with non-page-aligned addresses.

LKML-Reference: <[email protected]>

---
 arch/x86/include/asm/pgtable.h |    2 +-
 arch/x86/mm/pat.c              |    6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
arch/x86/include/asm/pgtable.h +1 -1
index 1de2094..a34c785 100644
@@ -274,7 +274,7 @@ static inline int is_new_memtype_allowed(u64 paddr, unsigned long size,
 	/*
 	 * PAT type is always WB for untracked ranges, so no need to check.
 	 */
-	if (x86_platform.is_untracked_pat_range(paddr, paddr + size - 1))
+	if (x86_platform.is_untracked_pat_range(paddr, paddr + size))
 		return 1;
 
 	/*
arch/x86/mm/pat.c +3 -3
index 38a66ef..b5bc08c 100644
@@ -394,7 +394,7 @@ int reserve_memtype(u64 start, u64 end, unsigned long req_type,
 	}
 
 	/* Low ISA region is always mapped WB in page table. No need to track */
-	if (x86_platform.is_untracked_pat_range(start, end - 1)) {
+	if (x86_platform.is_untracked_pat_range(start, end)) {
 		if (new_type)
 			*new_type = _PAGE_CACHE_WB;
 		return 0;
@@ -505,7 +505,7 @@ int free_memtype(u64 start, u64 end)
 		return 0;
 
 	/* Low ISA region is always mapped WB. No need to track */
-	if (x86_platform.is_untracked_pat_range(start, end - 1))
+	if (x86_platform.is_untracked_pat_range(start, end))
 		return 0;
 
 	is_range_ram = pat_pagerange_is_ram(start, end);
@@ -588,7 +588,7 @@ static unsigned long lookup_memtype(u64 paddr)
 	int rettype = _PAGE_CACHE_WB;
 	struct memtype *entry;
 
-	if (x86_platform.is_untracked_pat_range(paddr, paddr + PAGE_SIZE - 1))
+	if (x86_platform.is_untracked_pat_range(paddr, paddr + PAGE_SIZE))
 		return rettype;
 
 	if (pat_pagerange_is_ram(paddr, paddr + PAGE_SIZE)) {
#10 lore raw

[tip:x86/mm] x86: Change is_ISA_range() into an inline function

In reply to Jack Steiner
Commit-ID:  65f116f5f16dc3371fce24fb24bc4843b5380ba5
Gitweb:     http://git.kernel.org/tip/65f116f5f16dc3371fce24fb24bc4843b5380ba5
Author:     H. Peter Anvin <[email protected]>
AuthorDate: Mon, 23 Nov 2009 14:44:39 -0800
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Mon, 23 Nov 2009 17:09:59 -0800

x86: Change is_ISA_range() into an inline function

Change is_ISA_range() from a macro to an inline function. This makes it type safe, and also allows it to be assigned to a function pointer if necessary.

LKML-Reference: <[email protected]>

---
 arch/x86/include/asm/e820.h |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)
arch/x86/include/asm/e820.h +12 -7
index 40b4e61..68b4e0e 100644
@@ -61,6 +61,12 @@ struct e820map {
 	struct e820entry map[E820_X_MAX];
 };
 
+#define ISA_START_ADDRESS	0xa0000
+#define ISA_END_ADDRESS		0x100000
+
+#define BIOS_BEGIN		0x000a0000
+#define BIOS_END		0x00100000
+
 #ifdef __KERNEL__
 /* see comment in arch/x86/kernel/e820.c */
 extern struct e820map e820;
@@ -126,15 +132,14 @@ extern void e820_reserve_resources(void);
 extern void e820_reserve_resources_late(void);
 extern void setup_memory_map(void);
 extern char *default_machine_specific_memory_setup(void);
-#endif /* __KERNEL__ */
-#endif /* __ASSEMBLY__ */
 
-#define ISA_START_ADDRESS	0xa0000
-#define ISA_END_ADDRESS		0x100000
-#define is_ISA_range(s, e) ((s) >= ISA_START_ADDRESS && (e) < ISA_END_ADDRESS)
+static inline bool is_ISA_range(u64 s, u64 e)
+{
+	return s >= ISA_START_ADDRESS && e < ISA_END_ADDRESS;
+}
 
-#define BIOS_BEGIN		0x000a0000
-#define BIOS_END		0x00100000
+#endif /* __KERNEL__ */
+#endif /* __ASSEMBLY__ */
 
 #ifdef __KERNEL__
 #include <linux/ioport.h>
#11 lore raw

[tip:x86/mm] x86, platform: Change is_untracked_pat_range() to bool; cleanup init

In reply to Jack Steiner
Commit-ID:  eb41c8be89dbe079f49202774e04a79ccac48a09
Gitweb:     http://git.kernel.org/tip/eb41c8be89dbe079f49202774e04a79ccac48a09
Author:     H. Peter Anvin <[email protected]>
AuthorDate: Mon, 23 Nov 2009 14:46:07 -0800
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Mon, 23 Nov 2009 17:09:59 -0800

x86, platform: Change is_untracked_pat_range() to bool; cleanup init

- Change is_untracked_pat_range() to return bool.
- Clean up the initialization of is_untracked_pat_range() -- by default, we simply point it at is_ISA_range() directly.
- Move is_untracked_pat_range to the end of struct x86_platform, since it is the newest field.

LKML-Reference: <[email protected]>

---
 arch/x86/include/asm/pat.h         |    2 --
 arch/x86/include/asm/x86_init.h    |    4 ++--
 arch/x86/kernel/apic/x2apic_uv_x.c |    4 ++--
 arch/x86/kernel/x86_init.c         |    2 +-
 arch/x86/mm/pat.c                  |    5 -----
 5 files changed, 5 insertions(+), 12 deletions(-)
arch/x86/include/asm/pat.h +0 -2
index 4c35dd0..e2c1668 100644
@@ -24,6 +24,4 @@ int io_reserve_memtype(resource_size_t start, resource_size_t end,
 
 void io_free_memtype(resource_size_t start, resource_size_t end);
 
-int default_is_untracked_pat_range(u64 start, u64 end);
-
 #endif /* _ASM_X86_PAT_H */
arch/x86/include/asm/x86_init.h +2 -2
index 8112ed7..024cf3c 100644
@@ -113,16 +113,16 @@ struct x86_cpuinit_ops {
 
 /**
  * struct x86_platform_ops - platform specific runtime functions
- * @is_untracked_pat_range	exclude from PAT logic
  * @calibrate_tsc:		calibrate TSC
  * @get_wallclock:		get time from HW clock like RTC etc.
  * @set_wallclock:		set time back to HW clock
+ * @is_untracked_pat_range	exclude from PAT logic
  */
 struct x86_platform_ops {
-	int (*is_untracked_pat_range)(u64 start, u64 end);
 	unsigned long (*calibrate_tsc)(void);
 	unsigned long (*get_wallclock)(void);
 	int (*set_wallclock)(unsigned long nowtime);
+	bool (*is_untracked_pat_range)(u64 start, u64 end);
 };
 
 extern struct x86_init_ops x86_init;
arch/x86/kernel/apic/x2apic_uv_x.c +2 -2
index 2477c9f..597a47b 100644
@@ -37,12 +37,12 @@ DEFINE_PER_CPU(int, x2apic_extra_bits);
 static enum uv_system_type uv_system_type;
 static u64 gru_start_paddr, gru_end_paddr;
 
-static int is_GRU_range(u64 start, u64 end)
+static inline bool is_GRU_range(u64 start, u64 end)
 {
 	return start >= gru_start_paddr && end < gru_end_paddr;
 }
 
-static int uv_is_untracked_pat_range(u64 start, u64 end)
+static bool uv_is_untracked_pat_range(u64 start, u64 end)
 {
 	return is_ISA_range(start, end) || is_GRU_range(start, end);
 }
arch/x86/kernel/x86_init.c +1 -1
index bcc749e..861b8b5 100644
@@ -70,8 +70,8 @@ struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
 };
 
 struct x86_platform_ops x86_platform = {
-	.is_untracked_pat_range		= default_is_untracked_pat_range,
 	.calibrate_tsc			= native_calibrate_tsc,
 	.get_wallclock			= mach_get_cmos_time,
 	.set_wallclock			= mach_set_rtc_mmss,
+	.is_untracked_pat_range		= is_ISA_range,
 };
arch/x86/mm/pat.c +0 -5
index b5bc08c..ef71251 100644
@@ -349,11 +349,6 @@ static int free_ram_pages_type(u64 start, u64 end)
 	return 0;
 }
 
-int default_is_untracked_pat_range(u64 start, u64 end)
-{
-	return is_ISA_range(start, end);
-}
-
 /*
  * req_type typically has one of the:
  * - _PAGE_CACHE_WB
#12 lore raw

[tip:x86/mm] x86, mm: Correct the implementation of is_untracked_pat_range()

In reply to Jack Steiner
Commit-ID:  ccef086454d4c97e7b722e9303390207d681cb4c
Gitweb:     http://git.kernel.org/tip/ccef086454d4c97e7b722e9303390207d681cb4c
Author:     H. Peter Anvin <[email protected]>
AuthorDate: Mon, 30 Nov 2009 21:33:51 -0800
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Mon, 30 Nov 2009 21:33:51 -0800

x86, mm: Correct the implementation of is_untracked_pat_range()

The semantics the PAT code expect of is_untracked_pat_range() is "is this range completely contained inside the untracked region." This means that checkin 8a27138924f64d2f30c1022f909f74480046bc3f was technically wrong, because the implementation needlessly confusing.

The sane interface is for it to take a semiclosed range like just about everything else (as evidenced by the sheer number of "- 1"'s removed by that patch) so change the actual implementation to match.

Cc Ingo Molnar <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Jack Steiner <[email protected]>

LKML-Reference: <[email protected]>

---
 arch/x86/include/asm/e820.h        |    6 +++++-
 arch/x86/kernel/apic/x2apic_uv_x.c |    2 +-
 2 files changed, 6 insertions(+), 2 deletions(-)
arch/x86/include/asm/e820.h +5 -1
index 68b4e0e..761249e 100644
@@ -133,9 +133,13 @@ extern void e820_reserve_resources_late(void);
 extern void setup_memory_map(void);
 extern char *default_machine_specific_memory_setup(void);
 
+/*
+ * Returns true iff the specified range [s,e) is completely contained inside
+ * the ISA region.
+ */
 static inline bool is_ISA_range(u64 s, u64 e)
 {
-	return s >= ISA_START_ADDRESS && e < ISA_END_ADDRESS;
+	return s >= ISA_START_ADDRESS && e <= ISA_END_ADDRESS;
 }
 
 #endif /* __KERNEL__ */
arch/x86/kernel/apic/x2apic_uv_x.c +1 -1
index 597a47b..1e09417 100644
@@ -39,7 +39,7 @@ static u64 gru_start_paddr, gru_end_paddr;
 
 static inline bool is_GRU_range(u64 start, u64 end)
 {
-	return start >= gru_start_paddr && end < gru_end_paddr;
+	return start >= gru_start_paddr && end <= gru_end_paddr;
 }
 
 static bool uv_is_untracked_pat_range(u64 start, u64 end)