maps__mutate_mapping(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… maps__mutate_mapping(9)

okay so this is a page from the Kernel API Manual, and bestie, it's a whole vibe. gather round, we're talking about maps__mutate_mapping πŸ—ΊοΈβœ¨


✨ NAME ✨

maps__mutate_mapping β€” apply write-protected mutations to a map. literally that's the whole thing, and yes it slays πŸ’–


πŸŽ€ SYNOPSIS πŸŽ€

int maps__mutate_mapping (struct maps *maps , struct map *map , int
(*mutate_cb)(struct map *map, void *data) , void *data );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • maps β€” the maps collection that contains the map. like, the friend group the map belongs to 🫢
  • map β€” the map you're actually mutating. main character of this call fr πŸ’…
  • mutate_cb β€” the callback function that does the actual mutations. it's giving "you had one job" and it does it ✨
  • data β€” private data you pass along to the callback. little gift bag for your callback 🎁

🌸 DESCRIPTION 🌸

so what happens is: this acquires the write lock on the maps semaphore, so that concurrent readers are safely protected from ever seeing partially mutated or unsorted map boundaries. no half-finished glow-ups visible to the group chat, periodt πŸ’–

WARNING: πŸ‘‘ acquiring down_write here can trigger a recursive self-deadlock if the caller already holds the read lock (for example, during maps__for_each_map or maps__find iteration paths that trigger lazy symbol loading). 😭 to completely avoid this deadlock, all kernel/module maps must be pre-loaded up-front (via maps__load_maps) under a clean, single-threaded context before entering multi-threaded event processing loops. no cap, do it in that order or it's giving deadlock πŸ’€

🌈 SEE ALSO 🌈

kernel file ./tools/perf/util/maps.c β€” go read it, iykyk πŸ’œ


that's the whole page babes, stay locked and stay safe out there πŸ§šπŸ’…

./tools/perf/util Β· October 2026 Β· maps__mutate_mapping(9) β€” mwah, xoxo, go mutate responsibly πŸ“πŸŽ€

πŸ“¦ where this page comes from