create_filter(9)
π create_filter(9) β from the Kernel API Manual, bestie
okay so picture this: you're deep in the kernel's tracing guts and you need a filter. not like a coffee filter, a trace event filter. this little guy create_filter is the function that makes one for you. let's get into it β¨
πΈ SYNOPSIS πΈ
int create_filter (struct trace_array *tr , struct trace_event_call
*call , char *filter_string , bool set_str , struct event_filter
**filterp );
that's the whole gang right there π«Ά five args, one int coming back at you.
π ARGUMENTS π
trβ the trace array that's associated with these events. your home base for this whole situation.callβ thetrace_event_callyou're creating a filter for. the main character of this operation, lowkey.filter_stringβ the filter string itself. the actual filter-y text, periodt.set_strβ this one's the remember-y flag: it says "rememberfilter_strand enable detailed error in filter". so if you want your filter to hold onto the string and give you detailed errors, set ittrue. πfilterpβ the out param for the created filter, and heads up: it's always updated on return. β οΈ but there's a strict vibe check here β it must be a pointer that references aNULLpointer. no cap, don't skip that part.
π¦ DESCRIPTION π¦
So what does it actually do? It creates a filter for call with filter_str. π And if set_str is true, then filter_str gets copied and recorded in the new filter β iconic behaviour honestly.
Now the returns, because this is where people get caught out π
- On success β returns
0, and*filterppoints to the new filter. slay. β - On failure β returns
-errno, and*filterpmay point toNULLor to a new filter. π
and that second failure case is the sneaky one: in that case, the returned filter contains error information if set_str is true, and the caller is responsible for freeing it. so likeβ¦ you have to clean up. main character responsibility fr fr π«Ά
β οΈ ngl the*filterpmust-be-a-pointer-to-a-NULL-pointer rule is not a suggestion, bestie. it's giving "read the argument list twice before you compile." π
π SEE ALSO π
- Kernel file
./kernel/trace/trace_events_filter.c struct prog_entry(9)update_preds(9)filter_parse_regex(9)create_system_filter(9)
all the siblings in the same kernel file β go say hi, they're all part of the filter cinematic universe π§β¨
and that's the whole page, bestie π this one lives under ./kernel/trace and it's dated October 2026 in the Kernel API Manual β so when you see it, you'll know exactly where it came from. mwah ππ
π¦ 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