Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> However, printk can block (while allocating memory)

No, printk() is magic. It can be called even in NMI context, which is a worse place. Quoting https://lwn.net/Articles/800946/, "[...] kernel code must be able to call printk() from any context. Calls from atomic context prevent it from blocking; calls from non-maskable interrupts (NMIs) can even rule out the use of spinlocks. [...]"




This is really good to know. I had assumed it could block when allocating memory for the formatted string buffer, but the rationale explained in that article makes a lot of sense. Being able to use printk simplifes things a lot.


Also: allocating memory with GFP_ATOMIC doesn't sleep.


now that is technical leadership.


If you have to rely on printf debugging, you go to epic lengths to ensure printf always works.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: