STRUCT MOVABLE_OPERATIONS(9)
π 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 insidemigrate_page, the driver shouldn't touch thesrc->lrufield. It may write todst->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
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms