From 3788dee2d2bab33aef04b4377392371b93dee1f7 Mon Sep 17 00:00:00 2001 From: Richard Braun Date: Fri, 28 Jun 2013 20:44:33 +0200 Subject: x86/pmap: improve TLB range flushes Use a threshold to determine whether TLB entries should be invalidated indivudally or through a global TLB flush. --- arch/x86/machine/pmap.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/arch/x86/machine/pmap.c b/arch/x86/machine/pmap.c index 60c1a6e8..43ca984c 100644 --- a/arch/x86/machine/pmap.c +++ b/arch/x86/machine/pmap.c @@ -145,6 +145,12 @@ static struct { unsigned long va; } pmap_pt_vas[MAX_CPUS]; +/* + * Maximum number of mappings for which individual TLB invalidations can be + * performed. Global TLB flushes are done beyond this value. + */ +#define PMAP_UPDATE_MAX_MAPPINGS 64 + /* * TLB invalidation data. * @@ -645,9 +651,16 @@ pmap_update_local(struct pmap *pmap, unsigned long start, unsigned long end) if ((pmap != pmap_current()) && (pmap != kernel_pmap)) return; - while (start < end) { - cpu_tlb_flush_va(start); - start += PAGE_SIZE; + if (vm_page_atop(end - start) > PMAP_UPDATE_MAX_MAPPINGS) { + if (pmap == kernel_pmap) + cpu_tlb_flush_all(); + else + cpu_tlb_flush(); + } else { + while (start < end) { + cpu_tlb_flush_va(start); + start += PAGE_SIZE; + } } } -- cgit v1.2.3