pin_hibernation_swap_type(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– pin_hibernation_swap_type(9) πŸ’–

okay so bestie, welcome to the Kernel API Manual β€” yes we're reading kernel docs together, this is our bonding era 🫢. Today's main character is pin_hibernation_swap_type, and ngl, it's giving "tiny function, huge responsibility."


✨ NAME ✨

pin_hibernation_swap_type β€” pin the swap device for hibernation πŸ”’πŸ’€


🌸 SYNOPSIS 🌸

int pin_hibernation_swap_type (dev_t device , sector_t offset );

πŸŽ€ ARGUMENTS πŸŽ€

  • device β€” the block device that's holding the resume image πŸ‘€
  • offset β€” the offset that identifies the swap area, a.k.a. the "which swap area tho" coordinate πŸ“

πŸ¦‹ DESCRIPTION πŸ¦‹

So here's the vibe: it goes and locates the swap device that matches device/offset, then marks it as pinned for hibernation. While it's pinned, swapoff is prevented β€” like, absolutely not, we're not doing that right now πŸ’….

And listen, bestie, there's a limit here: only one uswsusp context may pin a swap device at a time. That's the rule. If it's already pinned, this function just returns -EBUSY and moves on. No drama, just a hard no πŸ™ˆ.


πŸ”₯ RETURN πŸ”₯

  • >= 0 β€” success, and you get the swap type back ✨
  • -EINVAL β€” device is invalid, like girl what even is that 😭
  • -ENODEV β€” the swap device was not found, it's literally not here πŸ’€
  • -EBUSY β€” the device is already pinned for hibernation, someone else got here first πŸ‘‘

πŸ‘‘ SEE ALSO πŸ‘‘

Kernel file ./mm/swapfile.c β€” and the whole friend group:

swap_put_entries_cluster(9), swap_dup_entries_cluster(9), folio_alloc_swap(9), folio_dup_swap(9), folio_put_swap(9), swap_entry_swapped(9), folio_free_swap(9), swap_put_entries_direct(9), swap_alloc_hibernation_slot(9), swap_free_hibernation_slot(9), unpin_hibernation_swap_type(9), find_hibernation_swap_type(9)


🌈 friendly reminder: pinning is a commitment. Only one uswsusp context at a time, iykyk.

and that's the whole page, bestie, you ate πŸ“βœ¨ β€” this iconic little number lives in ./mm, dated October 2026, and it's filed under pin_hibernation_swap_type(9). mwah πŸ’‹πŸ§šπŸ’œ

πŸ“¦ where this page comes from