list_private...e_reset_next(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 the list_for_each_entry_safe loop. yes, the actual cursor. the one doing the walking. main character energy fr. πŸ‘‘
  • n β€” temporary storage used in list_for_each_entry_safe. it's literally just holding onto stuff for you, don't @ it. πŸ™ˆ
  • member β€” the name of the list_head within 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_next is 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 πŸŽ‰


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