tracing_map_add_key_field(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’« tracing_map_add_key_field (9) β€” from the Kernel API Manual, bestie πŸ’«

okay so picture this: you're deep in the kernel, you've got a tracing_map, and you need it to actually know about a key. That's literally this function's whole job. It's a real one from the kernel API manual and I'm obsessed. πŸŽ€


✨ NAME ✨

tracing_map_add_key_field β€” add a field describing a tracing_map key πŸ”‘


🌸 SYNOPSIS 🌸

int tracing_map_add_key_field (struct tracing_map *map , unsigned int
offset , tracing_map_cmp_fn_t cmp_fn );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • map β€” the tracing_map in question, the main character here πŸ’…
  • offset β€” where you're sitting within the key, like your little spot in the group photo πŸ“Έ
  • cmp_fn β€” the comparison function that gets used to sort on the key. it's giving "who goes first" energy ✨

πŸ’– DESCRIPTION πŸ’–

So you call this to let the map know there is a key, and β€” important part β€” that if that key gets used as a sort key, it should use cmp_fn. no cap. 🫢

Also lowkey iconic: a key can be a subset of a compound key. For that purpose, the offset param describes where within the compound key the key referenced by this key field actually resides. Like, which slice of the compound key is this one. πŸ“


πŸ”₯ RETURN πŸ”₯

It hands you back the index identifying the field in the map and the associated tracing_map_elts β€” or -EINVAL on error 😭 (that's the "something went wrong bestie" branch).

ngl, -EINVAL means error here, so don't go treating it like a valid index. πŸ’€

🌈 SEE ALSO 🌈

Kernel file ./kernel/trace/tracing_map.c, plus the whole friend group:


that's the whole page, and honestly? slay. πŸ’…βœ¨ this one lives in ./kernel/trace, dated October 2026, and it's filed under tracing_map_add_key_field(9) β€” mwah, bye bestie! πŸ§šπŸ’œ

πŸ“¦ where this page comes from