trace_array_printk(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ trace_array_printk β€” Kernel API Manual ✨

okay so bestie, we're in the trace_array_printk(9) manual page today πŸ’… and honestly? it's a good one. it's all about printing messages into your own tracing instance instead of being messy and yelling into the top-level buffer. main character energy only, no cap πŸŽ€


🌸 NAME 🌸

trace_array_printk β€” print a message to a specific instance

like, a specific one. not all of them. we're being polite about it 🫢


πŸ¦‹ SYNOPSIS πŸ¦‹

int trace_array_printk (struct trace_array *tr , unsigned long ip ,
       const char *fmt , ... );

look at that signature. iconic. it returns an int, it takes a struct trace_array *tr, an unsigned long ip, a const char *fmt, and then the classic ... because it's a printf-style situation and it will eat however many variable arguments you feed it πŸ“


πŸ’– ARGUMENTS πŸ’–

  • tr β€” the instance trace_array descriptor. this is your instance's little ID card, okay? gotta know which buffer we're talking to πŸͺͺ
  • ip β€” the instruction pointer that this is called from. yes literally, the instruction pointer. you pass it in, it gets recorded, that's the vibe ⭐
  • fmt β€” the format to print (printf format, bestie, so all your usual format specifiers live here) ✨
  • ... β€” variable arguments. as many as your fmt asks for. no more, no less, we're not doing that πŸ™ˆ

πŸ”₯ DESCRIPTION πŸ”₯

so here's the tea β˜• if a subsystem sets up its own instance, they have the right to printk strings into their own tracing instance buffer using this function. that's it. that's the whole deal. your instance, your buffer, your rules πŸ’…

but β€” and this is the important part, so listen up β€” this function will not write into the top level buffer. nope. not doing it. if you want the top level buffer, use trace_printk for that. and why, you ask? because writing into the top level buffer should only have events that can be individually disabled. it's a whole thing about keeping the top level clean and disable-able, iykyk 🧚

also, trace_printk is only used for debugging a kernel, and should not be ever incorporated in normal use. like, ever ever. it's a debugging tool, not a lifestyle 🫢

trace_array_printk, on the other hand, can be used, as it will not add noise to the top level tracing buffer. so you get your messages, and the top level buffer stays unbothered and pristine. slay 🌈

⚠️ real talk though: note that trace_array_init_printk must be called on tr before this can be used. before. not after, not "ehh it'll probably work", before. do the init first or this whole thing is a no πŸ’€

πŸ‘‘ SEE ALSO πŸ‘‘


and that's the page, bestie!! πŸŽ€ source/version is ./kernel/trace and the date on this beauty is October 2026 β€” go forth and print into your own instance only, periodt πŸ’œπŸ”₯

πŸ“¦ where this page comes from