llist_for_each(9)
π llist_for_each(9) β kernel API manual, but make it make sense
okay so this is llist_for_each, a kernel API manual page (section 9, the "kernel API" manual), and bestie we are going to get through this together. It's short, it's sweet, and it's giving "tiny function, big personality." π
β¨ NAME β¨
llist_for_each β iterate over some deleted entries of a lock-less list π¦
β¨ SYNOPSIS β¨
llist_for_each (pos , node );
that's it. that's the whole call. no cap. π
β¨ ARGUMENTS β¨
posβ thestruct llist_nodeto use as a loop cursor π (this is your little guy that walks the list)nodeβ the first entry of deleted list entries πΈ (this is where you start walking from)
β¨ DESCRIPTION β¨
okay so here's the vibe check: in general, some entries of the lock-less list can be traversed safely only after being deleted from the list, so you start with an entry instead of the list head. like, the list head is not invited to this party, we're starting from the entry itself, periodt. π
if you're using this on entries deleted from the lock-less list directly, the traverse order is from the newest to the oldest added entry. yes, newest first. it's giving reverse chronological, it's giving "most recent ex first in the group chat." π
so if you want to traverse from the oldest to the newest, you must reverse the order by yourself before traversing. nobody's gonna do it for you, bestie β you gotta reverse that order yourself, fr fr. π₯
β¨ SEE ALSO β¨
Kernel file ./include/linux/llist.h π and the whole llist friend group, all linked up:
init_llist_head(9)init_llist_node(9)llist_on_list(9)llist_entry(9)member_address_is_nonnull(9)llist_for_each_safe(9)llist_for_each_entry(9)llist_for_each_entry_safe(9)llist_empty(9)llist_add_batch(9)llist_add(9)llist_del_all(9)llist_del_first_init(9)
like, the entire llist cast showed up. main character energy from every single one of them. π
and that's the page, bestie π«Ά β brought to you from ./include/linux, dated October 2026, in the Kernel API Manual. go traverse something (safely, after deletion, newest to oldest, or reverse it yourself, you got this) β¨π
π¦ 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