4 ms·
Why printk() is so complicated, and how to fix it (2019)
- amelius 6y agoDid anyone list all its requirements?
- heinrichhartman 6y agoSlide 3? https://www.linuxplumbersconf.org/event/4/contributions/290/attachments/276/463/lpc2019_jogness_printk.pdf https://www.linuxplumbersconf.org/event/4/contributions/290/...
- mauvehaus 6y agoShort version: because it needs work whether it's a sunny day or the last embers of the burning world are cooling, and every condition in between. It needs to allow formatting of an arbitrary string, while not being able to allocate arbitrary memory when called, or take any locks, for that matter. Oh, and it needs to not slow the system to a crawl. And to be useful, its output has to end up somewhere a person can see it. It would be a miracle if it wasn't incredibly complicated.
- Akronymus 6y agoThis seems, to me, to be one of the few cases of truly intrinsic complexity.
- pcr910303 6y agoI’m not sure if it’s ‘true’ intrinsic complexity: one can argue that the complexity comes from the kernel having so many different modes. (E.g. a ‘simple’ single-threaded cooperative kernel might not have this complexity.) But it definitely is ‘useful’ complexity...
- PaulDavisThe1st 6y agojust adding interrupts and multiple cores is enough to break that kind of "simplicity".
- Blikkentrekker 6y agoIt is perhaps because it needs to do all those things because it's one thing used for many different things, providing detection for it's own context. Much of the complexity in many cases could be alleviated by different functions depending on what context it is called from.
- deleted 6y ago[deleted]
- igravious 6y agohttps://news.ycombinator.com/item?id=21155348 https://news.ycombinator.com/item?id=21155348 Why printk() is so complicated, and how to fix it (https://lwn.net/SubscriberLink/800946/a9ad9aba46f14e78/ https://lwn.net/SubscriberLink/800946/a9ad9aba46f14e78/) 90 points |Tomte | 2 years ago | 13 comments
- JoshTriplett 6y agoSome of this work has gone in now. printk now has a lockless ringbuffer, and that allows it to work from more contexts without needing special fallbacks.
- Animats 6y agoI liked the QNX solution - the kernel never prints anything. It never handles a string. It's just a microkernel; all it does is pass messages, allocate memory, and dispatch the CPU. Drivers are in user space, of course. There's a system management process, "proc", running in user space but with extra privileges, to manage things usually done in kernels. The kernel itself was very rarely modified. More than that, there's no "console". QNX often ran on industrial hardware that didn't have a display or even a file system. Problems are reported by sending a message to a logging process. That might ship it over a network to somewhere else.