discard_a_page(9)
π discard_a_page(9) β like, the Kernel API Manual page, bestie
okay so this is discard_a_page from the Kernel API Manual, and honestly? it's the opening move of throwing a page away. the beginning of the discard journey. main character energy for a cleanup routine β¨
πΈ SYNOPSIS πΈ
void discard_a_page (struct vdo_page_cache *cache );
that's it. one function, one arg, void return, no cap. π«Ά
π ARGUMENTS π
cacheβ the page cache. yes, the page cache. that's the whole vibe check on this one π
π¦ DESCRIPTION π¦
so here's the tea β β if there's, like, no page that's discardable, this function bumps up a count of deferred frees. why? so that the next time a page gets released and it's no longer busy, it'll kick off another whole discard cycle. basically a little nudge note to future-you π
and what does that count mean, you ask? it's an indication that the cache is not big enough. literally the cache sending you a hint. disrespectful but valid π
now, if the selected page is not dirty? the function immediately allocates that page to the oldest completion waiting for a free page. first come, first served, we love a fair queue π
no cap, keep both of these behaviours in mind β one path defers, the other path hands the page straight to whoever's been waiting the longest. two totally different vibes from one tiny function π
β SEE ALSO β
the whole friend group, fr fr. first up the file it lives in:
- Kernel file
./drivers/md/dm-vdo/block-map.c
then the squad, in the exact order the manual lists them:
- Block map eras(9)
- initialize_info(9)
- allocate_cache_components(9)
- assert_on_cache_thread(9)
- get_page_state_name(9)
- update_counter(9)
- set_info_state(9)
- find_free_page(9)
- find_page(9)
- select_lru_page(9)
- complete_with_page(9)
- complete_waiter_with_error(9)
- complete_waiter_with_page(9)
- distribute_page_over_waitq(9)
- set_persistent_error(9)
- validate_completed_page(9)
- handle_load_error(9)
- page_is_loaded(9)
- handle_rebuild_read_error(9)
- launch_page_load(9)
- schedule_page_save(9)
- launch_page_save(9)
- completion_needs_page(9)
- allocate_free_page(9)
- discard_page_if_needed(9)
- write_has_finished(9)
- handle_page_write_error(9)
- page_is_written_out(9)
- write_pages(9)
- vdo_release_page_completion(9)
- vdo_get_page(9)
- vdo_request_page_write(9)
- vdo_get_cached_page(9)
- vdo_invalidate_page_cache(9)
- get_tree_page_by_index(9)
- in_cyclic_range(9)
- is_not_older(9)
- add_to_dirty_lists(9)
- vdo_find_block_map_slot(9)
- make_forest(9)
- replace_forest(9)
- finish_cursor(9)
- continue_traversal(9)
- finish_traversal_load(9)
- traverse(9)
- launch_cursor(9)
- compute_boundary(9)
- vdo_traverse_forest(9)
- initialize_block_map_zone(9)
- clear_mapped_location(9)
- set_mapped_location(9)
like, that's the entire group chat and every single one of them is iconic π
and that's the page, bestie! π§ this lil beauty comes from ./drivers/md/dm-vdo, dated October 2026, and it's filed under discard_a_page(9). go read some more kernel docs, you're doing amazing πβ¨
π¦ 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