clean_cache_range(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– clean_cache_range(9) πŸ’–

okay so bestie, this one's a lil kernel API page from the Kernel API Manual, section 9 β€” the deep magic zone 🧚✨. it's called clean_cache_range and it is literally the "bestie, please flush your cache" of the x86 world. ngl, it's a short one, so we're gonna get through it together, mwah πŸ’…


🌸 NAME 🌸

clean_cache_range β€” write back a cache range with CLWB. that's it. that's the whole vibe. 🫢


✨ SYNOPSIS ✨

void clean_cache_range (void *addr , size_t size );

copy it exactly like that, spacing and all β€” no cap, do not "fix" the spaces, the manpage said what it said πŸŽ€


πŸ¦‹ ARGUMENTS πŸ¦‹

  • addr β€” the virtual start address. like, where the party begins πŸ“
  • size β€” number of bytes to write back. how much of the party we're cleaning up after 🧹

πŸ’œ DESCRIPTION πŸ’œ

so what does it actually do? it writes back a cache range using the CLWB (cache line write back) instruction. iconic. that's the whole job, and it does it well πŸ‘‘

and here's the lil detail you cannot skip, bestie β€” size is internally rounded up to be cache line size aligned. so if you hand it a number that isn't cache-line-sized, it's not gonna be messy about it, it just rounds up for you. lowkey thoughtful of it ngl 🌈

heads up: because of that rounding, the function may be working with a slightly bigger range than the size you actually passed in. that's the documented behaviour, so don't come for me, i'm just the messenger 😭

πŸŽ€ SEE ALSO πŸŽ€

  • Kernel file ./arch/x86/lib/usercopy_64.c β€” go read the source, iykyk πŸ“–βœ¨

and that's the whole page! πŸ“ short, sweet, slays. this one comes to you from ./arch/x86/lib and it's dated October 2026 β€” so remember that era, bestie, and go write back some cache lines πŸ’–πŸ”₯πŸ‘‘

πŸ“¦ where this page comes from