0001
0002 #ifndef _LINUX_PGALLOC_TRACK_H
0003 #define _LINUX_PGALLOC_TRACK_H
0004
0005 #if defined(CONFIG_MMU)
0006 static inline p4d_t *p4d_alloc_track(struct mm_struct *mm, pgd_t *pgd,
0007 unsigned long address,
0008 pgtbl_mod_mask *mod_mask)
0009 {
0010 if (unlikely(pgd_none(*pgd))) {
0011 if (__p4d_alloc(mm, pgd, address))
0012 return NULL;
0013 *mod_mask |= PGTBL_PGD_MODIFIED;
0014 }
0015
0016 return p4d_offset(pgd, address);
0017 }
0018
0019 static inline pud_t *pud_alloc_track(struct mm_struct *mm, p4d_t *p4d,
0020 unsigned long address,
0021 pgtbl_mod_mask *mod_mask)
0022 {
0023 if (unlikely(p4d_none(*p4d))) {
0024 if (__pud_alloc(mm, p4d, address))
0025 return NULL;
0026 *mod_mask |= PGTBL_P4D_MODIFIED;
0027 }
0028
0029 return pud_offset(p4d, address);
0030 }
0031
0032 static inline pmd_t *pmd_alloc_track(struct mm_struct *mm, pud_t *pud,
0033 unsigned long address,
0034 pgtbl_mod_mask *mod_mask)
0035 {
0036 if (unlikely(pud_none(*pud))) {
0037 if (__pmd_alloc(mm, pud, address))
0038 return NULL;
0039 *mod_mask |= PGTBL_PUD_MODIFIED;
0040 }
0041
0042 return pmd_offset(pud, address);
0043 }
0044 #endif
0045
0046 #define pte_alloc_kernel_track(pmd, address, mask) \
0047 ((unlikely(pmd_none(*(pmd))) && \
0048 (__pte_alloc_kernel(pmd) || ({*(mask)|=PGTBL_PMD_MODIFIED;0;})))?\
0049 NULL: pte_offset_kernel(pmd, address))
0050
0051 #endif