From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <1344e929d104a133c5a748fc591a9746.axp-list@archive.invalid> X-Archive-Original-Message-ID: <199610081651.LAA19884@atheist.tamu.edu> Date: Tue, 8 Oct 1996 21:16:25 +0300 (EET DST) From: Linus Torvalds Subject: Linux-2.0.22 and Linux-2.1.2 In-Reply-To: <199610081511.IAA03722@panda.mosberger> I made both a new 2.0.x and a 2.1.x release, and they are available on the usual sites. The 2.0.x is mainly a few driver updates, but also has the pty bug-fix that people in the 2.1.x tree have already been testing out. 2.1.2 is the much more interestign one, at least as far as I'm concerned. This release does: - goodbye old inefficient "verify_area()", hello run-time exceptions. Essentially, the old "verify_area()" was a very straightforward system that checked that any pointer given to the kernel was valid. It verified that the area was mapped, and returned either 0 or -EFAULT depending on that. It was reliable, boringly so. However, "verify_area()" did have a few problems. Notably: it was slow. Not "horribly and inexplicably slow", but it was simply called a lot, and it had to do a lot of checks. End result: it shows up on kernel profiles pretty well. Now, I tried to optimize it, but it was basically pretty optimized already. It used avl trees to find the memory areas, and it was just plain a good implementation. But the bad thing about it all was that it never found any errors. The things it checks against are things that never happen for normal programs, and as such it is very irritating to see it taking up almost 20% of the kernel time under some circumstances. Now, "verify_area()" had another more subtle problem, and that was the fact that the memory mapping that it checked could _change_ after it had been checked when people used kernel threads (another thread did a mmap or a munmap). That wasn't originally a problem, as Linux didn't have threads originally, but it's been nagging me for the last year or two. So... Enter the all-new-and-improved Linux-2.1.2. It gets rid of "verify_area()" altogether. Or rather, the function still exists, but it doesn't really do much any more. In fact, it does just about the same thing that it did in Linux-0.01: it only tests that the pointer is in user space (and it does _not_ check whether the area it points to is actually mapped). Voila, instant speedup: the function that used to take 20% of kernel time under some circumstances is now a inline function that expands to just a few assembly instructions. The downside? Bad programs who mess with the kernel. They pass invalid addresses to system calls, and nothing checks it any more. Bummer. But don't despair: we do actually have something that checks the invalid addresses. And what's nice about it is that it's actually built-in in the CPU hardware. The paging unit. Anyway, Linux-2.1.2 now uses exceptions to trap bad system call buffers. The new scheme is a bit more complex to actually use, but it's a _lot_ faster, and it actually works correctly in the presense of kernel threads (the old one worked fine too usually, but it _could_ make mistakes, and making mistakes isn't really acceptable when the whole and only idea of the function is to verify that no mistakes happen in the first place). However, I didn't have the stamina to add the extra exception handling to all of the system calls, so Linux-2.1.2 is a work in progress in that sense. It's not hard to add the necessary "exception()/end_exception()" pairs, but it _is_ tedious, and it does require some care (to make sure everything is "rolled back" correctly when an exception happens). So I'll be doing that over a period of kernels, but I wanted to make the basic stuff available now. In addition to the exception stuff, 2.1.2 also does: - updates some alpha handling. This should contain all the important things from the axp-diffs that David M-T has been making. - alpha and x86 system call entry optimizations. I now get less than 1us system call latencies on my ev5/333 according to lmbench. - various minor changes ("a" -> "an" fixes etc) David: don't expect all of your patches to be in. I didn't actually use much more than you machine check patches as-is: everything else is essentially re-done the way I perferred it. Linus -- To unsubscribe: mail -s unsubscribe axp-list-request@redhat.com < /dev/null