list_lru_walk_one(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… list_lru_walk_one (9) β€” Kernel API Manual πŸ’…

okay bestie, welcome to the <pink>kernel API manual</pink> ✨ you're literally about to read the page for list_lru_walk_one, and honestly? it's giving "walk the LRU, isolate the freeable stuff, dispose of it" energy πŸŽ€ let's get into it.


🌸 NAME 🌸

list_lru_walk_one β€” walk a @lru, isolating and disposing freeable items. periodt πŸ’…


✨ SYNOPSIS ✨

unsigned long list_lru_walk_one (struct list_lru *lru , int nid , struct
mem_cgroup *memcg , list_lru_walk_cb isolate , void *cb_arg , unsigned
long *nr_to_walk );

like, that's the whole signature, no cap 🫢


πŸ¦‹ ARGUMENTS πŸ¦‹

  • lru β€” the lru pointer. the main character of this whole function ngl πŸ‘‘
  • nid β€” the node id you're scanning from. where we start, bestie πŸ“
  • memcg β€” the cgroup you're scanning from. yes, that one πŸ’œ
  • isolate β€” callback function that is responsible for deciding what to do with the item currently being scanned. the vibe check, essentially 🧚
  • cb_arg β€” opaque type that will be passed to isolate. it's a mystery to everyone except you, iykyk πŸ™ˆ
  • nr_to_walk β€” how many items to scan. how many to scan, mind you, more on that in a sec πŸ‘€

πŸ’– DESCRIPTION πŸ’–

so this function will scan <purple>all elements in a particular lru</purple>, calling the isolate callback for each of those items, along with the current list spinlock and a caller-provided opaque. yes, every single one of them ✨

the isolate callback can choose to drop the lock internally β€” but it *must* return with the lock held. like, that's the rule, that's the whole deal, no exceptions πŸ”₯

the callback will return an enum lru_status telling the lru infrastructure what to do with the object being scanned. it's literally the callback telling everybody else what's up πŸ“£

⚠️ bestie, please note: nr_to_walk does not mean how many objects will be freed. it means how many objects will be scanned. those are two different things and mixing them up is a whole tragedy 😭

⭐ RETURN ⭐

the number of objects effectively removed from the LRU. that's it, that's the number πŸ’…


🌈 SEE ALSO 🌈

kernel file ./include/linux/list_lru.h πŸ‘‘ plus these icons:


and that's the whole page, bestie, you ate that 🫢 this one lives over in ./include/linux, and it's dated <mint>October 2026</mint> β€” so yeah, mark your calendar, mwah πŸ’‹πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from