tlb.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #ifndef __ASMARM_TLB_H
  2. #define __ASMARM_TLB_H
  3. #include <asm/pgalloc.h>
  4. #include <asm/tlbflush.h>
  5. /*
  6. * TLB handling. This allows us to remove pages from the page
  7. * tables, and efficiently handle the TLB issues.
  8. */
  9. struct mmu_gather {
  10. struct mm_struct *mm;
  11. unsigned int freed;
  12. unsigned int fullmm;
  13. unsigned int flushes;
  14. unsigned int avoided_flushes;
  15. };
  16. extern struct mmu_gather mmu_gathers[NR_CPUS];
  17. static inline struct mmu_gather *
  18. tlb_gather_mmu(struct mm_struct *mm, unsigned int full_mm_flush)
  19. {
  20. int cpu = smp_processor_id();
  21. struct mmu_gather *tlb = &mmu_gathers[cpu];
  22. tlb->mm = mm;
  23. tlb->freed = 0;
  24. tlb->fullmm = full_mm_flush;
  25. return tlb;
  26. }
  27. static inline void
  28. tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end)
  29. {
  30. struct mm_struct *mm = tlb->mm;
  31. unsigned long freed = tlb->freed;
  32. int rss = get_mm_counter(mm, rss);
  33. if (rss < freed)
  34. freed = rss;
  35. add_mm_counter(mm, rss, -freed);
  36. if (freed) {
  37. flush_tlb_mm(mm);
  38. tlb->flushes++;
  39. } else {
  40. tlb->avoided_flushes++;
  41. }
  42. /* keep the page table cache within bounds */
  43. check_pgt_cache();
  44. }
  45. static inline unsigned int
  46. tlb_is_full_mm(struct mmu_gather *tlb)
  47. {
  48. return tlb->fullmm;
  49. }
  50. #define tlb_remove_tlb_entry(tlb,ptep,address) do { } while (0)
  51. //#define tlb_start_vma(tlb,vma) do { } while (0)
  52. //FIXME - ARM32 uses this now that things changed in the kernel. seems like it may be pointless on arm26, however to get things compiling...
  53. #define tlb_start_vma(tlb,vma) \
  54. do { \
  55. if (!tlb->fullmm) \
  56. flush_cache_range(vma, vma->vm_start, vma->vm_end); \
  57. } while (0)
  58. #define tlb_end_vma(tlb,vma) do { } while (0)
  59. #define tlb_remove_page(tlb,page) free_page_and_swap_cache(page)
  60. #define pte_free_tlb(tlb,ptep) pte_free(ptep)
  61. #define pmd_free_tlb(tlb,pmdp) pmd_free(pmdp)
  62. #endif