pgalloc.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #ifndef _PPC64_PGALLOC_H
  2. #define _PPC64_PGALLOC_H
  3. #include <linux/mm.h>
  4. #include <linux/slab.h>
  5. #include <linux/cpumask.h>
  6. #include <linux/percpu.h>
  7. extern kmem_cache_t *zero_cache;
  8. /*
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version
  12. * 2 of the License, or (at your option) any later version.
  13. */
  14. static inline pgd_t *
  15. pgd_alloc(struct mm_struct *mm)
  16. {
  17. return kmem_cache_alloc(zero_cache, GFP_KERNEL);
  18. }
  19. static inline void
  20. pgd_free(pgd_t *pgd)
  21. {
  22. kmem_cache_free(zero_cache, pgd);
  23. }
  24. #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
  25. static inline pmd_t *
  26. pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
  27. {
  28. return kmem_cache_alloc(zero_cache, GFP_KERNEL|__GFP_REPEAT);
  29. }
  30. static inline void
  31. pmd_free(pmd_t *pmd)
  32. {
  33. kmem_cache_free(zero_cache, pmd);
  34. }
  35. #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, pte)
  36. #define pmd_populate(mm, pmd, pte_page) \
  37. pmd_populate_kernel(mm, pmd, page_address(pte_page))
  38. static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
  39. {
  40. return kmem_cache_alloc(zero_cache, GFP_KERNEL|__GFP_REPEAT);
  41. }
  42. static inline struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address)
  43. {
  44. pte_t *pte = kmem_cache_alloc(zero_cache, GFP_KERNEL|__GFP_REPEAT);
  45. if (pte)
  46. return virt_to_page(pte);
  47. return NULL;
  48. }
  49. static inline void pte_free_kernel(pte_t *pte)
  50. {
  51. kmem_cache_free(zero_cache, pte);
  52. }
  53. static inline void pte_free(struct page *ptepage)
  54. {
  55. kmem_cache_free(zero_cache, page_address(ptepage));
  56. }
  57. struct pte_freelist_batch
  58. {
  59. struct rcu_head rcu;
  60. unsigned int index;
  61. struct page * pages[0];
  62. };
  63. #define PTE_FREELIST_SIZE ((PAGE_SIZE - sizeof(struct pte_freelist_batch)) / \
  64. sizeof(struct page *))
  65. extern void pte_free_now(struct page *ptepage);
  66. extern void pte_free_submit(struct pte_freelist_batch *batch);
  67. DECLARE_PER_CPU(struct pte_freelist_batch *, pte_freelist_cur);
  68. void __pte_free_tlb(struct mmu_gather *tlb, struct page *ptepage);
  69. #define __pmd_free_tlb(tlb, pmd) __pte_free_tlb(tlb, virt_to_page(pmd))
  70. #define check_pgt_cache() do { } while (0)
  71. #endif /* _PPC64_PGALLOC_H */