list_lru_count_one(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ 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. the struct list_lru you'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 πŸ‘‘

  • 0 for 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:

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