From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <2da95d472a2edf79c380fa963e5e239b.axp-list@archive.invalid> X-Archive-Original-Message-ID: <199610171100.LAA00900@linux.reo.dec.com> Date: Thu, 17 Oct 1996 13:18:44 +0300 (EET DST) From: Linus Torvalds Subject: Re: Linux-2.1.4 In-Reply-To: On Thu, 17 Oct 1996, Ingo Molnar wrote: > > could it be optimized even one step further? We could do the following: > > movl xxxx,%eax /* get the value */ > > the exception handler could maintain a cross-table that identifies EIPs > and abort points. It would do something like this: > > jmp UGLY_AS_HELL_BUT_FAST_AS_LIGHTNING_CROSSJUMP_TABLE[exception_eip] Yes, we could actually do something like this. It needs compiler support, but that is possible, and g++ exceptions are actually kind of moving in this direction. However, in real life this is probably not an option. We'll see if g++ exceptions ever get that good, but right now I doubt this will be a realistic option within at least a year. > [ actually, we possibly dont even need such a table, the exception code > could just do a very simple (and fast) deassembly of the exception EIP, > and could decide where to jump ] Note that we can indeed do disassemblies: it doesn't even need to be fast. It can be slow as molasses, and nobody would care, because the exceptions never happen for good code. So we can have an _extremely_ stupid disassembly function that takes ages to do it. > > It's the RISC philosophy: make the basic operations simple, and do them > > extremely quickly. Complex operations might be slower, but complex operations > > are relatively rare. > > lets push it to the extreme ... We actually discussed this already with David Miller, especially as the disassembly phase is totally unnecessary in many cases (most RISC chips have equal-length instructions, so the only thing the exception handler would need to do is regs->flag_reg = -EFAULT; regs->ip += 4; return; However, there are some problems with that approach too, and while it's good for "get_user()" and "put_user()", it has some real problems for some other code. In particular, think of the case where we do a copy_from_user(buffer_cache, user_ptr, nr); Now, if we just skip the instructions that fault and set a return register value, the above will return an error, but it may have written incorrect data to the buffer cache (because the instructions following the faulting instruction were still executed). Now, we can handle that by having a copy_from_user() that tests the register value every now and then, and this is actually an option in the long run, but right now I'm nervous about the disassembly phase on x86 (on RISC it's simple, but the x86 disassembly is horrible and while I do not care about speed I _do_ care about correctness ;) So yes, we can potentially actually get the overhead down even further. That's one advantage with the new interface in 2.1.4 - the generic kernel code doesn't even need to know exactly _how_ we handle the exceptions. Linus -- To unsubscribe: mail -s unsubscribe axp-list-request@redhat.com < /dev/null