pgalloc-track.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _LINUX_PGALLLC_TRACK_H
  3. #define _LINUX_PGALLLC_TRACK_H
  4. #if defined(CONFIG_MMU)
  5. static inline p4d_t *p4d_alloc_track(struct mm_struct *mm, pgd_t *pgd,
  6. unsigned long address,
  7. pgtbl_mod_mask *mod_mask)
  8. {
  9. if (unlikely(pgd_none(*pgd))) {
  10. if (__p4d_alloc(mm, pgd, address))
  11. return NULL;
  12. *mod_mask |= PGTBL_PGD_MODIFIED;
  13. }
  14. return p4d_offset(pgd, address);
  15. }
  16. static inline pud_t *pud_alloc_track(struct mm_struct *mm, p4d_t *p4d,
  17. unsigned long address,
  18. pgtbl_mod_mask *mod_mask)
  19. {
  20. if (unlikely(p4d_none(*p4d))) {
  21. if (__pud_alloc(mm, p4d, address))
  22. return NULL;
  23. *mod_mask |= PGTBL_P4D_MODIFIED;
  24. }
  25. return pud_offset(p4d, address);
  26. }
  27. static inline pmd_t *pmd_alloc_track(struct mm_struct *mm, pud_t *pud,
  28. unsigned long address,
  29. pgtbl_mod_mask *mod_mask)
  30. {
  31. if (unlikely(pud_none(*pud))) {
  32. if (__pmd_alloc(mm, pud, address))
  33. return NULL;
  34. *mod_mask |= PGTBL_PUD_MODIFIED;
  35. }
  36. return pmd_offset(pud, address);
  37. }
  38. #endif /* CONFIG_MMU */
  39. #define pte_alloc_kernel_track(pmd, address, mask) \
  40. ((unlikely(pmd_none(*(pmd))) && \
  41. (__pte_alloc_kernel(pmd) || ({*(mask)|=PGTBL_PMD_MODIFIED;0;})))?\
  42. NULL: pte_offset_kernel(pmd, address))
  43. #endif /* _LINUX_PGALLLC_TRACK_H */