pr_fmt(9)
π pr_fmt(9) β the Kernel API Manual, bestie edition π
okay so like, quick vibe check: this is a page from the Kernel API Manual and it's about pr_fmt, which is genuinely one of those tiny things that makes a whole file look put-together. main character macro energy fr fr β¨
πΈ NAME πΈ
pr_fmt β the lil macro the pr_*() macros use to generate the printk format string π
π¦ SYNOPSIS π¦
pr_fmt (fmt );
β¨ ARGUMENTS β¨
fmtβ the format string that got passed in from apr_*()macro. that's it. that's the whole argument π«Ά
π DESCRIPTION π
okay so here's the tea: this macro is how you generate a unified format string for all the pr_*() macros. like, one string to rule them all, no cap π
the classic use case β the one everybody does β is prefixing every single pr_*() message in a file with a common string. so instead of your logs looking like a chaotic group chat with no names, every message is tagged. iconic behaviour tbh.
for example, defining this at the top of a source file:
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
would prefix all pr_info, pr_emerg... messages in the file with the module name. literally all of them. slay π₯
ngl this is the kind of one-liner that makes debugging at 3am feel slightly less cursed. slightly. π
π SEE ALSO π
- Kernel file
./include/linux/printk.h printk_cpu_sync_get_irqsave(9),printk_cpu_sync_put_irqrestore(9),printk(9),pr_emerg(9),pr_alert(9),pr_crit(9),pr_err(9),pr_warn(9),pr_notice(9),pr_info(9),pr_cont(9),pr_devel(9),pr_debug(9),print_hex_dump_bytes(9)
the whole pr_* friend group, assembled π
π
aaaand that's the page bestie π§π« huge shoutout to ./include/linux for hosting this one, dated October 2026 β go forth and prefix your logs, you're gonna eat ππ
π¦ 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