STRUCT DEV_PAGEMAP(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ‘‘ struct dev_pagemap(9) πŸ‘‘

okay so this is a page out of the Kernel API Manual, and it's literally the blueprint for struct dev_pagemap β€” the metadata bestie for ZONE_DEVICE mappings. strap in πŸ’–


✨ NAME ✨

struct dev_pagemap β€” metadata for ZONE_DEVICE mappings. that's it, that's the vibe 🫢


🌸 SYNOPSIS 🌸

here's the whole struct, character for character, no cap:

struct dev_pagemap {
    struct vmem_altmap altmap;
    struct percpu_ref ref;
    struct completion done;
    enum memory_type type;
    unsigned int flags;
    unsigned long vmemmap_shift;
    const struct dev_pagemap_ops *ops;
    void *owner;
    int nr_range;
    union {
      struct range range;
      struct range  ranges[];
    };
 };

πŸ’… Members πŸ’…

every single field, explained, because we don't skip ✨

  • altmap β€” pre-allocated/reserved memory for vmemmap allocations. it's the reserved little stash πŸŽ€
  • ref β€” reference count that pins the devm_memremap_pages mapping. keeps it alive, main character energy πŸ”₯
  • done β€” completion for ref. when ref is finished, this is how you know πŸ‘€
  • type β€” memory type: see MEMORY_* above in memremap.h. iykyk πŸ“–
  • flags β€” PGMAP_* flags to specify defailed behavior. (their spelling, not mine bestie πŸ’€)
  • vmemmap_shift β€” structural definition of how the vmemmap page metadata is populated, specifically the metadata page order. a zero value (that's the default) uses base pages as the vmemmap metadata representation. a bigger value will set up compound struct pages of the requested order value. so like, order matters ⭐
  • ops β€” method table. the whole friend group of functions πŸ’œ
  • owner β€” an opaque pointer identifying the entity that manages this instance. used by various helpers to make sure that no foreign ZONE_DEVICE memory is accessed. protecting the group chat from randos πŸ™ˆ
  • nr_range β€” number of ranges to be mapped πŸ”’
  • {unnamed_union} β€” anonymous. she has no name but she serves πŸ‘‘
  • range β€” range to be mapped when nr_range == 1 ☝️
  • ranges β€” array of ranges to be mapped when nr_range > 1 🌈

πŸ¦‹ SEE ALSO πŸ¦‹

  • Kernel file ./include/linux/memremap.h
  • struct vmem_altmap(9)

ngl, if you're poking at ZONE_DEVICE mappings without reading the members list first, that's a vibe check you will fail 😭 read them all, fr fr.

and that's the page, bestie πŸ’– this cutie came from ./include/linux, dated October 2026, straight out of the Kernel API Manual β€” struct dev_pagemap(9), periodt. πŸŽ€βœ¨

πŸ“¦ where this page comes from