On Sun, Jun 26, 2022 at 12:53 PM Joe Perches wrote: > > In a reply to the printbufs thread, I wrote a proposal to use an > alloc to reduce stack in vsprintf when CONFIG_KALLSYMS is enabled. > > No one has replied to this but I think it's somewhat sensible. I think that's a bad idea. Those things are *literally* called from panic situations, which may be while holding core memory allocation locks, or similar. The last thing we want to do is make a hard-to-debug panic be even *harder* to debug because you get a deadlock when oopsing. (And yes, I realize that the symbol name lookup can have problems too, but thats' kind of fundamental to %pS, while a kzmalloc isn't. Now, you are correct that the stack buffer is annoying. But I think the proper way to fix that is to say "we already *have* the target buffer, let's use it". That does require teaching the sprint_symbol() functions that they need to take a "length of buffer" and return how much they used, but that would seem to be a sensible thing anyway, and what the code should always have done? It's bad policy to just pass in a buffer without length, and I think it was always broken. Nasty. That KSYM_SYMBOL_LEN is magically taking care of it all, but it's ugly as heck, wouldn't you say? NOTE! The attached patch is completely broken. I did not do that interface change to the kallsyms code. The patch is literally meant to be just an explanation of what I mean, not a working patch. Linus