list_private...e_reset_next(9)
π list_private_safe_reset_next β Kernel API Manual β¨
okay so bestie, we're in the kernel API man pages (section 9, the fun one) and today's main character is list_private_safe_reset_next. pull up a chair. π
πΈ NAME πΈ
list_private_safe_reset_next β reset a stale list_for_each_entry_safe loop
like, the loop got stale, and we're resetting it. that's the whole vibe. periodt. π
β¨ SYNOPSIS β¨
list_private_safe_reset_next (pos , n , member );
three things go in, that's it. no cap. π«Ά
π¦ ARGUMENTS π¦
posβ the loop cursor used in thelist_for_each_entry_safeloop. yes, the actual cursor. the one doing the walking. main character energy fr. πnβ temporary storage used inlist_for_each_entry_safe. it's literally just holding onto stuff for you, don't @ it. πmemberβ the name of thelist_headwithin the struct. you know, the little handle inside the bigger thing. iykyk. π
π DESCRIPTION π
okay so here's the tea, and it's important so listen up. list_safe_reset_next is not safe to use in general if the list may be modified concurrently (eg. the lock is dropped in the loop body). like, genuinely not safe. do not do this casually, bestie, that's how you get undefined behaviour and a very bad afternoon. π
but!! there is an exception, and it's giving β¨specificβ¨:
- the cursor element (
pos) is pinned in the list, and list_safe_reset_nextis called after re-taking the lock and before completing the current iteration of the loop body.
that's the one window where it's chill. hit those conditions exactly and you slay. miss one andβ¦ π
fr fr, this is a "read it twice before you ship it" situation. the caveat is the whole point of the page.
π SEE ALSO π
the kernel file lives at ./include/linux/list_private.h β and honestly the whole friend group is here, so let's do the roll call π
Private List Primitives(9)list_private_entry(9)list_private_first_entry(9)list_private_last_entry(9)list_private_next_entry(9)list_private_next_entry_circular(9)list_private_prev_entry(9)list_private_prev_entry_circular(9)list_private_entry_is_head(9)list_private_for_each_entry(9)list_private_for_each_entry_reverse(9)list_private_for_each_entry_continue(9)list_private_for_each_entry_continue_reverse(9)list_private_for_each_entry_from(9)list_private_for_each_entry_from_reverse(9)list_private_for_each_entry_safe(9)list_private_for_each_entry_safe_continue(9)list_private_for_each_entry_safe_from(9)list_private_for_each_entry_safe_reverse(9)
aaaaand that's the page!! π§ it shipped from ./include/linux and it's dated October 2026 β so like, future girlboss behaviour honestly. go forth, reset your stale loops responsibly, and remember: pinned cursor, lock re-taken, iteration not finished yet. 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