0001
0002 #ifndef _ASM_POWERPC_PGALLOC_H
0003 #define _ASM_POWERPC_PGALLOC_H
0004
0005 #include <linux/mm.h>
0006
0007 #ifndef MODULE
0008 static inline gfp_t pgtable_gfp_flags(struct mm_struct *mm, gfp_t gfp)
0009 {
0010 if (unlikely(mm == &init_mm))
0011 return gfp;
0012 return gfp | __GFP_ACCOUNT;
0013 }
0014 #else
0015 static inline gfp_t pgtable_gfp_flags(struct mm_struct *mm, gfp_t gfp)
0016 {
0017 return gfp | __GFP_ACCOUNT;
0018 }
0019 #endif
0020
0021 #define PGALLOC_GFP (GFP_KERNEL | __GFP_ZERO)
0022
0023 pte_t *pte_fragment_alloc(struct mm_struct *mm, int kernel);
0024
0025 static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm)
0026 {
0027 return (pte_t *)pte_fragment_alloc(mm, 1);
0028 }
0029
0030 static inline pgtable_t pte_alloc_one(struct mm_struct *mm)
0031 {
0032 return (pgtable_t)pte_fragment_alloc(mm, 0);
0033 }
0034
0035 void pte_frag_destroy(void *pte_frag);
0036 void pte_fragment_free(unsigned long *table, int kernel);
0037
0038 static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
0039 {
0040 pte_fragment_free((unsigned long *)pte, 1);
0041 }
0042
0043 static inline void pte_free(struct mm_struct *mm, pgtable_t ptepage)
0044 {
0045 pte_fragment_free((unsigned long *)ptepage, 0);
0046 }
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062 #define MAX_PGTABLE_INDEX_SIZE 0xf
0063
0064 extern struct kmem_cache *pgtable_cache[];
0065 #define PGT_CACHE(shift) pgtable_cache[shift]
0066
0067 #ifdef CONFIG_PPC_BOOK3S
0068 #include <asm/book3s/pgalloc.h>
0069 #else
0070 #include <asm/nohash/pgalloc.h>
0071 #endif
0072
0073 #endif