[PATCH] [15/31] CPA: Don't flush the caches when the CPU supports self-snoop

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <linux-kernel@...>, <jbeulich@...>, <mingo@...>, <tglx@...>
Date: Monday, January 14, 2008 - 6:16 pm

When the self-snoop CPUID bit is set change_page_attr() only needs to flush
TLBs, but not the caches.

The description of self-snoop in the Intel manuals is a bit vague
but I got confirmation that this is what SS really means.

This should improve c_p_a() performance significantly on newer
Intel CPUs.

Note: the line > 80 characters will be modified again in a followup

Signed-off-by: Andi Kleen <ak@suse.de>

---
 arch/x86/mm/pageattr_32.c    |    5 +++--
 arch/x86/mm/pageattr_64.c    |    4 ++--
 include/asm-x86/cpufeature.h |    1 +
 3 files changed, 6 insertions(+), 4 deletions(-)

Index: linux/arch/x86/mm/pageattr_32.c
===================================================================
--- linux.orig/arch/x86/mm/pageattr_32.c
+++ linux/arch/x86/mm/pageattr_32.c
@@ -97,10 +97,11 @@ static void flush_kernel_map(void *arg)
 	struct flush_arg *a = (struct flush_arg *)arg;
 	struct flush *f;
 
-	if ((!cpu_has_clflush || a->full_flush) && boot_cpu_data.x86_model >= 4)
+	if ((!cpu_has_clflush || a->full_flush) && boot_cpu_data.x86_model >= 4 &&
+		!cpu_has_ss)
 		wbinvd();
 	list_for_each_entry(f, &a->l, l) {
-		if (!a->full_flush)
+		if (!a->full_flush && !cpu_has_ss)
 			clflush_cache_range((void *)f->addr, PAGE_SIZE);
 		if (!a->full_flush)
 			__flush_tlb_one(f->addr);
Index: linux/include/asm-x86/cpufeature.h
===================================================================
--- linux.orig/include/asm-x86/cpufeature.h
+++ linux/include/asm-x86/cpufeature.h
@@ -167,6 +167,7 @@
 #define cpu_has_pebs		boot_cpu_has(X86_FEATURE_PEBS)
 #define cpu_has_clflush		boot_cpu_has(X86_FEATURE_CLFLSH)
 #define cpu_has_bts		boot_cpu_has(X86_FEATURE_BTS)
+#define cpu_has_ss		boot_cpu_has(X86_FEATURE_SELFSNOOP)
 
 #if defined(CONFIG_X86_INVLPG) || defined(CONFIG_X86_64)
 # define cpu_has_invlpg		1
Index: linux/arch/x86/mm/pageattr_64.c
===================================================================
--- linux.orig/arch/x86/mm/pageattr_64.c
+++ linux/arch/x86/mm/pageattr_64.c
@@ -94,10 +94,10 @@ static void flush_kernel_map(void *arg)
 
 	/* When clflush is available always use it because it is
 	   much cheaper than WBINVD. */
-	if (a->full_flush || !cpu_has_clflush)
+	if ((a->full_flush || !cpu_has_clflush) && !cpu_has_ss)
 		asm volatile("wbinvd" ::: "memory");
 	list_for_each_entry(f, &a->l, l) {
-		if (!a->full_flush)
+		if (!a->full_flush && !cpu_has_ss)
 			clflush_cache_range((void *)f->addr, PAGE_SIZE);
 		if (!a->full_flush)
 			__flush_tlb_one(f->addr);
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] [31/31] Clean up pte_exec, Andi Kleen, (Mon Jan 14, 6:17 pm)
[PATCH] [30/31] Remove set_kernel_exec, Andi Kleen, (Mon Jan 14, 6:17 pm)
[PATCH] [15/31] CPA: Don't flush the caches when the CPU sup..., Andi Kleen, (Mon Jan 14, 6:16 pm)
[PATCH] [9/31] CPA: Add simple self test at boot, Andi Kleen, (Mon Jan 14, 6:16 pm)
Re: [PATCH] [9/31] CPA: Add simple self test at boot, Harvey Harrison, (Tue Jan 15, 6:37 am)
[PATCH] [6/31] CPA: Undo white space changes, Andi Kleen, (Mon Jan 14, 6:16 pm)
[PATCH] [4/31] Add pte_pgprot on i386, Andi Kleen, (Mon Jan 14, 6:16 pm)
Re: [PATCH] [4/31] Add pte_pgprot on i386, Johannes Weiner, (Tue Jan 15, 9:00 am)
[PATCH] [3/31] Add pte accessors for the global bit, Andi Kleen, (Mon Jan 14, 6:16 pm)
[PATCH] [2/31] CPA: Do a simple self test at boot, Andi Kleen, (Mon Jan 14, 6:16 pm)
Re: [PATCH] [2/31] CPA: Do a simple self test at boot, Harvey Harrison, (Tue Jan 15, 4:47 am)
Re: [PATCH] [2/31] CPA: Do a simple self test at boot, Harvey Harrison, (Tue Jan 15, 6:07 am)