list_swap(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’œ okay so, list_swap(9) β€” Kernel API Manual, bestie

hi hi hi 🫢 welcome to the little corner of the kernel docs where two list nodes literally trade lives. this one is from the Kernel API Manual, and it's short, it's sweet, and it ate. let's get into it ✨


🌸 NAME

list_swap β€” replace entry1 with entry2 and re-add entry1 at entry2's position πŸ’…

that's it. that's the whole vibe. two entries, one swap, no cap.


✨ SYNOPSIS

void list_swap (struct list_head *entry1 , struct list_head *entry2 );

she takes two struct list_head * and returns void, because the drama is entirely in-place, as it should be πŸ‘‘


πŸŽ€ ARGUMENTS

  • entry1 β€” the location to place entry2 πŸ¦‹ (so entry1 is the spot that's gonna be holding entry2 by the end)
  • entry2 β€” the location to place entry1 🌈 (yep, they're swapping, that's the whole bit)

like... it's giving mutual relocation. both of them move. neither of them knows where they're going until they get there. iconic behavior fr fr πŸ’€


πŸ”₯ SEE ALSO

bestie there is a whole friend group here, and i mean a whole one. this is the Kernel file ./include/linux/list.h and everyone in it:

that's the roster. that's the whole group chat. the hlist girlies showed up too ofc, they always do πŸ’…


ngl if you're grooving on list_swap, go read the rest of them β€” the list API is genuinely one of the most satisfying little families in the kernel and i will not be taking questions about that 🌸

okay bye bestie, go swap something πŸ¦‹


mwah πŸ’– this little page lives in ./include/linux and it's dated October 2026 β€” see you in the next one, periodt πŸŽ€

πŸ“¦ where this page comes from