Linux MIPS Architecture development
 help / color / mirror / Atom feed
* [PATCH] MIPS: Flush huge TLB
@ 2011-11-18 13:15 Hillf Danton
  2011-11-18 14:46 ` Ralf Baechle
  2011-11-21 10:48 ` Sergei Shtylyov
  0 siblings, 2 replies; 4+ messages in thread
From: Hillf Danton @ 2011-11-18 13:15 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: David Daney, Jayachandran C., linux-mips

When flushing TLB, if @vma is backed by huge page, we could flush huge TLB,
due to that huge page is defined to be far from normal page.

Signed-off-by: Hillf Danton <dhillf@gmail.com>
---

--- a/arch/mips/mm/tlb-r4k.c	Mon May 30 21:17:04 2011
+++ b/arch/mips/mm/tlb-r4k.c	Fri Nov 18 21:13:13 2011
@@ -120,22 +120,30 @@ void local_flush_tlb_range(struct vm_are

 	if (cpu_context(cpu, mm) != 0) {
 		unsigned long size, flags;
+		int huge = is_vm_hugetlb_page(vma);

 		ENTER_CRITICAL(flags);
-		size = (end - start + (PAGE_SIZE - 1)) >> PAGE_SHIFT;
-		size = (size + 1) >> 1;
+		if (huge) {
+			start = round_down(start, HPAGE_SIZE);
+			end = round_up(end, HPAGE_SIZE);
+			size = (end - start) >> HPAGE_SHIFT;
+		} else {
+			start = round_down(start, PAGE_SIZE << 1);
+			end = round_up(end, PAGE_SIZE << 1);
+			size = (end - start) >> (PAGE_SHIFT + 1);
+		}
 		if (size <= current_cpu_data.tlbsize/2) {
 			int oldpid = read_c0_entryhi();
 			int newpid = cpu_asid(cpu, mm);

-			start &= (PAGE_MASK << 1);
-			end += ((PAGE_SIZE << 1) - 1);
-			end &= (PAGE_MASK << 1);
 			while (start < end) {
 				int idx;

 				write_c0_entryhi(start | newpid);
-				start += (PAGE_SIZE << 1);
+				if (huge)
+					start += HPAGE_SIZE;
+				else
+					start += (PAGE_SIZE << 1);
 				mtc0_tlbw_hazard();
 				tlb_probe();
 				tlb_probe_hazard();

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-11-21 10:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-18 13:15 [PATCH] MIPS: Flush huge TLB Hillf Danton
2011-11-18 14:46 ` Ralf Baechle
2011-11-18 14:55   ` Hillf Danton
2011-11-21 10:48 ` Sergei Shtylyov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox