hlist_for_each_entry_safe(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… hlist_for_each_entry_safe β€” Kernel API Manual ✨

okay so bestie, welcome to the hlist_for_each_entry_safe(9) page πŸ’– yes the manual name is Kernel API Manual, we're in the big leagues now, and this one macro? it's giving "loop through a hash-list but make it unbothered by deletion" energy. no cap.


✨ NAME ✨

hlist_for_each_entry_safe β€” iterate over list of given type safe against removal of list entry πŸ¦‹

like, you walk the list, and it does not fall apart if somebody yanks an entry out from under you mid-loop. that's the whole vibe check. iconic behaviour honestly.


🌸 SYNOPSIS 🌸

hlist_for_each_entry_safe (pos , n , head , member );

yes, that spacing is exactly how it's written in the source, we don't "fix" things here, we respect the original 🫢


πŸŽ€ ARGUMENTS πŸŽ€

  • pos β€” the type * to use as a loop cursor. this is your main character ✨ it's the pointer that'll be pointing at whatever entry you're currently vibing with, one at a time.
  • n β€” another struct hlist_node to use as temporary storage. hi bestie πŸ‘‹ this one is the whole reason you're safe β€” it's holding onto the next thing so removal can't ruin your day.
  • head β€” the head for your list. the beginning, the origin story, the place where the whole hlist starts.
  • member β€” the name of the hlist_node within the struct. yep, just the member name β€” you tell it where the node lives inside your type and it handles the rest. iykyk πŸ’…
lowkey the n one is the entire point of the _safe in the name. don't skip it, don't get cute with it. the safety is the feature.

🌈 SEE ALSO 🌈

also check out the Kernel file ./tools/include/linux/list.h β€” that's where the magic lives, and it's linked up with basically the entire list-ops friend group 🌸:


and that's the whole page bestie, go forth and loop safely πŸ’œ

sign-off time πŸŽ€ this one's served fresh from ./tools/include/linux, stamped October 2026, and it answers to hlist_for_each_entry_safe(9) β€” periodt. πŸ’…βœ¨

πŸ“¦ where this page comes from