list_swap(9)
π 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 π¦ (soentry1is the spot that's gonna be holdingentry2by 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:
LIST_HEAD_INIT(9)LIST_HEAD(9)LIST_HEAD_GUARDED(9)INIT_LIST_HEAD(9)list_add(9)list_add_tail(9)list_add_tail_release(9)list_del(9)list_replace(9)list_replace_init(9)list_del_init(9)list_move(9)list_move_tail(9)list_bulk_move_tail(9)list_is_first(9)list_is_last(9)list_is_head(9)list_empty(9)list_del_init_careful(9)list_empty_careful(9)list_rotate_left(9)list_rotate_to_front(9)list_is_singular(9)list_cut_position(9)list_cut_before(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_first_entry_or_null_acquire(9)list_last_entry_or_null(9)list_next_entry(9)list_next_entry_circular(9)list_prev_entry(9)list_prev_entry_circular(9)list_for_each(9)list_for_each_continue(9)list_for_each_prev(9)list_for_each_safe(9)list_for_each_prev_safe(9)list_count_nodes(9)list_entry_is_head(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_from_reverse(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_unhashed(9)hlist_unhashed_lockless(9)hlist_empty(9)hlist_del(9)hlist_del_init(9)hlist_add_head(9)hlist_add_before(9)hlist_add_behind(9)hlist_add_fake(9)hlist_fake(9)hlist_is_singular_node(9)hlist_move_list(9)hlist_splice_init(9)hlist_for_each_entry(9)hlist_for_each_entry_continue(9)hlist_for_each_entry_from(9)hlist_for_each_entry_safe(9)hlist_count_nodes(9)
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
- 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