do_brk_flags(9)
β¨ do_brk_flags(9) β¨
okay so this is a page straight out of the Kernel API Manual bestie, and it's all about do_brk_flags β the little function that says "hey, can we make the brk vma a bit bigger?" but only if the flags line up. lowkey iconic behaviour tbh π
π¦ NAME π¦
do_brk_flags β Increase the brk vma if the flags match.
like, that's the whole vibe. if the flags don't match? bestie, we're doing something else (spoiler: we make a new one, keep reading π).
πΈ SYNOPSIS πΈ
int do_brk_flags (struct vma_iterator *vmi , struct vm_area_struct *vma
, unsigned long addr , unsigned long len , vma_flags_t vma_flags );
five arguments, one int coming back at you. no cap π«Ά
π ARGUMENTS π
vmiβ The vma iterator. it's the little tour guide walking through your vmas π§vmaβ The vma, (yes the original literally has that comma, we love a typo moment, keeping it exactly as-is π)addrβ The start address. where the party begins β¨lenβ The length of the increase. how much bigger we're going πvma_flagsβ The VMA Flags. the vibe check of this whole operation, fr fr π
π DESCRIPTION π
so here's the tea: it extends the brk VMA from addr to addr + len. that's the main character move π
but β and this is the important part β if the VMA is NULL or the flags do not match, then it creates a new anonymous VMA. so it's not gonna just force the extension through, it switches lanes and makes something fresh instead. no drama, just facts π¦
and then there's this lil note: Eventually we may be able to do some brk-specific accounting here. so like, future potential, nothing confirmed, we're just manifesting it β¨ (please don't read that as a promise, it's literally a "maybe someday" π)
β RETURN β
0 on success, or otherwise an error. that's it, that's the whole return section β short and slay π
π₯ SEE ALSO π₯
Kernel file ./mm/vma.c and its besties:
go read them, iykyk ππ
ok genuine reminder bestie: NULL vma or mismatched flags means a new anonymous VMA gets created β not an error, just a different path. don't @ me, that's literally what the page says π
and that's a wrap on do_brk_flags(9) from the ./mm corner of the world, dated October 2026 π tysm for reading, go touch some vmas (responsibly) ππ«Άβ¨
π¦ 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