register_mt...ce_algorithm(9)
π register_mt_adistance_algorithm(9) β the kernel API manual, but make it make sense
okay so bestie, welcome to the Kernel API Manual page for register_mt_adistance_algorithm β¨ this is the one you go to when you've written a memory tiering abstract distance algorithm and you need the kernel to ~actually know about it~ π
β¨ NAME β¨
register_mt_adistance_algorithm β register a memory tiering abstract distance algorithm π¦
πΈ SYNOPSIS πΈ
int register_mt_adistance_algorithm (struct notifier_block *nb );
that's it, that's the whole vibe check π
π«Ά ARGUMENTS π«Ά
nbβ the notifier block that describes your algorithm. it's giving "here's my whole personality, kernel" π
β RETURN β
0on success πerrnoon error π
no in-between, no "it depends", periodt β¨
π DESCRIPTION π
so every memory tiering abstract distance algorithm provider needs to register its algorithm with register_mt_adistance_algorithm β like, that's the whole ritual, no cap π―οΈ
when the kernel needs to calculate the abstract distance for a specified memory node, your notifier function gets called β unless some high priority algorithm has already provided a result (in which case, respectfully, you don't get the aux π).
the prototype of the notifier function is literally this:
int (*algorithm_notifier)(struct notifier_block *nb, unsigned long nid, void *data);
where:
nidspecifies the memory node π§datais the pointer to the returned abstract distance β that is,int *adistπ₯
here's the important bit, bestie, listen up: if your algorithm provides the result, you should return NOTIFY_STOP β like, you're done, drop the mic, everyone else can go home π
otherwise, return return_value & NOTIFY_STOP_MASK == 0 so the next algorithm in the chain gets a chance to provide the result πΈ iykyk
fr fr do not sleep on that mask check β it's literally the difference between "I got this" and "next bestie, you're up" π«Ά
π SEE ALSO π
- Kernel file
./mm/memory-tiers.c folio_use_access_time(9)next_demotion_node(9)unregister_mt_adistance_algorithm(9)mt_calc_adistance(9)
like, read them, they're all iconic in their own way π
and that's the whole page, diva π this came out of ./mm with the October 2026 date attached, so go forth and register your algorithm β the kernel is literally waiting for your main character energy πβ¨π
π¦ 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