_copy_mc_to_iter(9)
π _copy_mc_to_iter(9) β like, the Kernel API Manual one
okay bestie, buckle up, we're reading a man page from the Kernel API Manual section 9, and honestly? this one is kind of a baddie. it's giving "low-level memory safety with main character energy" and i'm obsessed. π¦
β¨ NAME β¨
_copy_mc_to_iter β copy to iter, but make it safe, because it handles source memory error exceptions π (yes, machine checks, we'll get there, don't panic)
πΈ SYNOPSIS πΈ
size_t _copy_mc_to_iter (const void *addr , size_t bytes , struct
iov_iter *i );
that's it. three args. she's sleek. π
π«Ά ARGUMENTS π«Ά
addrβ the source kernel address, like, where the data lives right now πbytesβ total transfer length, aka how much we're moving, fr friβ the destination iterator, the glow-up destination, the final form β¨
π₯ DESCRIPTION π₯
so here's the tea β β the pmem driver deploys this function for the dax operation (dax_copy_to_iter) for dax reads (which bypass the page-cache and the block-layer, no cap, they just go straight there π¨).
and then? upon #MC (machine check, the scary one π), read(2) aborts and returns EIO, or returns the bytes successfully copied. so worst case she still tells you what she managed to do. iconic behavior honestly π
now, the main differences between this and your typical _copy_to_iter β let me list them because there are two and both matter:
- typical tail/residue handling after a fault retries the copy byte-by-byte until the fault happens again π¬ but re-triggering machine checks is potentially fatal, so this implementation instead uses source alignment and poison alignment assumptions to avoid re-triggering hardware exceptions. like, she does NOT want to poke the bear again, and honestly? valid. π
ITER_KVECandITER_BVECcan return short copies. compare that tocopy_to_iter, where onlyITER_IOVECattempts might return a short copy. so yeah, she's built different π
β οΈ real talk: the byte-by-byte retry thing isn't just slow, re-triggering machine checks is potentially fatal β that's why the alignment assumptions exist. do not mess with that logic, bestie. π¨
π RETURN π
number of bytes copied (may be 0) β yes, zero is a possible answer, and no, that's not a vibe fail, that's just the contract π
β SEE ALSO β
all my faves from the kernel file ./lib/iov_iter.c, go give them a read, iykyk π
_copy_from_iter_flushcache(9)iov_iter_folio_queue(9)iov_iter_xarray(9)iov_iter_discard(9)import_iovec(9)iov_iter_restore(9)iov_iter_extract_pages(9)iov_iter_extract_bvecs(9)
and that's the whole page, bestie π sourced straight from ./lib, dated October 2026, and no i did not make any of that up. mwah π slay β¨
π¦ 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