memory_failure(9)
π memory_failure(9) π
ok so you're reading the Kernel API Manual bestie, and this is the page for memory_failure(9) β literally the function that handles a memory failure of a page. yes THAT kind of failure. the hardware kind. buckle up π
β¨ NAME β¨
memory_failure β Handle memory failure of a page. that's it, that's the whole vibe. when a page goes bad, this is the girl they call π
β¨ SYNOPSIS β¨
int memory_failure (unsigned long pfn , int flags );
like, it takes two things and returns an int. concise. iconic. no notes π
β¨ ARGUMENTS β¨
pfnβ Page Number of the corrupted page. that's the address of the page that's gone bad π the one having a whole crisis.flagsβ fine tune action taken. itty bitty knobs to nudge how it behaves, iykyk ποΈ
β¨ DESCRIPTION β¨
okay so picture this π«Ά β the low level machine check code of an architecture notices that hardware memory corruption happened on a page. and then it calls this function. and memory_failure tries its best to recover, which β ngl β includes dropping pages, killing processes etc. like, it's doing the absolute most to save the day, and sometimes the day gets saved by literally ending a process π no cap.
this function is primarily of use for corruptions that happen outside the current execution context β for example when a background scrubber detects it π§Ήβ¨ (scrubber said "not on my watch").
π¨ IMPORTANT VIBE CHECK: this must run in process context (e.g. a work queue) with interrupts enabled and no spinlocks held. do not try this from a spinlock bestie, it will not slay, it will not go well π
β¨ RETURN β¨
so the return values are giving a whole spectrum, let's go through them one by one:
0β success π periodt.-ENXIOβ memory not managed by the kernel. not our page, not our problem π«₯-EOPNOTSUPPβhwpoison_filterfiltered the error event. the bouncer said no β-EHWPOISONβ the page was already poisoned, potentially kill process. she's already been through it π maybe someone's getting killed over it, lowkey.- other negative values β failure. yeah. just... failure. π
β¨ SEE ALSO β¨
go read these next, fr fr, they're the rest of the friend group π―ββοΈ:
- Kernel file
./mm/memory-failure.c MF_ATTR_RO(9)get_hwpoison_page(9)mf_dax_kill_procs(9)memory_failure_pfn(9)memory_failure_queue(9)unpoison_memory(9)soft_offline_page(9)
okay that's the whole page!! this came from ./mm and it's dated October 2026 πΈ so yeah, that's the source, that's the version, that's the date β mwah, go forth and handle those failures bestie π¦β¨π
π¦ 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