trace_puts(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

🌸 trace_puts β€” like, the ftrace string-dropper ✨

okay so first things first, bestie: this is a page from the Kernel API Manual (section 9, kernel developer land πŸ’…), and today's main character is trace_puts. Let's get into it 🫢


✨ NAME ✨

trace_puts β€” write a string into the ftrace buffer πŸŽ€


πŸ’– SYNOPSIS πŸ’–

trace_puts (str );

that's it. that's the whole vibe. one arg, one string, one buffer. slay πŸ’…


πŸ¦‹ ARGUMENTS πŸ¦‹

  • str β€” the string to record. literally just the string, no cap. that's what goes in the buffer ✨

πŸŽ€ NOTE πŸŽ€

okay so this is the part where I need you to lock in πŸ”₯

  • __trace_bputs is an internal function for trace_puts, and the ip gets passed in via the trace_puts macro. iykyk πŸ‘€
  • This thing is similar to trace_printk, but it's made for those really fast paths where a developer wants the least amount of "Heisenbug" effects β€” like, the processing of the print format is still too much for that situation 😭
  • What this function does is let a kernel developer debug fast path sections that printk is just not appropriate for. By scattering various printk-like tracing around in the code, a developer can quickly see where problems are occurring. it's giving "sprinkle a little detective work" πŸ”
  • Now the serious bit, and I mean it: this is intended as a debugging tool for the developer only. Please refrain from leaving trace_puts scattered around in your code. πŸ™ˆ (Extra memory is used for special buffers that are allocated when trace_puts is used β€” so yeah, it's not free, bestie.)
fr fr, don't ship it. debug with it, then take it out. we've all seen code with random trace calls left in it and we do NOT want that to be you πŸ’€

⭐ RETURN ⭐

  • 0 if nothing was written
  • a positive # if the string was written ✨

and to be precise about that positive number, because details matter:

  • 1 when __trace_bputs is used
  • strlen(str) when __trace_puts is used

🌈 SEE ALSO 🌈


that's the whole page, bestie, go forth and debug responsibly πŸ§šβ€β™€οΈ

sign-off era: this lil page lives in ./include/linux and it's dated October 2026 β€” take that info and keep it safe in your notes πŸ“πŸ’œ

πŸ“¦ where this page comes from