balance_dir...imited_flags(9)
π balance_dirty_pages_ratelimited_flags β a Kernel API Manual moment β¨
okay so before we even start, bestie, this is a page from the Kernel API Manual, section 9, and the star of the show is balance_dirty_pages_ratelimited_flags β yes the name is a whole entire mouthful, we love her anyway π
β¨ NAME β¨
balance_dirty_pages_ratelimited_flags β literally just Balance dirty memory state. that's it, that's the elevator pitch π«Ά
πΈ SYNOPSIS πΈ
int balance_dirty_pages_ratelimited_flags (struct address_space *mapping
, unsigned int flags );
like, she takes a mapping and some flags and hands you back an int. iconic signature ngl π
π¦ ARGUMENTS π¦
mappingβ theaddress_spacewhich was dirtied. that's the vibe, that's the thing you got messy πflagsβ BDP flags. yes they're just called BDP flags, no further notes, we move π
π DESCRIPTION π
so here's the tea. any process that's dirtying memory should call in here once for each page which was newly dirtied. one call, one freshly-dirtied page, that's the deal fr fr.
and then? the function will periodically check the system's dirty state and will initiate writeback if needed. she's like a little roomba for your dirty pages, checking in on a schedule, kicking off writeback when things get too messy β¨
also, heads up bestie β the manpage says to see balance_dirty_pages_ratelimited for details, so if you want the full lore, that's where it's at π
π RETURN π
okay so this is where it actually matters, pay attention π
- if
flagscontainsBDP_ASYNC, she may return-EAGAINβ which is the code for "memory is out of balance and the caller must wait for I/O to complete". so like, you gotta go wait, no cutting the line π - otherwise, she returns
0β and that0means either memory was already in balance, or she was able to sleep until the amount of dirty memory returned to balance. either way, balanced, slay, we love a clean exit π
β SEE ALSO β
she lives in the kernel file ./mm/page-writeback.c and she has a whole friend group, look at this roster π₯
node_dirtyable_memory(9)global_dirtyable_memory(9)domain_dirty_limits(9)global_dirty_limits(9)node_dirty_limit(9)node_dirty_ok(9)__wb_calc_thresh(9)balance_dirty_pages_ratelimited(9)wb_over_bg_thresh(9)tag_pages_for_writeback(9)writeback_iter(9)filemap_dirty_folio(9)folio_redirty_for_writepage(9)folio_mark_dirty(9)folio_wait_writeback(9)folio_wait_writeback_killable(9)folio_wait_stable(9)
all of them are (9) girls, we stan a consistent section number π
π tiny reminder that this is all coming at you from ./mm, dated October 2026, so go read the source if you need more, bestie.
mwah, go balance some dirty pages, ily, bye π§π
π¦ 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