printk_cpu_sync_get_irqsave(9)
πΈ printk_cpu_sync_get_irqsave(9) β a Kernel API Manual moment π
okay so bestie, you found a kernel API page, and this one is from the Kernel API Manual, so likeβ¦ strap in. it's giving low-level, it's giving "please read the caution section," and honestly? iconic behavior. π
β¨ NAME β¨
printk_cpu_sync_get_irqsave β literally disables interrupts and acquires the printk cpu-reentrant spinning lock, in one single glow-up of a call. no cap. π₯
π¦ SYNOPSIS π¦
printk_cpu_sync_get_irqsave (flags );
(yes the spacing is like that, do not come for me, I don't make the rules π)
π ARGUMENTS π
flagsβ this is your stack-allocated storage, bestie. it's where the local interrupt state gets saved. you are literally gonna hand this exact thing over toprintk_cpu_sync_put_irqrestorelater, so keep it safe, keep it on the stack, that's the whole vibe. π«Ά
π DESCRIPTION π
so here's the tea: if the lock is currently owned by another CPU, you spin until it becomes available. that's it, that's the move. and the cute part? interrupts are restored while you're spinning. main character energy fr fr. β¨
β οΈ CAUTION: bestie. read this part. this function must be used carefully. it does NOT behave like a typical lock. like, at all. here are the important things to watch out forβ¦ π
- this function is reentrant on the same CPU. therefore the calling code must not assume exclusive access to data if code accessing the data can run reentrant or within NMI context on the same CPU. so likeβ¦ don't get cocky about your data, okay? π
- if there exists usage of this function from NMI context, it becomes unsafe to perform any type of locking or spinning to wait for other CPUs after calling this function from any context. yes, any context. and yes, this includes using spinlocks or any other busy-waiting synchronization methods. do not do it. I'm serious. π
π SEE ALSO π
Kernel file ./include/linux/printk.h β and the whole friend group, obviously:
printk_cpu_sync_put_irqrestore(9)pr_fmt(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)
and that's the whole page, bestie! π§ this little gem lives over in ./include/linux, and it's stamped October 2026 β so like, future-coded of it. go forth, save your flags, restore your interrupts, and slay responsibly. ππβ
π¦ 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