diff options
author | Alex Shi <alex.shi@intel.com> | 2012-06-27 21:02:18 -0400 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2012-06-27 22:29:09 -0400 |
commit | d8dfe60d6dcad5989c4558b753b98d657e2813c0 (patch) | |
tree | 82fd0ea40feab13ab533a5851b6371c1a7a05a59 /arch/x86/mm | |
parent | e7b52ffd45a6d834473f43b349e7d86593d763c7 (diff) |
x86/tlb: fall back to flush all when meet a THP large page
We don't need to flush large pages by PAGE_SIZE step, that just waste
time. and actually, large page don't need 'invlpg' optimizing according
to our micro benchmark. So, just flush whole TLB is enough for them.
The following result is tested on a 2CPU * 4cores * 2HT NHM EP machine,
with THP 'always' setting.
Multi-thread testing, '-t' paramter is thread number:
without this patch with this patch
./mprotect -t 1 14ns 13ns
./mprotect -t 2 13ns 13ns
./mprotect -t 4 12ns 11ns
./mprotect -t 8 14ns 10ns
./mprotect -t 16 28ns 28ns
./mprotect -t 32 54ns 52ns
./mprotect -t 128 200ns 200ns
Signed-off-by: Alex Shi <alex.shi@intel.com>
Link: http://lkml.kernel.org/r/1340845344-27557-4-git-send-email-alex.shi@intel.com
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'arch/x86/mm')
-rw-r--r-- | arch/x86/mm/tlb.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c index 3b91c981a27f..184a02a4d871 100644 --- a/arch/x86/mm/tlb.c +++ b/arch/x86/mm/tlb.c | |||
@@ -318,12 +318,42 @@ void flush_tlb_mm(struct mm_struct *mm) | |||
318 | 318 | ||
319 | #define FLUSHALL_BAR 16 | 319 | #define FLUSHALL_BAR 16 |
320 | 320 | ||
321 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | ||
322 | static inline unsigned long has_large_page(struct mm_struct *mm, | ||
323 | unsigned long start, unsigned long end) | ||
324 | { | ||
325 | pgd_t *pgd; | ||
326 | pud_t *pud; | ||
327 | pmd_t *pmd; | ||
328 | unsigned long addr = ALIGN(start, HPAGE_SIZE); | ||
329 | for (; addr < end; addr += HPAGE_SIZE) { | ||
330 | pgd = pgd_offset(mm, addr); | ||
331 | if (likely(!pgd_none(*pgd))) { | ||
332 | pud = pud_offset(pgd, addr); | ||
333 | if (likely(!pud_none(*pud))) { | ||
334 | pmd = pmd_offset(pud, addr); | ||
335 | if (likely(!pmd_none(*pmd))) | ||
336 | if (pmd_large(*pmd)) | ||
337 | return addr; | ||
338 | } | ||
339 | } | ||
340 | } | ||
341 | return 0; | ||
342 | } | ||
343 | #else | ||
344 | static inline unsigned long has_large_page(struct mm_struct *mm, | ||
345 | unsigned long start, unsigned long end) | ||
346 | { | ||
347 | return 0; | ||
348 | } | ||
349 | #endif | ||
321 | void flush_tlb_range(struct vm_area_struct *vma, | 350 | void flush_tlb_range(struct vm_area_struct *vma, |
322 | unsigned long start, unsigned long end) | 351 | unsigned long start, unsigned long end) |
323 | { | 352 | { |
324 | struct mm_struct *mm; | 353 | struct mm_struct *mm; |
325 | 354 | ||
326 | if (!cpu_has_invlpg || vma->vm_flags & VM_HUGETLB) { | 355 | if (!cpu_has_invlpg || vma->vm_flags & VM_HUGETLB) { |
356 | flush_all: | ||
327 | flush_tlb_mm(vma->vm_mm); | 357 | flush_tlb_mm(vma->vm_mm); |
328 | return; | 358 | return; |
329 | } | 359 | } |
@@ -346,6 +376,10 @@ void flush_tlb_range(struct vm_area_struct *vma, | |||
346 | if ((end - start)/PAGE_SIZE > act_entries/FLUSHALL_BAR) | 376 | if ((end - start)/PAGE_SIZE > act_entries/FLUSHALL_BAR) |
347 | local_flush_tlb(); | 377 | local_flush_tlb(); |
348 | else { | 378 | else { |
379 | if (has_large_page(mm, start, end)) { | ||
380 | preempt_enable(); | ||
381 | goto flush_all; | ||
382 | } | ||
349 | for (addr = start; addr < end; | 383 | for (addr = start; addr < end; |
350 | addr += PAGE_SIZE) | 384 | addr += PAGE_SIZE) |
351 | __flush_tlb_single(addr); | 385 | __flush_tlb_single(addr); |