pgalloc.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 0 /* Other page table pages that are zero on free */
  6. extern pgd_t *pgd_alloc(struct mm_struct *);
  7. extern void pgd_free(struct mm_struct *mm, pgd_t *pgd);
  8. #if PAGETABLE_LEVELS > 2
  9. extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
  10. extern pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address);
  11. extern void pmd_free(struct mm_struct *mm, pmd_t *pmd);
  12. #endif
  13. static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
  14. pte_t *pte)
  15. {
  16. set_pmd(pmd, __pmd((unsigned long)pte));
  17. }
  18. static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
  19. pgtable_t pte)
  20. {
  21. set_pmd(pmd, __pmd((unsigned long)page_address(pte)));
  22. }
  23. #define pmd_pgtable(pmd) pmd_page(pmd)
  24. /*
  25. * Allocate and free page tables.
  26. */
  27. static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
  28. unsigned long address)
  29. {
  30. return quicklist_alloc(QUICK_PT, GFP_KERNEL, NULL);
  31. }
  32. static inline pgtable_t pte_alloc_one(struct mm_struct *mm,
  33. unsigned long address)
  34. {
  35. struct page *page;
  36. void *pg;
  37. pg = quicklist_alloc(QUICK_PT, GFP_KERNEL, NULL);
  38. if (!pg)
  39. return NULL;
  40. page = virt_to_page(pg);
  41. if (!pgtable_page_ctor(page)) {
  42. quicklist_free(QUICK_PT, NULL, pg);
  43. return NULL;
  44. }
  45. return page;
  46. }
  47. static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
  48. {
  49. quicklist_free(QUICK_PT, NULL, pte);
  50. }
  51. static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
  52. {
  53. pgtable_page_dtor(pte);
  54. quicklist_free_page(QUICK_PT, NULL, pte);
  55. }
  56. #define __pte_free_tlb(tlb,pte,addr) \
  57. do { \
  58. pgtable_page_dtor(pte); \
  59. tlb_remove_page((tlb), (pte)); \
  60. } while (0)
  61. static inline void check_pgt_cache(void)
  62. {
  63. quicklist_trim(QUICK_PT, NULL, 25, 16);
  64. }
  65. #endif /* __ASM_SH_PGALLOC_H */