tracing_map_add_key_field(9)
π« 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β thetracing_mapin 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:
tracing_map_update_sum(9)tracing_map_read_sum(9)tracing_map_set_var(9)tracing_map_var_set(9)tracing_map_read_var(9)tracing_map_read_var_once(9)tracing_map_add_sum_field(9)tracing_map_add_var(9)tracing_map_insert(9)tracing_map_lookup(9)tracing_map_destroy(9)tracing_map_clear(9)tracing_map_create(9)tracing_map_init(9)tracing_map_destroy_sort_entries(9)tracing_map_sort_entries(9)
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
- 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