STRUCT MOVABLE_OPERATIONS(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… struct movable_operations(9) β€” the kernel API manual, but make it make sense

okay so bestie, welcome to the Kernel API Manual ✨ today's main character is struct movable_operations, and it's literally all about driver page migration. yes, that kind of migration β€” moving pages around in memory, not birds flying south πŸ¦‹


🌸 NAME

struct movable_operations β€” Driver page migration. that's it, that's the vibe. πŸ’–


✨ SYNOPSIS

here's the struct in all its glory, copy it exactly, no cap:

struct movable_operations {
    bool (*isolate_page)(struct page *, isolate_mode_t);
    int (*migrate_page)(struct page *dst, struct page *src, enum
migrate_mode);
    void (*putback_page)(struct page *);
 };

three function pointers, three little jobs, one iconic struct. πŸ‘‘


πŸŽ€ Members

πŸ’… isolate_page

The VM calls this function to prepare the page to be moved. 🚚

The page is locked and the driver should not unlock it β€” hands off the lock, bestie, it's not yours πŸ”’.

The driver should return true if the page is movable and false if it is not currently movable.

⚠️ Listen up: after this function returns, the VM uses the page->lru field, so the driver must preserve any information which is usually stored there. do not lose that data, i'm begging 🫢

πŸ”₯ migrate_page

After isolation, the VM calls this function with the isolated src page.

The driver should copy the contents of the src page to the dst page and set up the fields of the dst page. Both pages are locked. πŸ”

Return values, because this matters:

  • If page migration is successful, the driver should return 0. slay ✨
  • If the driver cannot migrate the page at the moment, it can return -EAGAIN. The VM interprets this as a temporary migration failure and will retry it later. πŸŒ€
  • Any other error value is a permanent migration failure and migration will not be retried. πŸ’€
🚨 and while you're inside migrate_page, the driver shouldn't touch the src->lru field. It may write to dst->lru. that's the line, don't cross it πŸ™ˆ

🧚 putback_page

If migration fails on the isolated page, the VM informs the driver that the page is no longer a candidate for migration by calling this function.

The driver should put the isolated page back into its own data structure. like, put it back where you found it, respectfully πŸŽ€


πŸ‘€ SEE ALSO

Kernel file ./include/linux/migrate.h β€” go read it, iykyk πŸ“–


okay that's the whole page, you ate that πŸ’–πŸ¦‹ this lil manual lives in ./include/linux and it's dated October 2026, so mark your calendars bestie, and remember: struct movable_operations is the blueprint, the driver does the actual work. periodt. πŸ‘‘πŸŒΈ

πŸ“¦ where this page comes from