diff options
| author | John David Anglin <dave.anglin@bell.net> | 2013-02-03 18:01:47 -0500 |
|---|---|---|
| committer | Helge Deller <deller@gmx.de> | 2013-02-20 16:49:38 -0500 |
| commit | 6d2439d9558e259822fb487ec274cc9e362e6a81 (patch) | |
| tree | d00a002e7526cb7729c9bf5b297833c2eee8ef85 | |
| parent | 6d2ddc2f9414d5ad0d3f014416020579ccce1baf (diff) | |
parisc: fixes and cleanups in page cache flushing (3/4)
flush_cache_mm, for the non current case also uses flush_dcache_page_asm
and flush_icache_page_asm which are TMPALIAS flushes.
For the non current case, the algorithm used by get_ptep is derived from the
vmalloc_to_page implementation in vmalloc.c. It is essentially a generic page
table lookup. The other alternative was to duplicate the lookup in entry.S.
The break point for switching to a full cache flush is somewhat arbitrary. The
same approach is used in flush_cache_range for non current case. In a GCC
build and check, many small programs are executed and this change provided a
significant performance enhancement, e.g. GCC build time was cut almost in half
on a rp3440 at j4. Previously, we always flushed the entire cache.
Signed-off-by: John David Anglin <dave.anglin@bell.net>
Signed-off-by: Helge Deller <deller@gmx.de>
| -rw-r--r-- | arch/parisc/kernel/cache.c | 88 |
1 files changed, 81 insertions, 7 deletions
diff --git a/arch/parisc/kernel/cache.c b/arch/parisc/kernel/cache.c index d9cbb4b22c9f..ec63de95cbd9 100644 --- a/arch/parisc/kernel/cache.c +++ b/arch/parisc/kernel/cache.c | |||
| @@ -469,8 +469,66 @@ void flush_cache_all(void) | |||
| 469 | on_each_cpu(cacheflush_h_tmp_function, NULL, 1); | 469 | on_each_cpu(cacheflush_h_tmp_function, NULL, 1); |
| 470 | } | 470 | } |
| 471 | 471 | ||
| 472 | static inline unsigned long mm_total_size(struct mm_struct *mm) | ||
| 473 | { | ||
| 474 | struct vm_area_struct *vma; | ||
| 475 | unsigned long usize = 0; | ||
| 476 | |||
| 477 | for (vma = mm->mmap; vma; vma = vma->vm_next) | ||
| 478 | usize += vma->vm_end - vma->vm_start; | ||
| 479 | return usize; | ||
| 480 | } | ||
| 481 | |||
| 482 | static inline pte_t *get_ptep(pgd_t *pgd, unsigned long addr) | ||
| 483 | { | ||
| 484 | pte_t *ptep = NULL; | ||
| 485 | |||
| 486 | if (!pgd_none(*pgd)) { | ||
| 487 | pud_t *pud = pud_offset(pgd, addr); | ||
| 488 | if (!pud_none(*pud)) { | ||
| 489 | pmd_t *pmd = pmd_offset(pud, addr); | ||
| 490 | if (!pmd_none(*pmd)) | ||
| 491 | ptep = pte_offset_map(pmd, addr); | ||
| 492 | } | ||
| 493 | } | ||
| 494 | return ptep; | ||
| 495 | } | ||
| 496 | |||
| 472 | void flush_cache_mm(struct mm_struct *mm) | 497 | void flush_cache_mm(struct mm_struct *mm) |
| 473 | { | 498 | { |
| 499 | /* Flushing the whole cache on each cpu takes forever on | ||
| 500 | rp3440, etc. So, avoid it if the mm isn't too big. */ | ||
| 501 | if (mm_total_size(mm) < parisc_cache_flush_threshold) { | ||
| 502 | struct vm_area_struct *vma; | ||
| 503 | |||
| 504 | if (mm->context == mfsp(3)) { | ||
| 505 | for (vma = mm->mmap; vma; vma = vma->vm_next) { | ||
| 506 | flush_user_dcache_range_asm(vma->vm_start, | ||
| 507 | vma->vm_end); | ||
| 508 | if (vma->vm_flags & VM_EXEC) | ||
| 509 | flush_user_icache_range_asm( | ||
| 510 | vma->vm_start, vma->vm_end); | ||
| 511 | } | ||
| 512 | } else { | ||
| 513 | pgd_t *pgd = mm->pgd; | ||
| 514 | |||
| 515 | for (vma = mm->mmap; vma; vma = vma->vm_next) { | ||
| 516 | unsigned long addr; | ||
| 517 | |||
| 518 | for (addr = vma->vm_start; addr < vma->vm_end; | ||
| 519 | addr += PAGE_SIZE) { | ||
| 520 | pte_t *ptep = get_ptep(pgd, addr); | ||
| 521 | if (ptep != NULL) { | ||
| 522 | pte_t pte = *ptep; | ||
| 523 | __flush_cache_page(vma, addr, | ||
| 524 | page_to_phys(pte_page(pte))); | ||
| 525 | } | ||
| 526 | } | ||
| 527 | } | ||
| 528 | } | ||
| 529 | return; | ||
| 530 | } | ||
| 531 | |||
| 474 | #ifdef CONFIG_SMP | 532 | #ifdef CONFIG_SMP |
| 475 | flush_cache_all(); | 533 | flush_cache_all(); |
| 476 | #else | 534 | #else |
| @@ -496,20 +554,36 @@ flush_user_icache_range(unsigned long start, unsigned long end) | |||
| 496 | flush_instruction_cache(); | 554 | flush_instruction_cache(); |
| 497 | } | 555 | } |
| 498 | 556 | ||
| 499 | |||
| 500 | void flush_cache_range(struct vm_area_struct *vma, | 557 | void flush_cache_range(struct vm_area_struct *vma, |
| 501 | unsigned long start, unsigned long end) | 558 | unsigned long start, unsigned long end) |
| 502 | { | 559 | { |
| 503 | int sr3; | ||
| 504 | |||
| 505 | BUG_ON(!vma->vm_mm->context); | 560 | BUG_ON(!vma->vm_mm->context); |
| 506 | 561 | ||
| 507 | sr3 = mfsp(3); | 562 | if ((end - start) < parisc_cache_flush_threshold) { |
| 508 | if (vma->vm_mm->context == sr3) { | 563 | if (vma->vm_mm->context == mfsp(3)) { |
| 509 | flush_user_dcache_range(start,end); | 564 | flush_user_dcache_range_asm(start, end); |
| 510 | flush_user_icache_range(start,end); | 565 | if (vma->vm_flags & VM_EXEC) |
| 566 | flush_user_icache_range_asm(start, end); | ||
| 567 | } else { | ||
| 568 | unsigned long addr; | ||
| 569 | pgd_t *pgd = vma->vm_mm->pgd; | ||
| 570 | |||
| 571 | for (addr = start & PAGE_MASK; addr < end; | ||
| 572 | addr += PAGE_SIZE) { | ||
| 573 | pte_t *ptep = get_ptep(pgd, addr); | ||
| 574 | if (ptep != NULL) { | ||
| 575 | pte_t pte = *ptep; | ||
| 576 | flush_cache_page(vma, | ||
| 577 | addr, pte_pfn(pte)); | ||
| 578 | } | ||
| 579 | } | ||
| 580 | } | ||
| 511 | } else { | 581 | } else { |
| 582 | #ifdef CONFIG_SMP | ||
| 512 | flush_cache_all(); | 583 | flush_cache_all(); |
| 584 | #else | ||
| 585 | flush_cache_all_local(); | ||
| 586 | #endif | ||
| 513 | } | 587 | } |
| 514 | } | 588 | } |
| 515 | 589 | ||
