register_mt...ce_algorithm(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 ⭐

  • 0 on success 🌈
  • errno on 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:

  • nid specifies the memory node 🧚
  • data is 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 🌈

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