list_lru_del(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… list_lru_del β€” deleting things from the LRU list, but make it a whole vibe ✨

okay bestie, so this is a page from the Kernel API Manual, and we're talking about list_lru_del(9) β€” your new favorite way to take an element OUT of the lru list. no cap, it's lowkey iconic. πŸŽ€


🌸 NAME 🌸

list_lru_del β€” delete an element from the lru list. literally that's it, she does one thing and she does it well πŸ’–


✨ SYNOPSIS ✨

bool list_lru_del (struct list_lru *lru , struct list_head *item , int
nid , struct mem_cgroup *memcg );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • lru β€” the lru pointer. main character energy tbh 🫢
  • item β€” the item to be deleted. bye bestie πŸ‘‹
  • nid β€” the node id of the sublist to delete the item from. gotta know which sublist we're dealing with πŸ’…
  • memcg β€” the cgroup of the sublist to delete the item from. keep up with the groups fr fr

πŸ”₯ DESCRIPTION πŸ”₯

So this function works analogously as list_lru_add in terms of list manipulation. same vibe, opposite direction, iykyk πŸ’œ

And here's the tea: the comments in list_lru_add about an element already being in a list are also valid for list_lru_del. that means you can delete an item that has already been removed or never been added. chaotic but it's fine, no notes 😭

BUT (yes there's a but, there's always a but πŸ™ˆ) β€” if the item is in a list, it must be in this list, and you must pass the right value of nid and memcg so that the right sublist is used. wrong sublist = wrong vibe = not slay πŸ’€

Now listen up because this part matters: you must ensure that the memcg is not freed during this call (e.g., with rcu or by taking a css refcnt). this is not the moment to get sloppy, bestie 🚨

When a memcg is deleted, list_lru entries are automatically moved to the parent memcg. This is done in a race-free way, so during deletion of an memcg both the old and new memcg will resolve to the same sublist internally. like a glow-up where the old and new version are secretly the same girlie β€” iconic behavior 🌈


⭐ RETURN ⭐

  • true if the list was updated πŸŽ‰
  • false otherwise πŸ™ƒ

🧚 SEE ALSO 🧚

Kernel file ./include/linux/list_lru.h and its whole friend group:


okay that's the whole page, go forth and delete responsibly πŸ“πŸ’…

from ./include/linux β€” October 2026 edition β€” mwah, ily, see u in the kernel 🫢✨

πŸ“¦ where this page comes from