pgalloc.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #ifndef __ASM_SH_PGALLOC_H
  2. #define __ASM_SH_PGALLOC_H
  3. #include <linux/quicklist.h>
  4. #include <asm/page.h>
  5. #define QUICK_PT 1 /* Other page table pages that are zero on free */
  6. #ifdef CONFIG_PGTABLE_LEVELS_3
  7. #include <asm/pgalloc_pmd.h>
  8. #else
  9. #include <asm/pgalloc_nopmd.h>
  10. #endif
  11. static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
  12. pte_t *pte)
  13. {
  14. set_pmd(pmd, __pmd((unsigned long)pte));
  15. }
  16. static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
  17. pgtable_t pte)
  18. {
  19. set_pmd(pmd, __pmd((unsigned long)page_address(pte)));
  20. }
  21. #define pmd_pgtable(pmd) pmd_page(pmd)
  22. /*
  23. * Allocate and free page tables.
  24. */
  25. static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
  26. unsigned long address)
  27. {
  28. return quicklist_alloc(QUICK_PT, GFP_KERNEL | __GFP_REPEAT, NULL);
  29. }
  30. static inline pgtable_t pte_alloc_one(struct mm_struct *mm,
  31. unsigned long address)
  32. {
  33. struct page *page;
  34. void *pg;
  35. pg = quicklist_alloc(QUICK_PT, GFP_KERNEL | __GFP_REPEAT, NULL);
  36. if (!pg)
  37. return NULL;
  38. page = virt_to_page(pg);
  39. pgtable_page_ctor(page);
  40. return page;
  41. }
  42. static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
  43. {
  44. quicklist_free(QUICK_PT, NULL, pte);
  45. }
  46. static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
  47. {
  48. pgtable_page_dtor(pte);
  49. quicklist_free_page(QUICK_PT, NULL, pte);
  50. }
  51. #define __pte_free_tlb(tlb,pte,addr) \
  52. do { \
  53. pgtable_page_dtor(pte); \
  54. tlb_remove_page((tlb), (pte)); \
  55. } while (0)
  56. static inline void check_pgt_cache(void)
  57. {
  58. __check_pgt_cache();
  59. quicklist_trim(QUICK_PT, NULL, 25, 16);
  60. }
  61. #endif /* __ASM_SH_PGALLOC_H */