list_for_each_prev(9)
π list_for_each_prev(9) β the backwards-walk bestie
okay so real talk, this page lives in the Kernel API Manual and it's basically your little cheat code for walking a linked list in reverse. Not forwards. Backwards. We're going back to the beginning, literally. π¦
β¨ NAME β¨
list_for_each_prev β iterate over a list backwards π«
Like, the whole entire personality of this macro is "walk the list the other way." That's it. That's the tweet.
π SYNOPSIS π
list_for_each_prev (pos , head );
(it's literally that simple bestie, don't overthink it π«Ά)
πΈ ARGUMENTS πΈ
posβ thestruct list_headyou're using as your loop cursor. Think of it as your little finger tracing along the list as you go. It's the thing that moves. πheadβ the head for your list. The main character. The starting point of the whole situation. π
π₯ SEE ALSO π₯
okay so this is the part where the manpage just dumps the entire friend group on you, and honestly? iconic. every single one of these, no cap:
list_add(9)list_add_tail(9)list_replace(9)list_del_init(9)list_move(9)list_move_tail(9)list_is_first(9)list_is_last(9)list_empty(9)list_empty_careful(9)list_rotate_left(9)list_is_singular(9)list_cut_position(9)list_splice(9)list_splice_tail(9)list_splice_init(9)list_splice_tail_init(9)list_entry(9)list_first_entry(9)list_last_entry(9)list_first_entry_or_null(9)list_last_entry_or_null(9)list_next_entry(9)list_prev_entry(9)list_for_each(9)list_for_each_safe(9)list_for_each_prev_safe(9)list_for_each_entry(9)list_for_each_entry_reverse(9)list_prepare_entry(9)list_for_each_entry_continue(9)list_for_each_entry_continue_reverse(9)list_for_each_entry_from(9)list_for_each_entry_safe(9)list_for_each_entry_safe_continue(9)list_for_each_entry_safe_from(9)list_for_each_entry_safe_reverse(9)list_safe_reset_next(9)hlist_for_each_entry(9)hlist_for_each_entry_continue(9)hlist_for_each_entry_from(9)hlist_for_each_entry_safe(9)list_del_range(9)list_for_each_from(9)
and before anyone asks β the kernel file is ./tools/include/linux/list.h if you wanna go read the source yourself. iykyk π
π§ the cute sign-off π§
this whole thing comes to you from ./tools/include/linux, dated October 2026, and it's called list_for_each_prev(9) in case you forgot already (you didn't, you're doing amazing). mwah πβ¨π
π¦ 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