linux-mips
[Top] [All Lists]

[PATCH] MIPS: Flush huge TLB

To: Ralf Baechle <ralf@linux-mips.org>
Subject: [PATCH] MIPS: Flush huge TLB
From: Hillf Danton <dhillf@gmail.com>
Date: Fri, 18 Nov 2011 21:15:39 +0800
Cc: David Daney <david.daney@cavium.com>, "Jayachandran C." <jayachandranc@netlogicmicro.com>, linux-mips@linux-mips.org
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:cc:content-type; bh=cZSG+II3Z6BdgX+D2BXaNMeow5ENSxC+AuqphyxSOvw=; b=ITDbub+/b13hN12DjcTJCZ/PAC1VTB4xpsgvTfKGAVKn/Yu5IsScrPvPcHyR3XRQzH I27vilViivr6RNcEXxS2I5BhIE/rEU5q8LIE5lriaJzzETIiUe29D4TCMKOYEicMzTi/ 5cdekuI84JzccsU2Zn3/AlUXXlo+uyZD5YYpQ=
Sender: linux-mips-bounce@linux-mips.org
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();

<Prev in Thread] Current Thread [Next in Thread>