STRUCT PTDESC(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ NAME ✨

okay so bestie, this is struct ptdesc(9) from the Kernel API Manual β€” literally the Memory descriptor for page tables. That’s the whole vibe. πŸ’…


🧚 SYNOPSIS 🧚

Here’s the full struct, exactly as it appears, because we do not mess with C source in this group chat:

struct ptdesc {
    memdesc_flags_t pt_flags;
    union {
      struct rcu_head pt_rcu_head;
      struct list_head pt_list;
      struct {
        unsigned long _pt_pad_1;
        pgtable_t pmd_huge_pte;
      };
    };
    unsigned long __page_mapping;
    union {
      pgoff_t pt_index;
      struct mm_struct *pt_mm;
      atomic_t pt_frag_refcount;
  #ifdef CONFIG_HUGETLB_PMD_PAGE_TABLE_SHARING;
      atomic_t pt_share_count;
  #endif;
    };
    union {
      unsigned long _pt_pad_2;
  #if ALLOC_SPLIT_PTLOCKS;
      spinlock_t *ptl;
  #else;
      spinlock_t ptl;
  #endif;
    };
    unsigned int __page_type;
    atomic_t __page_refcount;
  #ifdef CONFIG_MEMCG;
    unsigned long pt_memcg_data;
  #endif;
 };

πŸ‘― Members πŸ‘―

okay, meet the cast β€” every single member, no skips, no β€œwe’ll come back to it later” energy:

  • pt_flags β€” enum pt_flags plus zone/node/section.
  • {unnamed_union} β€” anonymous.
  • pt_rcu_head β€” For freeing page table pages.
  • pt_list β€” List of used page tables. Used for s390 gmap shadow pages (which are not linked into the user page tables) and x86 pgds.
  • {unnamed_struct} β€” anonymous.
  • _pt_pad_1 β€” Padding that aliases with page's compound head.
  • pmd_huge_pte β€” Protected by ptdesc->ptl, used for THPs.
  • __page_mapping β€” Aliases with page->mapping. Unused for page tables.
  • {unnamed_union} β€” anonymous.
  • pt_index β€” Used for s390 gmap.
  • pt_mm β€” Used for x86 pgds.
  • pt_frag_refcount β€” For fragmented page table tracking. Powerpc only.
  • pt_share_count β€” Used for HugeTLB PMD page table share count.
  • {unnamed_union} β€” anonymous.
  • _pt_pad_2 β€” Padding to ensure proper alignment.
  • ptl β€” Lock for the page table.
  • ptl β€” Lock for the page table.
  • __page_type β€” Same as page->page_type. Unused for page tables.
  • __page_refcount β€” Same as page refcount.
  • pt_memcg_data β€” Memcg data. Tracked for page tables here.

πŸ’– Description πŸ’–

This struct overlays struct page for now. Do not modify without a good understanding of the issues.

bestie, that is a real warning β€” do not just roll up and start changing things unless you actually understand the issues. like, fr fr. πŸ’€

πŸ”— SEE ALSO πŸ”—

Kernel file ./include/linux/mm_types.h β€” also go peek at softleaf_t(9), struct folio(9), vm_fault_t(9), enum vm_fault_reason(9), and enum fault_flag(9). iykyk πŸ¦‹

✨ cute little sign-off: source/version ./include/linux, date October 2026, page struct ptdesc(9) β€” bye bestie, slay responsibly πŸ’–πŸŽ€
πŸ“¦ where this page comes from