3 ms·
> 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.
by cesarb 6y ago
> 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/ 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. [...]"
- ksml 6y agoThis 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.
- kanox 6y agoAlso: allocating memory with GFP_ATOMIC doesn't sleep.
- m463 6y agonow that is technical leadership.
- msla 6y agoIf you have to rely on printf debugging, you go to epic lengths to ensure printf always works.