list_lru_count_one(9)
β¨ list_lru_count_one β¨
okay bestie, so this one's a kernel API manual page (man 9 energy, very β¨kernelβ¨), and it's literally about counting stuff on an LRU list. that's it. that's the vibe. π
πΈ NAME πΈ
list_lru_count_one β return the number of objects currently held by @lru
like, it counts the objects. on the lru. one of them. iconic honestly π
π¦ SYNOPSIS π¦
unsigned long list_lru_count_one (struct list_lru *lru , int nid ,
struct mem_cgroup *memcg );
yes the spacing is exactly like that, don't come for me, that's just how the page is written π
π ARGUMENTS π
lruβ the lru pointer. yes. it's the lru. that's the whole description. thestruct list_lruyou're counting from π«Άnidβ the node id to count from. so like, which NUMA node you wanna peek at βmemcgβ the cgroup to count from. scoping it down to one memory cgroup, slay πΈ
π₯ DESCRIPTION π₯
okay so here's the tea, and it's important, don't skip it π
there is no guarantee that the list is not updated while the count is being computed. like, the list can literally be changing out from under you mid-count. it's giving "living document" but make it a kernel data structure π
so if you're a caller that wants such a guarantee (a stable, trustworthy number, no funny business), you need to provide an outer lock. that's on you, not on this function. the function is just gonna vibe and hand you a number π
btw this is a real caveat, not me being dramatic. no outer lock = no guarantee. periodt.
π RETURN π
0for empty lists π- otherwise, the number of objects currently held by
lruβ¨
so like, zero means empty, anything else is a real count. cute and simple fr fr π
π SEE ALSO π
kernel file ./include/linux/list_lru.h, plus the whole friend group:
folio_memcg_list_lru_alloc(9)list_lru_lock(9)list_lru_unlock(9)list_lru_add(9)list_lru_add_obj(9)list_lru_del(9)list_lru_del_obj(9)list_lru_walk_one(9)list_lru_walk_one_irq(9)
go read those too, iykyk π§
and that's the whole page, bestie!! brought to you by the lovely people over in ./include/linux, version dated October 2026 β mwah, tysm for the lore, catch you in the next man page πβ¨π
π¦ 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