create_field_var_hist(9)
π create_field_var_hist(9) π
okay so bestie, we're in the Kernel API Manual today and this one is lowkey a little baddie β it's all about making a histogram and a variable for a field, automatically, so nobody has to do it by hand β¨
π NAME π
create_field_var_hist β automatically create a histogram and var for a field π«Ά
πΈ SYNOPSIS πΈ
struct hist_field * create_field_var_hist (struct hist_trigger_data
*target_hist_data , char *subsys_name , char *event_name , char
*field_name );
β¨ ARGUMENTS β¨
target_hist_dataβ the target hist trigger π like, the one everything's getting built aroundsubsys_nameβ optional subsystem name (optional!! she doesn't have to show up)event_nameβ optional event name (also optional, no pressure π )field_nameβ the name of the field β and fr fr, this is also the name of the resulting variable π
π¦ DESCRIPTION π¦
So here's the tea β β hist trigger actions fetch their data from variables, not directly from events. That's just how it is.
But because the kernel devs are actually sweeties and want your life to be easy, users are allowed to just straight-up name an event field inside an action β and the kernel will convert that into a variable on your behalf. Not me doing the work for youβ¦ the kernel doing the work for you π
Now. If you specify a field on an event that isn't the event of the histogram currently being defined (aka the target event histogram), there's literally only one way that can happen: a whole new hist trigger has to get created, and the field variable gets defined on that one. Main character energy for the new trigger, honestly.
Which brings us to what this function does:
- it creates a new histogram that's compatible with the target event β and by compatible we mean a histogram with the same key as the target histogram π
- and it creates a variable for the specified field
β¦but bestie, listen π β the variable name gets 'synthetic_' prepended to it, specifically so it does not collide with normal field variables. Safety first, always πΈ
π RETURN π
The variable created for the field. That's it, that's the prize π
π SEE ALSO π
- Kernel file
./kernel/trace/trace_events_hist.cβ go read it, iykyk π check_field_for_var_ref(9)find_var_ref(9)find_any_var_ref(9)check_var_refs(9)create_var_ref(9)create_target_field_var(9)
the whole friend group honestly π«Ά
and that's the page!! mwah π this lil kernel API doc lives over in ./kernel/trace, and it's dated October 2026 β so yeah, she's from the future, iconic behavior only πβπ
π¦ 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