tlb.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. #include <asm/pgalloc.h>
  22. /*
  23. * TLB handling. This allows us to remove pages from the page
  24. * tables, and efficiently handle the TLB issues.
  25. */
  26. struct mmu_gather {
  27. struct mm_struct *mm;
  28. unsigned int fullmm;
  29. };
  30. DECLARE_PER_CPU(struct mmu_gather, mmu_gathers);
  31. static inline struct mmu_gather *
  32. tlb_gather_mmu(struct mm_struct *mm, unsigned int full_mm_flush)
  33. {
  34. struct mmu_gather *tlb = &get_cpu_var(mmu_gathers);
  35. tlb->mm = mm;
  36. tlb->fullmm = full_mm_flush;
  37. return tlb;
  38. }
  39. static inline void
  40. tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end)
  41. {
  42. if (tlb->fullmm)
  43. flush_tlb_mm(tlb->mm);
  44. /* keep the page table cache within bounds */
  45. check_pgt_cache();
  46. put_cpu_var(mmu_gathers);
  47. }
  48. #define tlb_remove_tlb_entry(tlb,ptep,address) do { } while (0)
  49. /*
  50. * In the case of tlb vma handling, we can optimise these away in the
  51. * case where we're doing a full MM flush. When we're doing a munmap,
  52. * the vmas are adjusted to only cover the region to be torn down.
  53. */
  54. static inline void
  55. tlb_start_vma(struct mmu_gather *tlb, struct vm_area_struct *vma)
  56. {
  57. if (!tlb->fullmm)
  58. flush_cache_range(vma, vma->vm_start, vma->vm_end);
  59. }
  60. static inline void
  61. tlb_end_vma(struct mmu_gather *tlb, struct vm_area_struct *vma)
  62. {
  63. if (!tlb->fullmm)
  64. flush_tlb_range(vma, vma->vm_start, vma->vm_end);
  65. }
  66. #define tlb_remove_page(tlb,page) free_page_and_swap_cache(page)
  67. #define pte_free_tlb(tlb,ptep) pte_free(ptep)
  68. #define pmd_free_tlb(tlb,pmdp) pmd_free(pmdp)
  69. #define tlb_migrate_finish(mm) do { } while (0)
  70. #endif