[PATCH] [14/31] CPA: Use page granuality TLB flushing in change_page_attr

!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

With the infrastructure added for CLFLUSH it is possible
to only TLB flush the actually changed pages in change_page_attr()

Take care of old Athlon K7 Errata on the 32bit version

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

---
 arch/x86/mm/pageattr_32.c |   15 ++++++++-------
 arch/x86/mm/pageattr_64.c |   10 +++++-----
 2 files changed, 13 insertions(+), 12 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,19 +97,20 @@ 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 = 1;
-	if (a->full_flush && boot_cpu_data.x86_model >= 4)
+	if ((!cpu_has_clflush || a->full_flush) && boot_cpu_data.x86_model >= 4)
 		wbinvd();
 	list_for_each_entry(f, &a->l, l) {
 		if (!a->full_flush)
 			clflush_cache_range((void *)f->addr, PAGE_SIZE);
+		if (!a->full_flush)
+			__flush_tlb_one(f->addr);
 	}
 
-	/* Flush all to work around Errata in early athlons regarding 
-	 * large page flushing. 
-	 */
-	__flush_tlb_all();	
+	/* Handle errata with flushing large pages in early Athlons */
+	if (a->full_flush ||
+	    (boot_cpu_data.x86_vendor == X86_VENDOR_AMD &&
+	     boot_cpu_data.x86 == 7))
+		__flush_tlb_all();
 }
 
 static void set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte) 
Index: linux/arch/x86/mm/pageattr_64.c
===================================================================
--- linux.orig/arch/x86/mm/pageattr_64.c
+++ linux/arch/x86/mm/pageattr_64.c
@@ -92,18 +92,18 @@ 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 = 1;
-
 	/* When clflush is available always use it because it is
 	   much cheaper than WBINVD. */
-	if (a->full_flush)
+	if (a->full_flush || !cpu_has_clflush)
 		asm volatile("wbinvd" ::: "memory");
 	list_for_each_entry(f, &a->l, l) {
 		if (!a->full_flush)
 			clflush_cache_range((void *)f->addr, PAGE_SIZE);
+		if (!a->full_flush)
+			__flush_tlb_one(f->addr);
 	}
-	__flush_tlb_all();
+	if (a->full_flush)
+		__flush_tlb_all();
 }
 
 /* both protected by init_mm.mmap_sem */
--
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] [14/31] CPA: Use page granuality TLB flushing in cha..., 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)