lc_get(9)
lc_get(9) π
okay so welcome to the Kernel API Manual, bestie β this is the lc_get(9) page and it's lowkey iconic β¨
π NAME π
lc_get β get element by label, maybe change the active set π
πΈ SYNOPSIS πΈ
struct lc_element * lc_get (struct lru_cache *lc , unsigned int enr );
π¦ ARGUMENTS π¦
lcβ the lru cache to operate on, bestie. that's the main character here.enrβ the label to look up. yes, the one you're hunting for π
β¨ DESCRIPTION β¨
So lc_get finds an element in the cache, increases its usage count, "touches" it, and returns it. periodt. π
In case the requested number is not present, it needs to be added to the cache. because of that, it is possible that an other element becomes evicted from the cache. in either case, the user is notified so he is able to e.g. keep a persistent log of the cache changes, and therefore the objects in use. fr fr, this is your heads-up moment π«Ά
π Return values π
NULLβ The cache was markedLC_STARVING, or the requested label was not in the active set and a changing transaction is still pending (lcwas markedLC_DIRTY). Or no unused or free element could be recycled (lcwill be marked asLC_STARVING, blocking furtherlc_getoperations). not the vibe, but it's important π- pointer to the element with the REQUESTED element number β in this case, it can be used right away. slay, go off π
- pointer to an UNUSED element with some different element number β where that different number may also be
LC_FREE.
In this case, the cache is marked LC_DIRTY, so lc_try_lock will no longer succeed. the returned element pointer is moved to the "to_be_changed" list, and registered with the new element number on the hash collision chains, so it is possible to pick it up from lc_is_used. up to "max_pending_changes" (see lc_create) can be accumulated. the user now should do whatever housekeeping is necessary, typically serialize on lc_try_lock_for_transaction, then call lc_committed(lc) and lc_unlock, to finish the change. literally the whole little transaction ritual π§
π₯ NOTE π₯
The user needs to check the lc_number on EACH use, so he recognizes any cache set change. no skipping the vibe check on this one, bestie β each use means each use π
π SEE ALSO π
Kernel file ./lib/lru_cache.c:
lc_create(9)lc_destroy(9)lc_reset(9)lc_seq_printf_stats(9)lc_find(9)lc_is_used(9)lc_del(9)lc_get_cumulative(9)lc_try_get(9)lc_committed(9)lc_put(9)lc_element_by_index(9)lc_seq_dump_details(9)
and that's the whole page, bestie: source ./lib, October 2026, lc_get(9) β Kernel API Manual edition πβ¨π«Ά
π¦ 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