tlb.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * linux/include/asm-arm/tlb.h
  3. *
  4. * Copyright (C) 2002 Russell King
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * Experimentation shows that on a StrongARM, it appears to be faster
  11. * to use the "invalidate whole tlb" rather than "invalidate single
  12. * tlb" for this.
  13. *
  14. * This appears true for both the process fork+exit case, as well as
  15. * the munmap-large-area case.
  16. */
  17. #ifndef __ASMARM_TLB_H
  18. #define __ASMARM_TLB_H
  19. #include <asm/cacheflush.h>
  20. #include <asm/tlbflush.h>
  21. #ifndef CONFIG_MMU
  22. #include <linux/pagemap.h>
  23. #include <asm-generic/tlb.h>
  24. #else /* !CONFIG_MMU */
  25. #include <asm/pgalloc.h>
  26. /*
  27. * TLB handling. This allows us to remove pages from the page
  28. * tables, and efficiently handle the TLB issues.
  29. */
  30. struct mmu_gather {
  31. struct mm_struct *mm;
  32. unsigned int fullmm;
  33. };
  34. DECLARE_PER_CPU(struct mmu_gather, mmu_gathers);
  35. static inline struct mmu_gather *
  36. tlb_gather_mmu(struct mm_struct *mm, unsigned int full_mm_flush)
  37. {
  38. struct mmu_gather *tlb = &get_cpu_var(mmu_gathers);
  39. tlb->mm = mm;
  40. tlb->fullmm = full_mm_flush;
  41. return tlb;
  42. }
  43. static inline void
  44. tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end)
  45. {
  46. if (tlb->fullmm)
  47. flush_tlb_mm(tlb->mm);
  48. /* keep the page table cache within bounds */
  49. check_pgt_cache();
  50. put_cpu_var(mmu_gathers);
  51. }
  52. #define tlb_remove_tlb_entry(tlb,ptep,address) do { } while (0)
  53. /*
  54. * In the case of tlb vma handling, we can optimise these away in the
  55. * case where we're doing a full MM flush. When we're doing a munmap,
  56. * the vmas are adjusted to only cover the region to be torn down.
  57. */
  58. static inline void
  59. tlb_start_vma(struct mmu_gather *tlb, struct vm_area_struct *vma)
  60. {
  61. if (!tlb->fullmm)
  62. flush_cache_range(vma, vma->vm_start, vma->vm_end);
  63. }
  64. static inline void
  65. tlb_end_vma(struct mmu_gather *tlb, struct vm_area_struct *vma)
  66. {
  67. if (!tlb->fullmm)
  68. flush_tlb_range(vma, vma->vm_start, vma->vm_end);
  69. }
  70. #define tlb_remove_page(tlb,page) free_page_and_swap_cache(page)
  71. #define pte_free_tlb(tlb,ptep) pte_free(ptep)
  72. #define pmd_free_tlb(tlb,pmdp) pmd_free(pmdp)
  73. #define tlb_migrate_finish(mm) do { } while (0)
  74. #endif /* CONFIG_MMU */
  75. #endif