mpol_to_str(9)
π mpol_to_str β the Kernel API Manual one β¨
okay so bestie, welcome to mpol_to_str(9) from the Kernel API Manual β this is the little guy that takes a mempolicy and makes it printable. no cap, it's giving "glow-up for a struct" π
πΈ NAME πΈ
mpol_to_str β format a mempolicy structure for printing π
β¨ SYNOPSIS β¨
void mpol_to_str (char *buffer , int maxlen , struct mempolicy *pol );
π¦ ARGUMENTS π¦
bufferβ the char buffer that's gonna contain the formatted mempolicy string. it's the canvas, she's the art π¨maxlenβ length ofbuffer. yes, you gotta tell her how much room she has. be honest with her πpolβ pointer to the mempolicy that needs to be formatted. the main character, literally π
π DESCRIPTION π
So what it does: it converts pol into a string. that's the whole vibe. π«Ά
and if buffer is too short? she truncates the string. not a crash, not a meltdown, just a lil trim β but lowkey you don't want that, so listen up π
the manpage recommends a maxlen of at least 51 for the longest mode, "weighted interleave", plus the longest flag, "relative|balancing", and also so you can display at least a few node ids. that's the 51 breakdown bestie, the math is mathing π₯
ngl, if you're eyeballing your buffer size, just give her the 51. don't do her dirty with some tiny buffer and then act surprised when it truncates π
π SEE ALSO π
Kernel file ./mm/mempolicy.c, plus the whole friend group: numa_nearest_node(9), nearest_node_nodemask(9), folio_can_map_prot_numa(9), alloc_pages_mpol(9), vma_alloc_folio(9), alloc_pages(9), mpol_misplaced(9), mpol_shared_policy_init(9), mpol_parse_str(9) β iykyk, go read them, they're iconic π§
and that's the page! π
sign-off time: this one lives in ./mm π, dated October 2026 β, and yeah β she's mpol_to_str(9) through and through. mwah πβ¨
π¦ 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