Re: [solved]newlib print issue?
Posted: Fri Feb 26, 2021 1:26 pm
Not even that. He already has a web server (which is powerful enough to host one of Germany's most popular blogs; when he posts links to smaller sites, he regularly takes down those sites just by his readers clicking those links), so he could just install cgit and be done with it. Hell, even SVN would be an improvement over CVS.vvaltchev wrote:Maybe we should suggest the guy to move dietlibc to Github?
Yeah, I looked it up again. The kernel interface there is horrible. I suppose the Linux guys really dropped the ball on this, and Rich was only playing the hand he was dealt. set_thread_area() is defined to modify the GDT. It gets an augmented GDT entry as argument and returns a GDT index back, that then still has to be converted into a selector. This is such a leaky abstraction it isn't even funny.vvaltchev wrote:I can't talk about AMD64, but on x86 it literally means allowing each process to own a limited set of GDT entries.
By the way, on AMD64, the __set_thread_area() function doesn't even call the set_thread_area() syscall. It just calls arch_prctl(SET_FS, arg). Way more sane.
Wouldn't you just copy the GDT on fork()? No ref-counting needed when each process has its own copy from the start right? And I can't imagine a GDT being big enough to worry about wasting space.vvaltchev wrote: The tricky part is it has to work also in fork-ed children,
Possibly, but reloading segment descriptor caches on every task switch can't be cheap, either. Anyway, the interface is designed to modify the GDT now, so now it is no longer possible to change. Binaries exist now that depend on set_thread_area() modifying the GDT instead of the LDT. So changing it would break ABI, and breaking ABI with userspace is the one thing Linus will not do.vvaltchev wrote:But why? It's an architecture specific feature anyway, why don't just having a small LDT per process? Maybe there's some overhead is setting the LDT on every task switch?
Incidentally, there is a modify_ldt() that musl will fall back on if set_thread_area() fails, but then it is no longer capable of multi-threading. It assumes to always get the first entry in the LDT, because that code is supposed to only run on very old kernels that lack set_thread_area() and therefore also lack clone().