VM and swap - it's really unusable
Subsystems (6)
Is it possible to decide, now what should go into 2.4.18 (maybe -pre3) -aa or -rmap?
Andrew Morten`s read-latency.patch is a clear winner for me, too. What about 00_nanosleep-5 and bootmem?
The O(1) scheduler?
Maybe preemption? It is disengageable so nobody should be harmed but we get the chance for wider testing.
Any comments?
Thanks,
Dieter
Signature · 6 lines
Dieter Nützel Graduate Student, Computer Science University of Hamburg Department of Computer Science @home: [email protected]
On Tue, 8 Jan 2002, Dieter [iso-8859-15] Nützel wrote (passim):
Quoted 2 lines
Is it possible to decide, now what should go into 2.4.18 (maybe -pre3) -aa or -rmap?
[...]
Quoted 4 lines
Maybe preemption? It is disengageable so nobody should be harmed but we get the chance for wider testing.
Any comments?
preemption?? this is eventually 2.5 stuff, and should not be integrated into 2.4 stable tree. Of course a backport is possible, when/if it will be quite well tested and well working on 2.5
Quoted 4 lines · Luigi Genoni
On Tue, 8 Jan 2002, Dieter [iso-8859-15] Nützel wrote (passim):
Quoted 8 lines
Quoted 2 lines
Is it possible to decide, now what should go into 2.4.18 (maybe -pre3) -aa or -rmap?
[...]
Quoted 4 lines
Maybe preemption? It is disengageable so nobody should be harmed but we get the chance for wider testing.
Any comments?
preemption?? this is eventually 2.5 stuff, and should not be integrated
indeed ("eventually" in the italian sense btw, obvious to me, but not for l-k).
I'm not against preemption (I can see the benefits about the mean latency for real time DSP) but the claims about preemption making the kernel faster doesn't make sense to me. more frequent scheduling, overhead of branches in the locks (you've to conditional_schedule after the last preemption lock is released and the cachelines for the per-cpu preemption locks) and the other preemption stuff can only make the kernel slower. Furthmore for multimedia playback any sane kernel out there with lowlatency fixes applied will work as well as a preemption kernel that pays for all the preemption overhead.
About the other claim that as the kernel becomes more granular performance will increase with preemption in kernel, that's obviously wrong as well, it's clearly the other way around. Maybe it was meant "latency will decrease further", that's right, but also performance will decrease if something.
So yes, mean latency will decrease with preemptive kernel, but your CPU is definitely paying something for it.
Quoted 6 lines
into 2.4 stable tree. Of course a backport is possible, when/if it will be quite well tested and well working on 2.5
Andrea
Quoted 3 lines
So yes, mean latency will decrease with preemptive kernel, but your CPU is definitely paying something for it.
And Andrew Morton's work suggests he can do a much better job of reducing latency than -preempt.
Anton
Quoted 10 lines · On 20020108 Dieter Nützel wrote:
Is it possible to decide, now what should go into 2.4.18 (maybe -pre3) -aa or -rmap?
Andrew Morten`s read-latency.patch is a clear winner for me, too. What about 00_nanosleep-5 and bootmem?
The O(1) scheduler?
Maybe preemption? It is disengageable so nobody should be harmed but we get the chance for wider testing.Any comments?
I would pefer the ton of small, usefull and safe bits in Andrea's kernel (vm-21, cache-aligned-spinlocks, compiler, gcc3, rwsem, highmen fixes...)
Signature · 4 lines
J.A. Magallon # Let the source be with you... mailto:[email protected] Mandrake Linux release 8.2 (Cooker) for i586 Linux werewolf 2.4.18-pre2-beo #1 SMP Tue Jan 8 03:18:18 CET 2002 i686
Quoted 6 lines · Anton Blanchard
Quoted 2 lines · Andrea Arcangeli [apparently]
So yes, mean latency will decrease with preemptive kernel, but your CPU is definitely paying something for it.
And Andrew Morton's work suggests he can do a much better job of reducing latency than -preempt.
That's not a particularly clueful comment, Anton. Obviously, any latency-busting hacks that Andrew does could also be patched into a -preempt kernel.
What a preemptible kernel can do that a non-preemptible kernel can't is:
reschedule exactly as often as necessary, instead of having lots of extra schedule points inserted all over the place, firing when *they* think the time is right, which may well be earlier than necessary.
The preemptible approach is much less of a maintainance headache, since people don't have to be constantly doing audits to see if something changed, and going in to fiddle with scheduling points.
Finally, with preemption, rescheduling can be forced with essentially zero latency in response to an arbitrary interrupt such as IO completion, whereas the non-preemptive kernel will have to 'coast to a stop'. In other words, the non-preemptive kernel will have little lags between successive IOs, whereas the preemptive kernel can submit the next IO immediately. So there are bound to be loads where the preemptive kernel turns in better latency *and throughput* than the scheduling point hack.
Mind you, I'm not devaluing Andrew's work, it's good and valuable. However it's good to be aware of why that approach can't equal the latency-busting performance of the preemptive approach.
--
Daniel
Quoted 8 lines · Daniel Phillips
Quoted 6 lines · Anton Blanchard
Quoted 2 lines · Andrea Arcangeli [apparently]
So yes, mean latency will decrease with preemptive kernel, but your CPU is definitely paying something for it.
And Andrew Morton's work suggests he can do a much better job of reducing latency than -preempt.
Quoted 8 lines
That's not a particularly clueful comment, Anton. Obviously, any latency-busting hacks that Andrew does could also be patched into a -preempt kernel.
What a preemptible kernel can do that a non-preemptible kernel can't is:
reschedule exactly as often as necessary, instead of having lots of extra schedule points inserted all over the place, firing when *they* think the time is right, which may well be earlier than necessary.
"extra schedule points all over the place", that's the -preempt kernel not the lowlatency kernel! (on yeah, you don't see them in the source but ask your CPU if it sees them)
Quoted 3 lines
The preemptible approach is much less of a maintainance headache, since people don't have to be constantly doing audits to see if something changed, and going in to fiddle with scheduling points.
this yes, it requires less maintainance, but still you should keep in mind the details about the spinlocks, things like the checks the VM does in shrink_cache are needed also with preemptive kernel.
Quoted 7 lines
Finally, with preemption, rescheduling can be forced with essentially zero latency in response to an arbitrary interrupt such as IO completion, whereas the non-preemptive kernel will have to 'coast to a stop'. In other words, the non-preemptive kernel will have little lags between successive IOs, whereas the preemptive kernel can submit the next IO immediately. So there are bound to be loads where the preemptive kernel turns in better latency *and throughput* than the scheduling point hack.
The I/O pipeline is big enough that a few msec before or later in a submit_bh shouldn't make a difference, the batch logic in the ll_rw_block layer also try to reduce the reschedule, and last but not the least if the task is I/O bound preemptive kernel or not won't make any difference in the submit_bh latency because no task is eating cpu and latency will be the one of pure schedule call.
Quoted 3 lines
Mind you, I'm not devaluing Andrew's work, it's good and valuable. However it's good to be aware of why that approach can't equal the latency-busting performance of the preemptive approach.
I also don't want to devaluate the preemptive kernel approch (the mean latency it can reach is lower than the one of the lowlat kernel, however I personally care only about worst case latency and this is why I don't feel the need of -preempt), but I just wanted to make clear that the idea that is floating around that preemptive kernel is all goodness is very far from reality, you get very low mean latency but at a price.
Andrea
Quoted 7 lines · Andrea Arcangeli
Quoted 3 lines
The preemptible approach is much less of a maintainance headache, since people don't have to be constantly doing audits to see if something changed, and going in to fiddle with scheduling points.
this yes, it requires less maintainance, but still you should keep in mind the details about the spinlocks, things like the checks the VM does in
shrink_cacheare needed also with preemptive kernel.
Yes of course, the spinlock regions still have to be analyzed and both patches have to be maintained for that. Long duration spinlocks are bad by any measure, and have to be dealt with anyway.
Quoted 8 lines
Quoted 7 lines
Finally, with preemption, rescheduling can be forced with essentially zero latency in response to an arbitrary interrupt such as IO completion, whereas the non-preemptive kernel will have to 'coast to a stop'. In other words, the non-preemptive kernel will have little lags between successive IOs, whereas the preemptive kernel can submit the next IO immediately. So there are bound to be loads where the preemptive kernel turns in better latency *and throughput* than the scheduling point hack.
Quoted 6 lines
The I/O pipeline is big enough that a few msec before or later in a
submit_bhshouldn't make a difference, the batch logic in thell_rw_blocklayer also try to reduce the reschedule, and last but not the least if the task is I/O bound preemptive kernel or not won't make any difference in thesubmit_bhlatency because no task is eating cpu and latency will be the one of pure schedule call.
That's not correct. For one thing, you don't know that no task is eating CPU, or that nobody is hogging the kernel. Look at the above, and consider the part about the little lags between IOs.
Quoted 8 lines
Quoted 3 lines
Mind you, I'm not devaluing Andrew's work, it's good and valuable. However it's good to be aware of why that approach can't equal the latency-busting performance of the preemptive approach.
I also don't want to devaluate the preemptive kernel approch (the mean latency it can reach is lower than the one of the lowlat kernel, however I personally care only about worst case latency and this is why I don't feel the need of -preempt),
This is exactly the case that -preempt handles well. On the other hand, trying to show that scheduling hacks satisfy any given latency bound is equivalent to solving the halting problem.
I thought you had done some real time work?
Quoted 3 lines
but I just wanted to make clear that the
idea that is floating around that preemptive kernel is all goodness is very far from reality, you get very low mean latency but at a price.
A price lots of people are willing to pay.
By the way, have you measured the cost of -preempt in practice?
--
Daniel
Quoted 28 lines · Daniel Phillips
Quoted 7 lines · Andrea Arcangeli
Quoted 3 lines
The preemptible approach is much less of a maintainance headache, since people don't have to be constantly doing audits to see if something changed, and going in to fiddle with scheduling points.
this yes, it requires less maintainance, but still you should keep in mind the details about the spinlocks, things like the checks the VM does in
shrink_cacheare needed also with preemptive kernel.Yes of course, the spinlock regions still have to be analyzed and both patches have to be maintained for that. Long duration spinlocks are bad by any measure, and have to be dealt with anyway.
Quoted 8 lines
Quoted 7 lines
Finally, with preemption, rescheduling can be forced with essentially zero latency in response to an arbitrary interrupt such as IO completion, whereas the non-preemptive kernel will have to 'coast to a stop'. In other words, the non-preemptive kernel will have little lags between successive IOs, whereas the preemptive kernel can submit the next IO immediately. So there are bound to be loads where the preemptive kernel turns in better latency *and throughput* than the scheduling point hack.
Quoted 6 lines
The I/O pipeline is big enough that a few msec before or later in a
submit_bhshouldn't make a difference, the batch logic in thell_rw_blocklayer also try to reduce the reschedule, and last but not the least if the task is I/O bound preemptive kernel or not won't make any difference in thesubmit_bhlatency because no task is eating cpu and latency will be the one of pure schedule call.
Quoted 3 lines
That's not correct. For one thing, you don't know that no task is eating CPU, or that nobody is hogging the kernel. Look at the above, and consider the part about the little lags between IOs.
We agree. Actually "if the task is I/O bound", I meant "if nobody is hogging CPU", I exactly wanted to make the example of no task hogging CPU in general.
Quoted 13 lines
Quoted 8 lines
Quoted 3 lines
Mind you, I'm not devaluing Andrew's work, it's good and valuable. However it's good to be aware of why that approach can't equal the latency-busting performance of the preemptive approach.
I also don't want to devaluate the preemptive kernel approch (the mean latency it can reach is lower than the one of the lowlat kernel, however I personally care only about worst case latency and this is why I don't feel the need of -preempt),
This is exactly the case that -preempt handles well. On the other hand, trying to show that scheduling hacks satisfy any given latency bound is equivalent to solving the halting problem.
Quoted 7 lines
I thought you had done some real time work?
Quoted 3 lines
but I just wanted to make clear that the
idea that is floating around that preemptive kernel is all goodness is very far from reality, you get very low mean latency but at a price.A price lots of people are willing to pay.
I'm not convinced that all those people knows exactly what they're buying then 8).
Quoted 2 lines
By the way, have you measured the cost of -preempt in practice?
dropping the lock in spin_unlock made a difference in the numbers, so the overhead must be definitely visible, by simply loading the system with threaded kernel computation (like webserving etc..etc..).
Andrea
Quoted 17 lines · Andrea Arcangeli
Quoted 4 lines · Luigi Genoni
On Tue, 8 Jan 2002, Dieter [iso-8859-15] Nützel wrote (passim):
Quoted 8 lines
Quoted 2 lines
Is it possible to decide, now what should go into 2.4.18 (maybe -pre3) -aa or -rmap?
[...]
Quoted 4 lines
Maybe preemption? It is disengageable so nobody should be harmed but we get the chance for wider testing.
Any comments?
preemption?? this is eventually 2.5 stuff, and should not be integrated
indeed ("eventually" in the italian sense btw, obvious to me, but not for l-k).
Quoted 9 lines
I'm not against preemption (I can see the benefits about the mean latency for real time DSP) but the claims about preemption making the kernel faster doesn't make sense to me. more frequent scheduling, overhead of branches in the locks (you've to
conditional_scheduleafter the last preemption lock is released and the cachelines for the per-cpu preemption locks) and the other preemption stuff can only make the kernel slower. Furthmore for multimedia playback any sane kernel out there with lowlatency fixes applied will work as well as a preemption kernel that pays for all the preemption overhead.
I would add that preemption simply gives a felling of more speed with interactive usage (with one single user on the system), and also has some advantages for dedicated servers, but except of those conditions it never showed in my experience to be a real and decisive advantage. Of course we are supposing that the preemptive scheduler is very well done, because otherway (bad working scheduler) there is nothing worse than preemption.
Quoted 9 lines
About the other claim that as the kernel becomes more granular performance will increase with preemption in kernel, that's obviously wrong as well, it's clearly the other way around. Maybe it was meant "latency will decrease further", that's right, but also performance will decrease if something.
So yes, mean latency will decrease with preemptive kernel, but your CPU is definitely paying something for it.
agreed. Obviously this choice depends on what you want to do with your system. If you have more than a couple of interactive users (and here I have also 50 interactive users at the same time on every single system), preemption is not what you want, period. If you have a desktop system, well, it is a different situation.
Quoted 5 lines
Quoted 4 lines
into 2.4 stable tree. Of course a backport is possible, when/if it will be quite well tested and well working on 2.5
Andrea
Luigi
Quoted 6 lines · Daniel Phillips
Quoted 4 lines · Anton Blanchard
Quoted 2 lines · Andrea Arcangeli [apparently]
So yes, mean latency will decrease with preemptive kernel, but your CPU is definitely paying something for it.
Quoted 6 lines
Quoted 2 lines
And Andrew Morton's work suggests he can do a much better job of reducing latency than -preempt.
That's not a particularly clueful comment, Anton. Obviously, any latency-busting hacks that Andrew does could also be patched into a -preempt kernel.
Yes. The important part is the implicit dropping of the BKL across schedule().
Quoted 4 lines
What a preemptible kernel can do that a non-preemptible kernel can't is:
reschedule exactly as often as necessary, instead of having lots of extra schedule points inserted all over the place, firing when *they* think the time is right, which may well be earlier than necessary.
Nope. `if (current->need_resched)' -> the time is right (beyond right, actually).
Quoted 3 lines
The preemptible approach is much less of a maintainance headache, since people don't have to be constantly doing audits to see if something changed, and going in to fiddle with scheduling points.
Except it doesn't work. The full-on low-latency patch has ~60 rescheduling points. Of these, ~40 involve popping spinlocks. Really, the only significant latency sources which the preemptible kernel solves are generic_file_read() and generic_file_write().
So preemptible kernel needs lock-break to be useful. And then it's basically the same thing, with the same maintainability problems. And believe me, these are considerable. Mainly because the areas which needs busting up exactly coincide with the areas where there has been most churn in the kernel.
Quoted 7 lines
Finally, with preemption, rescheduling can be forced with essentially zero latency in response to an arbitrary interrupt such as IO completion, whereas the non-preemptive kernel will have to 'coast to a stop'. In other words, the non-preemptive kernel will have little lags between successive IOs, whereas the preemptive kernel can submit the next IO immediately. So there are bound to be loads where the preemptive kernel turns in better latency *and throughput* than the scheduling point hack.
Latency yes. Throughout no.
I don't think the "preempt slows down the kernel" argument is very valid really. Let's invert the argument - Linux is multitasking, and that has a cost. There's no reason why certain bits of the kernel need to violate that just to get a bit more throughput. If it really worries you, set HZ=10 and increase all the timeslices, etc.
Now, there *may* be overheads added due to losing the implicit locking which per-CPU data gives you.
The main cost of preempt IMO is in complexity and stability risks.
(BTW: I took a weird oops testing the preempt patch on an SMP NFS client. The fault address was 0x0aXXXXXX. No useful backtrace, unfortunately).
Quoted 3 lines
Mind you, I'm not devaluing Andrew's work, it's good and valuable. However it's good to be aware of why that approach can't equal the latency-busting performance of the preemptive approach.
There's no point in just merging the preempt patch and saying "there, that's done". It doesn't do anything.
Instead, a decision needs to be made: "Linux will henceforth be a low-latency kernel". Now, IF we can come to this decision, then internal preemption is the way to do it. But it affects ALL kernel developers. Because we'll need to introduce a new rule: "it is a bug to spend more than five milliseconds holding any locks".
So. Do we we want a low-latency kernel? Are we prepared to mandate
the five-millisecond rule? It can be done, but won't be easy, and
we'll never get complete coverage. But I don't see the will around here.
-
Quoted 5 lines · Andrew Morton
There's no point in just merging the preempt patch and saying "there, that's done". It doesn't do anything.
Instead, a decision needs to be made: "Linux will henceforth be a low-latency kernel".
I thought the intention was to make it a config option?
Quoted 9 lines
Now, IF we can come to this decision, then
internal preemption is the way to do it. But it affects ALL kernel developers. Because we'll need to introduce a new rule: "it is a bug to spend more than five milliseconds holding any locks".So. Do we we want a low-latency kernel? Are we prepared to mandate
the five-millisecond rule? It can be done, but won't be easy, and
we'll never get complete coverage. But I don't see the will around here.
At least the flaming has gotten a little less ;-)
--
Daniel
Quoted 2 lines
low-latency kernel". Now, IF we can come to this decision, then internal preemption is the way to do it. But it affects ALL kernel
The pre-empt patches just make things much much harder to debug. They remove some of the predictability and the normal call chain following goes out of the window because you end up seeing crashes in a thread with no idea what ran the microsecond before
Some of that happens now but this makes it vastly worse.
The low latency patches don't change the basic predictability and debuggability but allow you to hit a 1mS pre-empt target for the general case.
Alan
Quoted 3 lines · Andrea Arcangeli
"extra schedule points all over the place", that's the -preempt kernel not the lowlatency kernel! (on yeah, you don't see them in the source but ask your CPU if it sees them)
How so? The branch on drop of the last lock? It's not a factor in profiles I've seen. And it is marked unlikely. The other change is the usual check for reschedule on return from interrupt, but that is the case already, we just allow it when in-kernel, too.
This makes me think the end conclusion would be that preemptive multitasking in general is bad. Why don't we increase the timeslice and and tick period, in that case?
One can argue the complexity degrades performance, but tests show otherwise. In throughput and latency. Besides, like I always say, its an option that uses existing kernel (SMP lock) infrastructure. You don't have to use it ;)
Quoted 7 lines
Quoted 3 lines
The preemptible approach is much less of a maintainance headache, since people don't have to be constantly doing audits to see if something changed, and going in to fiddle with scheduling points.
this yes, it requires less maintainance, but still you should keep in mind the details about the spinlocks, things like the checks the VM does in
shrink_cacheare needed also with preemptive kernel.
They impact SMP in the same way they impact preempt-kernel. Long-held locks are never good. Weird locking rules are never good.
Quoted 6 lines
The I/O pipeline is big enough that a few msec before or later in a
submit_bhshouldn't make a difference, the batch logic in thell_rw_blocklayer also try to reduce the reschedule, and last but not the least if the task is I/O bound preemptive kernel or not won't make any difference in thesubmit_bhlatency because no task is eating cpu and latency will be the one of pure schedule call.
Yet throughput tests show marked increase. I believe this is true with Andrew's patch, too. We multitask better. We dispatch waiting tasks faster. Without the patch, a queued I/O task may stall for sometime waiting for some hog to get out of the kernel.
Although the patch's goal is to improve interactivity (*), no one says the higher priority task we preempt in favor of has to be CPU-bound. A woken up I/O-bound task is just as benefiting from the patch.
(*) this is, IMO, where we benefit most though. By far the most pleasing benchmark isn't to see some x% decrease in latency or y more MB/s in bonnie, but to feel the improvement in interactivity. On a multitasking desktop, it is noticeable.
Quoted 6 lines
I also don't want to devaluate the preemptive kernel approch (the mean latency it can reach is lower than the one of the lowlat kernel, however I personally care only about worst case latency and this is why I don't feel the need of -preempt), but I just wanted to make clear that the idea that is floating around that preemptive kernel is all goodness is very far from reality, you get very low mean latency but at a price.
Andrea, I don't want you or anyone to believe preemption is a free ride. On the other hand, the patch has a _huge_ userbase and you can't question that. You also can't question the benchmarks that show improvements in average _and_ worst case latency _and_ throughput.
I don't expect you to use the patch. If it were merged, it is an option. It provides a framework for continuing to improve latency. It is a solution to the problem (i.e. latency is poor because the kernel is non-preemptible) instead of a hack. I agree worst-case latency is important, and I agree the patch shines more so in average case. But we do affect worse-case. And now a framework exists for working on fixing the worst-case latencies too. And in the end, its just an option for some, but a better kernel for others.
Robert Love
Quoted 8 lines · Andrew Morton
Quoted 4 lines · Daniel Phillips
What a preemptible kernel can do that a non-preemptible kernel can't is:
reschedule exactly as often as necessary, instead of having lots of extra schedule points inserted all over the place, firing when *they* think the time is right, which may well be earlier than necessary.Nope. `if (
current->need_resched)' -> the time is right (beyond right, actually).
Oops, sorry, right.
The preemptible kernel can reschedule, on average, sooner than the scheduling-point kernel, which has to wait for a scheduling point to roll around.
And while I'm enumerating differences, the preemptable kernel (in this incarnation) has a slight per-spinlock cost, while the non-preemptable kernel has the fixed cost of checking for rescheduling, at intervals throughout all 'interesting' kernel code, essentially all long-running loops. But by clever coding it's possible to finesse away almost all the overhead of those loop checks, so in the end, the non-preemptible low-latency patch has a slight efficiency advantage here, with emphasis on 'slight'.
--
Daniel
Quoted 7 lines · Andrew Morton
Quoted 4 lines
What a preemptible kernel can do that a non-preemptible kernel can't is:
reschedule exactly as often as necessary, instead of having lots of extra schedule points inserted all over the place, firing when *they* think the time is right, which may well be earlier than necessary.Nope. `if (
current->need_resched)' -> the time is right (beyond right, actually).
Eh, I disagree here. The right time is the moment a high-priority task becomes runnable. Given your HZ, only a fully preemptible kernel can come close to meeting that.
Quoted 9 lines
Quoted 7 lines
Finally, with preemption, rescheduling can be forced with essentially zero latency in response to an arbitrary interrupt such as IO completion, whereas the non-preemptive kernel will have to 'coast to a stop'. In other words, the non-preemptive kernel will have little lags between successive IOs, whereas the preemptive kernel can submit the next IO immediately. So there are bound to be loads where the preemptive kernel turns in better latency *and throughput* than the scheduling point hack.
Latency yes. Throughout no.
I bet in _many_ (most?) workloads the preemptible kernel turns in better throughput. Anytime there is load on the system, there should be a benefit. I bet the same goes for your patch. I've certainly verified it for both in various loads myself.
Quoted 5 lines
I don't think the "preempt slows down the kernel" argument is very valid really. Let's invert the argument - Linux is multitasking, and that has a cost. There's no reason why certain bits of the kernel need to violate that just to get a bit more throughput. If it really worries you, set HZ=10 and increase all the timeslices, etc.
Very well said. I always find an answer to the "more complexity, more context switching, blah blah" arguments as ultimately being arguments tantamount to "preemptive multitasking sucks".
Quoted 2 lines
Now, there *may* be overheads added due to losing the implicit locking which per-CPU data gives you.
Perhaps, but note what preempt enable and disable statements effectively
are: an inc and a dec. Not even atomic.
Yes, there is a branch on reenable. This may be an interesting change to look into. FWIW, we have a construct that doesn't check for reschedule on reenable, too.
Quoted 4 lines
The main cost of preempt IMO is in complexity and stability risks.
(BTW: I took a weird oops testing the preempt patch on an SMP NFS client. The fault address was 0x0aXXXXXX. No useful backtrace, unfortunately).
Should of sent me the oops :)
Quoted 13 lines
Quoted 3 lines
Mind you, I'm not devaluing Andrew's work, it's good and valuable. However it's good to be aware of why that approach can't equal the latency-busting performance of the preemptive approach.
There's no point in just merging the preempt patch and saying "there, that's done". It doesn't do anything.
Instead, a decision needs to be made: "Linux will henceforth be a low-latency kernel". Now, IF we can come to this decision, then internal preemption is the way to do it. But it affects ALL kernel developers. Because we'll need to introduce a new rule: "it is a bug to spend more than five milliseconds holding any locks".
Quoted 4 lines
So. Do we we want a low-latency kernel? Are we prepared to mandate
the five-millisecond rule? It can be done, but won't be easy, and
we'll never get complete coverage. But I don't see the will around here.
I agree here, but then I do have three points:
- proper lock use that benefits SMP scalability benefits preempt-kernel induced latency improvements. In other words, things like short lock durations, fine-grained locking, and ditching the BKL benefit both worlds.
- with the preemptible kernel in place, we can look at the long-held locks and figure ways to combat them. The preempt-stats patch helps us find them. Then, we can take a lock-break approach. We can look into finer grained locks. We can localize lock the lock if it is global or the BKL. Or we can do something radical like make long-held spinlocks priority-inheriting when preempt-kernel is enabled. In other words, preempt-kernel becomes a framework for proper solutions in the future.
- finally, the usual: it's an option.
Robert Love
Quoted 3 lines · Daniel Phillips
The preemptible kernel can reschedule, on average, sooner than the scheduling-point kernel, which has to wait for a scheduling point to roll around.
The preemptible kernel ALSO has to wait for a scheduling point to roll around, since it cannot preempt with spinlocks held.
Considering this, I don't see much of an advantage to adding kernel preemption.
regards,
Rik
Signature · 4 lines
"Linux holds advantages over the single-vendor commercial OS"
-- Microsoft's "Competing with Linux" document
http://www.surriel.com/ http://distro.conectiva.com/Quoted 5 lines · Rik van Riel
The preemptible kernel ALSO has to wait for a scheduling point to roll around, since it cannot preempt with spinlocks held.
Considering this, I don't see much of an advantage to adding kernel preemption.
It only has to wait if locks are held and then only until the locks are dropped. Otherwise it will preempt on the next return from interrupt.
Future work would be to look into long-held locks and see what we can do.
Without preempt-kernel, we have none of this: either run until completion or explicit scheduling points.
Robert Love
Quoted 7 lines · Daniel Phillips
And while I'm enumerating differences, the preemptable kernel (in this incarnation) has a slight per-spinlock cost, while the non-preemptable kernel has the fixed cost of checking for rescheduling, at intervals throughout all 'interesting' kernel code, essentially all long-running loops. But by clever coding it's possible to finesse away almost all the overhead of those loop checks, so in the end, the non-preemptible low-latency patch has a slight efficiency advantage here, with emphasis on 'slight'.
True (re spinlock weight in preemptible kernel) but how is that not comparable to explicit scheduling points? Worse, the preempt-kernel typically does its preemption on a branch on return to interrupt (similar to user space's preemption). What better time to check and reschedule if needed?
Robert Love
Quoted 4 lines · Daniel Phillips
Quoted 2 lines
Instead, a decision needs to be made: "Linux will henceforth be a low-latency kernel".
I thought the intention was to make it a config option?
It was originally, it is now, and I intend it to be.
Further, since it uses the existing SMP locks, it doesn't introduce new design decisions (the one being protection of implicitly locked per-CPU data on preempt).
Robert Love
Quoted 8 lines · Daniel Phillips
Quoted 6 lines · Andrew Morton
Quoted 4 lines · Daniel Phillips
What a preemptible kernel can do that a non-preemptible kernel can't is:
reschedule exactly as often as necessary, instead of having lots of extra schedule points inserted all over the place, firing when *they* think the time is right, which may well be earlier than necessary.
Quoted 8 lines
Quoted 2 lines
Nope. `if (
current->need_resched)' -> the time is right (beyond right, actually).Oops, sorry, right.
The preemptible kernel can reschedule, on average, sooner than the scheduling-point kernel, which has to wait for a scheduling point to roll around.
That's theory. Practice (ie: instrumentation) says that the preempt patch makes little improvement over conditional yields in generic_file_read() and generic_file_write(). Four lines. Additional yields in wait_for_buffers() (where we move zillions of buffers from BUF_LOCKED to BUF_CLEAN) and in submit_bh() and bread() are cream.
Preemptability is global in its impact, and in its effect. It requires global changes to make it useful. If we're prepared to make those changes (scan_swap_map, truncate_inode_pages, etc) then fine. Go for it. We'll end up with a better kernel.
Quoted 8 lines
And while I'm enumerating differences, the preemptable kernel (in this incarnation) has a slight per-spinlock cost, while the non-preemptable kernel has the fixed cost of checking for rescheduling, at intervals throughout all 'interesting' kernel code, essentially all long-running loops. But by clever coding it's possible to finesse away almost all the overhead of those loop checks, so in the end, the non-preemptible low-latency patch has a slight efficiency advantage here, with emphasis on 'slight'.
As I said: I don't buy the efficiency worries at all. If scheduling pressure is so high that either approach impacts performance, then scheduling pressure is too high. We need to fix the context switch rate and/or speed up context switches. The overhead of conditional_schedule() or preempt will be zilch.
-
Quoted 10 lines · Robert Love
Quoted 5 lines · Rik van Riel
The preemptible kernel ALSO has to wait for a scheduling point to roll around, since it cannot preempt with spinlocks held.
Considering this, I don't see much of an advantage to adding kernel preemption.
It only has to wait if locks are held and then only until the locks are dropped. Otherwise it will preempt on the next return from interrupt.
So what exactly _is_ the difference between an explicit preemption point and a place where we need to explicitly drop a spinlock ?
Quoted 4 lines
From what I can see, there really isn't a difference.
Future work would be to look into long-held locks and see what we can do.
One thing we could do is download Andrew Morton's patch ;)
Rik
Signature · 4 lines
"Linux holds advantages over the single-vendor commercial OS"
-- Microsoft's "Competing with Linux" document
http://www.surriel.com/ http://distro.conectiva.com/Quoted 3 lines · Rik van Riel
So what exactly _is_ the difference between an explicit preemption point and a place where we need to explicitly drop a spinlock ?
In that case nothing, except that when we drop the lock and check it is the earliest place where preemption is allowed. In the normal scenario, however, we have a check for reschedule on return from interrupt (e.g. the timer) and thus preempt in the same manner as with user space and that is the key.
Quoted 4 lines
Quoted 2 lines
Future work would be to look into long-held locks and see what we can do.
One thing we could do is download Andrew Morton's patch ;)
That is certainly one option, and Andrew's patch is very good. Nonetheless, I think we need a more general framework that tackles the problem itself. Preemptible kernel does this, yields results now, and allows for greater return later on.
Robert Love
Quoted 8 lines · Rik van Riel
Quoted 3 lines · Daniel Phillips
The preemptible kernel can reschedule, on average, sooner than the scheduling-point kernel, which has to wait for a scheduling point to roll around.
The preemptible kernel ALSO has to wait for a scheduling point to roll around, since it cannot preempt with spinlocks held.
Think about the relative amount of time spent inside spinlocks vs regular kernel.
Quoted 2 lines
Considering this, I don't see much of an advantage to adding kernel preemption.
And now?
--
Daniel
Quoted 10 lines · Robert Love
Quoted 7 lines · Daniel Phillips
And while I'm enumerating differences, the preemptable kernel (in this incarnation) has a slight per-spinlock cost, while the non-preemptable kernel has the fixed cost of checking for rescheduling, at intervals throughout all 'interesting' kernel code, essentially all long-running loops. But by clever coding it's possible to finesse away almost all the overhead of those loop checks, so in the end, the non-preemptible low-latency patch has a slight efficiency advantage here, with emphasis on 'slight'.
Quoted 5 lines
True (re spinlock weight in preemptible kernel) but how is that not comparable to explicit scheduling points? Worse, the preempt-kernel typically does its preemption on a branch on return to interrupt (similar to user space's preemption). What better time to check and reschedule if needed?
The per-spinlock cost I was refering to is the cost of the inc/dec per spinlock. I guess this cost is small enough as to be hard to measure, but I have not tried so I don't know. Curiously, none of the people I've heard making pronouncements on the overhead of your preempt patch seem to have measured it either.
--
Daniel
Quoted 11 lines · Daniel Phillips
Quoted 5 lines
True (re spinlock weight in preemptible kernel) but how is that not comparable to explicit scheduling points? Worse, the preempt-kernel typically does its preemption on a branch on return to interrupt (similar to user space's preemption). What better time to check and reschedule if needed?
The per-spinlock cost I was refering to is the cost of the inc/dec per spinlock. I guess this cost is small enough as to be hard to measure, but I have not tried so I don't know. Curiously, none of the people I've heard making pronouncements on the overhead of your preempt patch seem to have measured it either.
;-)
If they did I suspect it would be minimal. Andrew's point on complexity and overhead in this manner is exact -- such thinks are just not an issue.
I see two valid arguments against kernel preemption, and I'll be the first to admit them:
- we introduce new problems with kernel programming. specifically, the issue with implicitly locked per-CPU data. honestly, this isn't a huge deal. I've been working on preempt-kernel for awhile now and the problems we have found and fixed are minimal. admittedly, however, especially wrt the future, preempt-kernel may introduce new concerns. I say let's rise to meet them.
- we don't do enough for the worst-case latency. this is where future work is useful and where preempt-kernel provides the framework for a better kernel.
I want a better kernel. Hell, I want the best kernel. In my opinion, one factor of that is having a preemptible kernel.
Robert Love
Quoted 8 lines · Alan Cox
Quoted 2 lines
low-latency kernel". Now, IF we can come to this decision, then internal preemption is the way to do it. But it affects ALL kernel
The pre-empt patches just make things much much harder to debug. They remove some of the predictability and the normal call chain following goes out of the window because you end up seeing crashes in a thread with no idea what ran the microsecond before
Quoted 6 lines
Some of that happens now but this makes it vastly worse.
The low latency patches don't change the basic predictability and debuggability but allow you to hit a 1mS pre-empt target for the general case.
Yes, it does make things much much harder to debug - but:
* If you get a problem on a preemtive UP kernel, it is likely to be a problem on a SMP too - and those are hard to debug aswell. But the positive aspect is that you get more people that can do the debugging... :-) (One CPU gets delayed with handling a IRQ the other runs into the critical section)
* It is optional at compile time.
And could even be made run time optional / CPU ! Just set a too big value on the counter and it will never reschedule...
/RogerL
Signature · 3 lines
Roger Larsson Skellefteå Sweden
Quoted 8 lines · Daniel Phillips
Quoted 6 lines · Andrew Morton
Quoted 4 lines · Daniel Phillips
What a preemptible kernel can do that a non-preemptible kernel can't is:
reschedule exactly as often as necessary, instead of having lots of extra schedule points inserted all over the place, firing when *they* think the time is right, which may well be earlier than necessary.
Quoted 9 lines
Quoted 2 lines
Nope. `if (
current->need_resched)' -> the time is right (beyond right, actually).Oops, sorry, right.
The preemptible kernel can reschedule, on average, sooner than the scheduling-point kernel, which has to wait for a scheduling point to roll around.
Yes. It can also fix problematic areas which my testing didn't cover.
Incidentally, there's the SMP problem. Suppose we have the code:
lock_kernel();
for (lots) {
do(something sucky);
if (current->need_resched)
schedule();
}
unlock_kernel();This works fine on UP, but not on SMP. The scenario:
- CPU A runs this loop.
- CPU B is spinning on the lock.
- Interrupt occurs, kernel elects to run RT task on CPU B. CPU A doesn't have need_resched set, and just keeps on going. CPU B is stuck spinning on the lock.
This is only an issue for the low-latency patch - all the other approaches still have sufficiently bad worse-case that this scenario isn't worth worrying about.
I toyed with creating spin_lock_while_polling_resched(), but ended up changing the scheduler to set need_resched against _all_ CPUs if an RT task is being woken (yes, yuk).
-
Quoted 7 lines · Robert Love
Quoted 3 lines · Rik van Riel
So what exactly _is_ the difference between an explicit preemption point and a place where we need to explicitly drop a spinlock ?
Quoted 5 lines
In that case nothing, except that when we drop the lock and check it is the earliest place where preemption is allowed. In the normal scenario, however, we have a check for reschedule on return from interrupt (e.g. the timer) and thus preempt in the same manner as with user space and that is the key.
One could do:
static inline void spin_unlock(spinlock_t *lock)
{
__asm__ __volatile__(
spin_unlock_string
);
if (--current->lock_depth == 0 &&
current->need_resched &&
current->state == TASK_RUNNING)
schedule();
}But I have generally avoided "global" solutions like this, in favour of nailing the _specific_ code which is causing the problem. Which is a lot more work, but more useful.
The scheduling points in bread() and submit_bh() in the mini-ll patch go against this (masochistic) philosophy.
Quoted 9 lines
Quoted 4 lines
Quoted 2 lines
Future work would be to look into long-held locks and see what we can do.
One thing we could do is download Andrew Morton's patch ;)
That is certainly one option, and Andrew's patch is very good. Nonetheless, I think we need a more general framework that tackles the problem itself. Preemptible kernel does this, yields results now, and allows for greater return later on.
We need something which makes 2.4.x not suck.
-
Quoted 45 lines · Daniel Phillips
Quoted 7 lines · Andrea Arcangeli
Quoted 3 lines
The preemptible approach is much less of a maintainance headache, since people don't have to be constantly doing audits to see if something changed, and going in to fiddle with scheduling points.
this yes, it requires less maintainance, but still you should keep in mind the details about the spinlocks, things like the checks the VM does in
shrink_cacheare needed also with preemptive kernel.Yes of course, the spinlock regions still have to be analyzed and both patches have to be maintained for that. Long duration spinlocks are bad by any measure, and have to be dealt with anyway.
Quoted 8 lines
Quoted 7 lines
Finally, with preemption, rescheduling can be forced with essentially zero latency in response to an arbitrary interrupt such as IO completion, whereas the non-preemptive kernel will have to 'coast to a stop'. In other words, the non-preemptive kernel will have little lags between successive IOs, whereas the preemptive kernel can submit the next IO immediately. So there are bound to be loads where the preemptive kernel turns in better latency *and throughput* than the scheduling point hack.
Quoted 6 lines
The I/O pipeline is big enough that a few msec before or later in a
submit_bhshouldn't make a difference, the batch logic in thell_rw_blocklayer also try to reduce the reschedule, and last but not the least if the task is I/O bound preemptive kernel or not won't make any difference in thesubmit_bhlatency because no task is eating cpu and latency will be the one of pure schedule call.That's not correct. For one thing, you don't know that no task is eating CPU, or that nobody is hogging the kernel. Look at the above, and consider the part about the little lags between IOs.
Quoted 8 lines
Quoted 3 lines
Mind you, I'm not devaluing Andrew's work, it's good and valuable. However it's good to be aware of why that approach can't equal the latency-busting performance of the preemptive approach.
I also don't want to devaluate the preemptive kernel approch (the mean latency it can reach is lower than the one of the lowlat kernel, however I personally care only about worst case latency and this is why I don't feel the need of -preempt),
This is exactly the case that -preempt handles well. On the other hand, trying to show that scheduling hacks satisfy any given latency bound is equivalent to solving the halting problem.
Quoted 7 lines
I thought you had done some real time work?
Quoted 3 lines
but I just wanted to make clear that the
idea that is floating around that preemptive kernel is all goodness is very far from reality, you get very low mean latency but at a price.A price lots of people are willing to pay
Probably sometimes they are not making a good business. In the reality preempt is good in many scenarios, as I said, and I agree that for desktops, and dedicated servers where just one application runs, and probably the CPU is idle the most of the time, indeed users have a speed feeling. Please consider that on eavilly loaded servers, with 40 and more users, some are running gcc, others g77, others g++ compilations, someone runs pine or mutt or kmail, and netscape, and mozilla, and emacs (someone form xterm kde or gnome), and and
and... You can have also 4/8 CPU butthey are not infinite ;) (but I talk mainly thinking of dualAthlon systems).
there is a lot of memory and disk I/O.
This is not a strange scenary on the interactive servers used at SNS. Here preempt has a too high price
Quoted 3 lines
By the way, have you measured the cost of -preempt in practice?
Yes, I did a lot of tests, and with current preempt patch definitelly I was seeing a too big performance loss.
Quoted 7 lines · Daniel Phillips
Quoted 6 lines · Andrew Morton
Quoted 4 lines · Daniel Phillips
What a preemptible kernel can do that a non-preemptible kernel can't is:
reschedule exactly as often as necessary, instead of having lots of extra schedule points inserted all over the place, firing when *they* think the time is right, which may well be earlier than necessary.
Quoted 9 lines
Quoted 2 lines
Nope. `if (
current->need_resched)' -> the time is right (beyond right, actually).Oops, sorry, right.
The preemptible kernel can reschedule, on average, sooner than the scheduling-point kernel, which has to wait for a scheduling point to roll around.
mmhhh. At which cost? And then anyway if I have a spinlock, I still have to wait for a scheduling point to roll around.
On Wed, Jan 09, 2002 at 12:02:48AM +0100, Luigi Genoni wrote:
| Probably sometimes they are not making a good business. In the reality | preempt is good in many scenarios, as I said, and I agree that for | desktops, and dedicated servers where just one application runs, and | probably the CPU is idle the most of the time, indeed users have a speed | feeling. Please consider that on eavilly loaded servers, with 40 and more | users, some are running gcc, others g77, others g++ compilations, someone | runs pine or mutt or kmail, and netscape, and mozilla, and emacs (someone | form xterm kde or gnome), and and | and... You can have also 4/8 CPU butthey are not infinite ;) (but I talk | mainly thinking of dualAthlon systems). | there is a lot of memory and disk I/O. | This is not a strange scenary on the interactive servers used at SNS. | Here preempt has a too high price
MacOS 9 is the OS for you.
Essentially what the low-latency patches are is cooperative multitasking. Which has less overhead in some cases than preemptive as long as everyone is equally nice and calls WaitNextEvent() within the right inner loops. In the absence of preemptive, Andrew's patch is the next best thing. But Bad Things happen without preemptive. Just try using Mac OS 9. ;)
Preemptive gives better interactivity under load, which is the whole point of multitasking (think about it). If you don't want the overhead (which also exists without preemptive) run #processes == #processors.
Whether or not preemptive is applied, having a large number of processes active is a performance hit from context switches, cache thrashing, etc. Preemptive punishes (and rewards) everyone equally, thus better latency.
I'm really surprised that people are still actually arguing _against_ preemptive multitasking in this day and age. This is a no-brainer in the long run, where current corner cases aren't holding us back.
At least IMVHO.
Signature · 14 lines
Ken. [email protected] | > By the way, have you measured the cost of -preempt in practice? | > | Yes, I did a lot of tests, and with current preempt patch definitelly | I was seeing a too big performance loss. | | | - | To unsubscribe from this list: send the line "unsubscribe linux-kernel" in | the body of a message to [email protected] | More majordomo info at http://vger.kernel.org/majordomo-info.html | Please read the FAQ at http://www.tux.org/lkml/
Quoted 28 lines · Ken Brownfield
On Wed, Jan 09, 2002 at 12:02:48AM +0100, Luigi Genoni wrote:
| Probably sometimes they are not making a good business. In the reality | preempt is good in many scenarios, as I said, and I agree that for | desktops, and dedicated servers where just one application runs, and | probably the CPU is idle the most of the time, indeed users have a speed | feeling. Please consider that on eavilly loaded servers, with 40 and more | users, some are running gcc, others g77, others g++ compilations, someone | runs pine or mutt or kmail, and netscape, and mozilla, and emacs (someone | form xterm kde or gnome), and and | and... You can have also 4/8 CPU butthey are not infinite ;) (but I talk | mainly thinking of dualAthlon systems). | there is a lot of memory and disk I/O. | This is not a strange scenary on the interactive servers used at SNS. | Here preempt has a too high priceMacOS 9 is the OS for you.
Essentially what the low-latency patches are is cooperative multitasking. Which has less overhead in some cases than preemptive as long as everyone is equally nice and calls
WaitNextEvent()within the right inner loops. In the absence of preemptive, Andrew's patch is the next best thing. But Bad Things happen without preemptive. Just try using Mac OS 9. ;)Preemptive gives better interactivity under load, which is the whole point of multitasking (think about it). If you don't want the overhead (which also exists without preemptive) run #processes == #processors.
Quoted 7 lines
Whether or not preemptive is applied, having a large number of processes active is a performance hit from context switches, cache thrashing, etc. Preemptive punishes (and rewards) everyone equally, thus better latency.
I'm really surprised that people are still actually arguing _against_ preemptive multitasking in this day and age. This is a no-brainer in the long run, where current corner cases aren't holding us back.
Amen.
Of course, the counter argument is that we, as kernel programmers, can design everything to behave kindly cooperatively. I reply "now that the kernel is SMP safe it is trivial to become preemptible" but some still don't take the patch. I'll keep trucking along.
Robert Love
Quoted 15 lines · Ken Brownfield
On Wed, Jan 09, 2002 at 12:02:48AM +0100, Luigi Genoni wrote:
| Probably sometimes they are not making a good business. In the reality | preempt is good in many scenarios, as I said, and I agree that for | desktops, and dedicated servers where just one application runs, and | probably the CPU is idle the most of the time, indeed users have a speed | feeling. Please consider that on eavilly loaded servers, with 40 and more | users, some are running gcc, others g77, others g++ compilations, someone | runs pine or mutt or kmail, and netscape, and mozilla, and emacs (someone | form xterm kde or gnome), and and | and... You can have also 4/8 CPU butthey are not infinite ;) (but I talk | mainly thinking of dualAthlon systems). | there is a lot of memory and disk I/O. | This is not a strange scenary on the interactive servers used at SNS. | Here preempt has a too high price
Quoted 8 lines
MacOS 9 is the OS for you.
Essentially what the low-latency patches are is cooperative multitasking. Which has less overhead in some cases than preemptive as long as everyone is equally nice and calls
WaitNextEvent()within the right inner loops. In the absence of preemptive, Andrew's patch is the next best thing. But Bad Things happen without preemptive. Just try using Mac OS 9 :)
Not exaclty what I was thinking about.
I listened some horror story from MAC sysadmin at SNS
Quoted 8 lines
Preemptive gives better interactivity under load, which is the whole point of multitasking (think about it). If you don't want the overhead (which also exists without preemptive) run #processes == #processors.
Whether or not preemptive is applied, having a large number of processes active is a performance hit from context switches, cache thrashing, etc. Preemptive punishes (and rewards) everyone equally, thus better latency.
you are supposing that I want them to be punished equally. But there are cases when that is not what you want ;). Thing if one users runs a montecarlo code for test in the server I was describing. This job could run, let's say, a couple of hour, and also under nice 20 it can suck a lot.
Quoted 6 lines
I'm really surprised that people are still actually arguing _against_ preemptive multitasking in this day and age. This is a no-brainer in the long run, where current corner cases aren't holding us back.
At least IMVHO.
What I am talking about is some test I did some week ago. The initial post of this thread, I think, was very clear about that. On the long run, with a very well tested implementation. Actually it is not a good idea to insert preempt nside of the 2.4 stable tree,
because there is a lot of work to do
to get a very WELL TESTED implementation.
Quoted 3 lines
Preemptive gives better interactivity under load, which is the whole point of multitasking (think about it). If you don't want the overhead (which also exists without preemptive) run #processes == #processors.
That is generally not true. Pe-emption is used in user space to prevent applications doing very stupid things. Pre-emption in a trusted environment can often be most efficient if done by the programs themselves.
Userspace is not a trusted environment
Quoted 3 lines
I'm really surprised that people are still actually arguing _against_ preemptive multitasking in this day and age. This is a no-brainer in the long run, where current corner cases aren't holding us back.
Andrew's patches give you 1mS worst case latency for normal situations, that is below human perception, and below scheduling granularity. In other words without the efficiency loss and the debugging problems you can place the far enough latency below other effects that it isnt worth attacking any more.
Alan
Quoted 2 lines · Luigi Genoni
Quoted 1 line · Daniel Phillips
On January 8, 2002 04:29 pm, Andrea Arcangeli wrote:
[-]
Quoted 15 lines
Quoted 15 lines
Quoted 4 lines
I also don't want to devaluate the preemptive kernel approch (the mean latency it can reach is lower than the one of the lowlat kernel, however I personally care only about worst case latency and this is why I don't feel the need of -preempt),
This is exactly the case that -preempt handles well. On the other hand, trying to show that scheduling hacks satisfy any given latency bound is equivalent to solving the halting problem.
I thought you had done some real time work?
Quoted 3 lines
but I just wanted to make clear that the
idea that is floating around that preemptive kernel is all goodness is very far from reality, you get very low mean latency but at a price.
Quoted 6 lines
Quoted 1 line
A price lots of people are willing to pay
Probably sometimes they are not making a good business. In the reality preempt is good in many scenarios, as I said, and I agree that for desktops, and dedicated servers where just one application runs, and probably the CPU is idle the most of the time,
OK, good. You are much at the same line than I am.
Should we starting not only to differentiate between UP and SMP systems but allthought between desktop and (big) servers?
I remember one saying. "Think, this patch is worth only for ~0.05% of the Linux users..." (He meant the multi SMP system users.)
Allmost 99.95% of the Linux users running desktops and I am somewhat tiered of saying, "sorry, Linux is under development..."
Look at the imprint of the famous German ct magazine (they are not even known as Linux bashers...;-). It shows little penguins falling like domino stones (starting with 2.4.17).
Let me rephrase it:
I appreciate all your great work and I know "only" some (little) internals of it but we should do some interactivity improvements for the 2.4 kernel, too. I know what it's worth Andrew's (lowlatency patch) and Robert's (George Anzinger's) preempt patch. In short the system (bigger desktop) flies.
The holly grail would be a combination of preempt+lock-break plus lowlatency and Ingo's O(1) scheduler.
My main focus lies on 3D graphics not kernel and I use KDE (yes, a little luxury:-) 'cause KDE is C++ and most visualization systems are c and later c++.
Without the above patches even my 1 GHz Athlon II, 640 MB, feels sluggish. But I don't forget to think about throughput which is even usefull for "heavy" compiler runs...
Quoted 10 lines
indeed users have a speed
feeling. Please consider that on eavilly loaded servers, with 40 and more users, some are running gcc, others g77, others g++ compilations, someone runs pine or mutt or kmail, and netscape, and mozilla, and emacs (someone form xterm kde or gnome), and and
and... You can have also 4/8 CPU butthey are not infinite ;) (but I talk mainly thinking of dualAthlon systems).
there is a lot of memory and disk I/O.
This is not a strange scenary on the interactive servers used at SNS. Here preempt has a too high price
That's why preempt is a compile time option, btw.
Quoted 4 lines
Quoted 1 line
By the way, have you measured the cost of -preempt in practice?
Yes, I did a lot of tests, and with current preempt patch definitelly I was seeing a too big performance loss.
Have you tried with stock 2.4.17 or with additional patches? 2.4.17-rc2aa2 (10_vm-21)?
The later make big differences in throughput for me (with and without preempt).
I am under preparation of some numbers. Anybody want some special tests?
dbench (yes, I know...) with and without MP3 during run latencytest0.42-png
bonnie++getc_putc
Thank you for all your serious answers. This was definitely not intended as a flamewar start.
-Dieter
Signature · 6 lines
Dieter Nützel Graduate Student, Computer Science University of Hamburg Department of Computer Science @home: [email protected]
Quoted 9 lines · Alan Cox
Quoted 3 lines
Preemptive gives better interactivity under load, which is the whole point of multitasking (think about it). If you don't want the overhead (which also exists without preemptive) run #processes == #processors.
That is generally not true. Pe-emption is used in user space to prevent applications doing very stupid things. Pre-emption in a trusted environment can often be most efficient if done by the programs themselves.
Userspace is not a trusted environment
The best part about planned preemption points is that there is minimal state to save when an interruption occurs.
Quoted 9 lines
Quoted 4 lines
I'm really surprised that people are still actually arguing _against_ preemptive multitasking in this day and age. This is a no-brainer in the long run, where current corner cases aren't holding us back.
Andrew's patches give you 1mS worst case latency for normal situations, that is below human perception, and below scheduling granularity. In other words without the efficiency loss and the debugging problems you can place the far enough latency below other effects that it isnt worth attacking any more.
Incidently human visual perception runs around 200 milliseconds minimum and hearing/touch perception around 100 milliseconds if the signal has to go through the brain. Of course we extend our perceptions with tools/programs etc.
john
Quoted 7 lines · Andrew Morton
Quoted 4 lines
What a preemptible kernel can do that a non-preemptible kernel can't is:
reschedule exactly as often as necessary, instead of having lots of extra schedule points inserted all over the place, firing when *they* think the time is right, which may well be earlier than necessary.Nope. `if (
current->need_resched)' -> the time is right (beyond right, actually).
Have we ever considered making rescheduling work like get_user? That is, make current->need_resched be a pointer, and if we need to reschedule, make it an INVALID pointer that causes us to fault and call schedule in its fault path?
Orthogonally, for rescheduling points with locks, we could build a version of the spinlocks that know when they're blocking other processes and can do a spin_yield(&lock) in places where they can safely give up a lock. On single processor, spin_yield could translate to a scheduling point.
Signature · 1 line
"Love the dolphins," she advised him. "Write by W.A.S.T.E.."
Quoted 2 lines · John Alvord
The best part about planned preemption points is that there is minimal state to save when an interruption occurs.
Actually, both preempt-kernel and low-latency do about the same amount of work re saving state.
With preempt-kernel, when a task is preempted in-kernel we AND a flag value into the preempt count. That is all we need to keep track of things.
With low-latency, the task state is set to TASK_RUNNING (which is a precautionary measure). So it is about the same, although low-latency (and lock-break) often also have to do various setup with the locks and all.
Robert Love
Quoted 3 lines · Alan Cox
Andrew's patches give you 1mS worst case latency for normal situations, that is below human perception, and below scheduling granularity.
The full ll patch is pretty gruesome though.
The high-end audio synth guys claim that two milliseconds is getting to be too much. They are generating real-time audio and they do have more than one round-trip through the software. It adds up.
Linux is being used in so many different applications now. You are, I think, one of the stronger recognisers of the fact that we do not only use Linux to squirt out html and to provide shell prompts to snotty students. Good scheduling responsiveness is a valuable feature.
I haven't seen any figures for embedded XP, but it is said that if you bend over backwards you can get 10 milliseconds out of NT4, and 4-5 out of the fabled BeOS. This is one area where we can fairly easily be very much the best. It's low-hanging fruit.
Internal preemptability is, in my opinion, the best way to deliver this.
I accept your point about it making debugging harder - I would suggest that the preempt code be altered so that it can be disabled at runtime, rather than via a rebuild. I suspect this can be done at zero cost by setting init_task's preempt count to 1000000 via a kernel boot option. And at almost-zero cost via a sysctl.
I would further suggest that support be added to the kernel to allow general users to both detect and find the source of latency problems. That's actually pretty easy - realfeel running at 2 kHz only consumes 2-3% of the CPU. It can just be left ticking over in the background.
With preemptability merged in 2.5 we can then work to fix the long-held locks. Most of them are simple. Some of them are very much not. I'll gladly help with that.
-
Quoted 4 lines · Andrew Morton
[snip]
With preemptability merged in 2.5 we can then work to fix the long-held locks. Most of them are simple. Some of them are very much not. I'll gladly help with that.
Amen. Thank you, Andrew.
Let's work together and make a better kernel.
Robert Love
Quoted 9 lines · Luigi Genoni
Quoted 6 lines · Daniel Phillips
Quoted 3 lines · Andrea Arcangeli
but I just wanted to make clear that the
idea that is floating around that preemptive kernel is all goodness is very far from reality, you get very low mean latency but at a price.A price lots of people are willing to pay
Probably sometimes they are not making a good business.
Perhaps. But they are happy customers and their music sounds better.
Note: the dominating cost of -preempt is not Robert's patch, but the fact that you need to have CONFIG_SMP enabled, even for uniprocessor, turning all those stub macros into real spinlocks. For a dual processor you have to have this anyway and it just isn't an issue.
Personally, I don't intend to ever get another single-processor machine, except maybe a laptop, and that's only if Transmeta doesn't come up with a dual-processor laptop configuration.
Quoted 4 lines
Quoted 1 line
By the way, have you measured the cost of -preempt in practice?
Yes, I did a lot of tests, and with current preempt patch definitelly I was seeing a too big performance loss.
Was this on uniprocessor machines, or your dual Athlons? How did you measure the performance?
--
Daniel
Quoted 5 lines · Luigi Genoni
Quoted 3 lines · Daniel Phillips
Quoted 2 lines · Andrew Morton
Quoted 1 line · Daniel Phillips
What a preemptible kernel can do that a non-preemptible kernel can't
is:
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
reschedule exactly as often as necessary, instead of having lots of
extra
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
schedule points inserted all over the place, firing when *they* think
the
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 1 line
time is right, which may well be earlier than necessary.
Nope. `if (
current->need_resched)' -> the time is right (beyond right, actually).
Quoted 8 lines
Quoted 5 lines
Oops, sorry, right.
The preemptible kernel can reschedule, on average, sooner than the scheduling-point kernel, which has to wait for a scheduling point to roll around.
mmhhh. At which cost? And then anyway if I have a spinlock, I still have to wait for a scheduling point to roll around.
Did you read the thread? Think about the relative amount of time spent in spinlocks vs the amount of time spent in the regular kernel.
--
Daniel
Preemtive kernel (Was: Re: [2.4.17/18pre] VM and swap - it's really unusable)
In reply to Luigi Genoni(the subject has been wrong for some time now...)
Quoted 10 lines · Daniel Phillips
Quoted 9 lines · Luigi Genoni
Quoted 7 lines · Daniel Phillips
Quoted 4 lines · Andrea Arcangeli
but I just wanted to make clear that the
idea that is floating around that preemptive kernel is all goodness is very far from reality, you get very low mean latency but at a price.A price lots of people are willing to pay
Quoted 9 lines
Quoted 1 line
Probably sometimes they are not making a good business.
Perhaps. But they are happy customers and their music sounds better.
Note: the dominating cost of -preempt is not Robert's patch, but the fact that you need to have
CONFIG_SMPenabled, even for uniprocessor, turning all those stub macros into real spinlocks. For a dual processor you have to have this anyway and it just isn't an issue.
Well you don't - the first versions used the SMP spinlocks macros but replaced them with own code. (basically an INC on entry and a DEC and test when leaving)
Think about what happens on a UP
There are two cases
- the processor is in the critical section, it can not be preempted = no other process can take the CPU away from it.
- the processor is not in a critical section, no process can be executing inside it = can never be busy.
=> no real spinlocks needed on a UP
/RogerL
Signature · 3 lines
Roger Larsson Skellefteå Sweden
Re: Preemtive kernel (Was: Re: [2.4.17/18pre] VM and swap - it's really unusable)
In reply to Luigi GenoniQuoted 26 lines · Roger Larsson
(the subject has been wrong for some time now...)
Quoted 10 lines · Daniel Phillips
Quoted 9 lines · Luigi Genoni
Quoted 7 lines · Daniel Phillips
Quoted 4 lines · Andrea Arcangeli
but I just wanted to make clear that the
idea that is floating around that preemptive kernel is all goodness is very far from reality, you get very low mean latency but at a price.A price lots of people are willing to pay
Quoted 8 lines
Quoted 1 line
Probably sometimes they are not making a good business.
Perhaps. But they are happy customers and their music sounds better.
Note: the dominating cost of -preempt is not Robert's patch, but the fact that you need to have
CONFIG_SMPenabled, even for uniprocessor, turning all those stub macros into real spinlocks. For a dual processor you have to have this anyway and it just isn't an issue.Well you don't - the first versions used the SMP spinlocks macros but replaced them with own code. (basically an INC on entry and a DEC and test when leaving)
Quoted 7 lines
Think about what happens on a UP
There are two cases
- the processor is in the critical section, it can not be preempted = no other process can take the CPU away from it.
- the processor is not in a critical section, no process can be executing inside it = can never be busy.
=> no real spinlocks needed on a UP
Right, thanks, it was immediately obvious when you pointed out that the macros are just used to find the bounds of the critical regions. So the cost of -preempt is somewhat less than I had imagined.
--
Daniel
Andrew Morton wrote:
[...]
Quoted 5 lines
I haven't seen any figures for embedded XP, but it is said that if you bend over backwards you can get 10 milliseconds out of NT4, and 4-5 out of the fabled BeOS. This is one area where we can fairly easily be very much the best. It's low-hanging fruit.
Quoted 8 lines
Internal preemptability is, in my opinion, the best way to deliver this.
I accept your point about it making debugging harder - I would suggest that the preempt code be altered so that it can be disabled at runtime, rather than via a rebuild. I suspect this can be done at zero cost by setting init_task's preempt count to 1000000 via a kernel boot option. And at almost-zero cost via a sysctl.
And with some bad luck, the bug goes away when you do this. The bug of the missing lock...
Helge Hafting
Quoted 7 lines · Andrew Morton
Quoted 3 lines · Daniel Phillips
The preemptible kernel can reschedule, on average, sooner than the scheduling-point kernel, which has to wait for a scheduling point to roll around.
Yes. It can also fix problematic areas which my testing didn't cover.
I bet, with a minor hack, it can help you *find* those problem areas too. You compile the two patches together and automatically log any event along with the execution address, where your explicit schedule points failed to reschedule in time. Sort of like a profile but suited exactly to your problem.
This just detects the problem areas in normal kernel execution, not spinlocks, but that is probably where most of the maintainance will be anyway.
By the way, did you check for latency in directory operations?
Quoted 21 lines
Incidentally, there's the SMP problem. Suppose we have the code:
lock_kernel(); for (lots) { do(something sucky); if (current->need_resched) schedule(); } unlock_kernel();This works fine on UP, but not on SMP. The scenario:
- CPU A runs this loop.
- CPU B is spinning on the lock.
- Interrupt occurs, kernel elects to run RT task on CPU B. CPU A doesn't have
need_reschedset, and just keeps on going. CPU B is stuck spinning on the lock.
Quoted 7 lines
This is only an issue for the low-latency patch - all the other approaches still have sufficiently bad worse-case that this scenario isn't worth worrying about.
I toyed with creating
spin_lock_while_polling_resched(), but ended up changing the scheduler to setneed_reschedagainst _all_ CPUs if an RT task is being woken (yes, yuk).
Heh, subtle. Thanks for pointing that out and making my head hurt.
--
Daniel
Quoted 7 lines · Daniel Phillips
Quoted 5 lines · Andrew Morton
Quoted 3 lines · Daniel Phillips
The preemptible kernel can reschedule, on average, sooner than the scheduling-point kernel, which has to wait for a scheduling point to roll around.
Quoted 8 lines
Quoted 2 lines
Yes. It can also fix problematic areas which my testing didn't cover.
I bet, with a minor hack, it can help you *find* those problem areas too. You compile the two patches together and automatically log any event along with the execution address, where your explicit schedule points failed to reschedule in time. Sort of like a profile but suited exactly to your problem.
Well, one of the instrumentation patches which I use detects a scheduling overrun at interrupt time and emits an all-CPU backtrace. You just feed the trace into ksymoops or gdb then go stare at the offending code.
That's the easy part - the hard part is getting sufficient coverage. There are surprising places. close_files(), exit_notify(), ...
Quoted 4 lines
This just detects the problem areas in normal kernel execution, not spinlocks, but that is probably where most of the maintainance will be anyway.
By the way, did you check for latency in directory operations?
Yes. They can be very bad for really large directories. Scheduling on the found-in-cache case in bread() kills that one easily for most local filesystems. There may still be a problem in ext2.
-
Quoted 6 lines · Andrew Morton
Quoted 1 line · Daniel Phillips
By the way, did you check for latency in directory operations?
Yes. They can be very bad for really large directories. Scheduling on the found-in-cache case in
bread()kills that one easily for most local filesystems. There may still be a problem in ext2.
A indexed directory won't have that problem - I'll get to finishing off the htree patch pretty soon[1]. In any event, the analogous technique will work:
a schedule point in ext2_bread.
[1] Wli's hash work is happening at a convenient time.
--
Daniel
Oliver Xymoron wrote:
[...]
Quoted 4 lines
Have we ever considered making rescheduling work like
get_user? That is, makecurrent->need_reschedbe a pointer, and if we need to reschedule, make it an INVALID pointer that causes us to fault and call schedule in its fault path?
Elegant perhaps, but now you take the time to do a completely unnecessary
page fault when rescheduling. This has a cost which is high on some architectures. But the point of rescheduling was to improve interactive performance and io latency.
Every page fault may have to check for this case.
Helge Hafting
Quoted 7 lines · Robert Love
Quoted 3 lines · Andrea Arcangeli
"extra schedule points all over the place", that's the -preempt kernel not the lowlatency kernel! (on yeah, you don't see them in the source but ask your CPU if it sees them)
How so? The branch on drop of the last lock? It's not a factor in
exactly, this is the reschedule point I meant. Oh note that it's unlikely also in the lowlatecy patch. Please count the number of time you add this branch in the -preempt, and how many times we add this branch in the lowlat and then tell me who is adding rescheduling points in the kernel all over the place.
Quoted 3 lines
This makes me think the end conclusion would be that preemptive multitasking in general is bad. Why don't we increase the timeslice and and tick period, in that case?
that would increase performance, but we'd lost interactivity.
Quoted 2 lines
One can argue the complexity degrades performance, but tests show otherwise. In throughput and latency. Besides, like I always say, its
which benchmarks? you should make sure the CPU spend all its cycles in the kernel to benchmark the perfrormance degradation (this is the normal case of webserving with a few gigabit ethernet cards using sendfile).
Quoted 1 line
ride. On the other hand, the patch has a _huge_ userbase and you can't
I question this because it is too risky to apply. There is no way any distribution or production system could ever consider applying the preempt kernel and ship it in its next kernel update 2.4. You never know if a driver will deadlock because it is doing a test and set bit busy loop by hand instead of using spin_lock and you cannot audit all the device drivers out there. It is not like the VM that is self contained and that can be replaced without any caller noticing, this instead impacts every single driver out there and you'd need to audit all of them, which is not feasible I think and that should be done by giving everybody the time to test. This is also what makes preempt config option risky, if we go preempt we should force everybody to use it, at least during 2.5, so we get the useful feedback from testers of all the hardware, or nobody could trust -preempt.
NOTE: I trust your work with spinlocks, locks around per-cpu data structures etc.. is perfect, I trust that part, as said it's the driver doing test and set bit that you cannot audit that is the problem here and that makes it potentially unstable, not your changes. And also the per-cpu data structures sounds a little risky (but for example for UP that's not an issue).
Quoted 2 lines
question that. You also can't question the benchmarks that show improvements in average _and_ worst case latency _and_ throughput.
I don't question some benchmark is faster with -preempt, the interesting thing is to find why because it shouldn't be the case, Andrew for example mentioned software raid, there are good reasons for which -preempt could be faster there, so we added a single sechdule point and we just have that case covered in 18pre2aa1, we don't need reschedule points all over the place like in -preempt to cover things like that. It is good to find them out so we can fix those bugs, I consider them bugs :).
Again: I'm not completly against preempt, it can reach an mean latency much lower than mainline (it can reschedule immediatly in the middle of long copy-users for example), so it definitely has a value, it's just that I'm not sure if it worth it.
Andrea
Quoted 9 lines · Andrea Arcangeli
Quoted 5 lines · Daniel Phillips
BTW, I find your main argument confusing. First you don't want -preempt with
CONFIG_EXERIMENTALbecause it might not get wide enough testing, so you want to enable it by default in the mainline kernel, then you argue it's too risky because everybody will use it and it might break some obscure driver. Sorry, you lost me back there.the point I am making is very simple: _if_ we include it, it should _not_ be a config option.
That doesn't make any sense to me. Why should _SMP be a config option and not _PREEMPT?
--
Daniel
----- Original Message -----
From: "Andrea Arcangeli" <[email protected]>
To: "Robert Love" <[email protected]>
Cc: "Daniel Phillips" <[email protected]>; "Anton Blanchard" <[email protected]>; "Luigi Genoni" <[email protected]>; "Dieter N?tzel" <[email protected]>; "Marcelo Tosatti" <[email protected]>; "Rik van Riel" <[email protected]>; "Linux Kernel List" <[email protected]>; "Andrew Morton" <[email protected]>
Sent: Wednesday, January 09, 2002 6:24 AM
Subject: Re: [2.4.17/18pre] VM and swap - it's really unusable
Quoted 19 lines · Robert Love
Quoted 7 lines · Andrea Arcangeli
Quoted 4 lines
"extra schedule points all over the place", that's the -preempt kernel not the lowlatency kernel! (on yeah, you don't see them in the source but ask your CPU if it sees them)
How so? The branch on drop of the last lock? It's not a factor in
exactly, this is the reschedule point I meant. Oh note that it's unlikely also in the lowlatecy patch. Please count the number of time you add this branch in the -preempt, and how many times we add this branch in the lowlat and then tell me who is adding rescheduling points in the kernel all over the place.
Quoted 3 lines
This makes me think the end conclusion would be that preemptive multitasking in general is bad. Why don't we increase the timeslice and and tick period, in that case?
Quoted 8 lines
that would increase performance, but we'd lost interactivity.
Quoted 2 lines
One can argue the complexity degrades performance, but tests show otherwise. In throughput and latency. Besides, like I always say, its
which benchmarks? you should make sure the CPU spend all its cycles in the kernel to benchmark the perfrormance degradation (this is the normal case of webserving with a few gigabit ethernet cards using sendfile).
I haven't seen any interactive tests that showed worse results than the
vanilla kernel with the preempt patch. The only cases where it gives a worse performance is in a single tasking environment such as running bonnie or dbench and apps like that that require to throttle the system. This is obviously expected behavior though. Performance degradation might be seen on a per app basis, but when looking at the system as a whole, performance has never degraded with the patch as far as i've seen. Better overall performance is what has lead to better "benchmark" performance on the tests being run by people.
Quoted 15 lines
Quoted 1 line
ride. On the other hand, the patch has a _huge_ userbase and you can't
I question this because it is too risky to apply. There is no way any distribution or production system could ever consider applying the preempt kernel and ship it in its next kernel update 2.4. You never know if a driver will deadlock because it is doing a test and set bit busy loop by hand instead of using
spin_lockand you cannot audit all the device drivers out there. It is not like the VM that is self contained and that can be replaced without any caller noticing, this instead impacts every single driver out there and you'd need to audit all of them, which is not feasible I think and that should be done by giving everybody the time to test. This is also what makes preempt config option risky, if we go preempt we should force everybody to use it, at least during 2.5, so we get the useful feedback from testers of all the hardware, or nobody could trust -preempt.
I disagree. Redhat shipped gcc 2.96 when it was producing incompatible
binaries and was buggy as all hell, why not ship a kernel that is "unstable" and "risky" if it promises better performance.
If scheduling points are ugly in 2.4, then they'd be ugly in 2.5. The only solution to the problem you see with it is making 2.5 fully preemptible from the ground up instead of having to add fixes. If nobody wants to do things the hard way (assuming there is a better way), is it better to leave it unfixed rather than fix it? Of course i'm assuming that the idea of a fully preemptible kernel is better than the current version we have now.
Quoted 10 lines
NOTE: I trust your work with spinlocks, locks around per-cpu data structures etc.. is perfect, I trust that part, as said it's the driver doing test and set bit that you cannot audit that is the problem here and that makes it potentially unstable, not your changes. And also the per-cpu data structures sounds a little risky (but for example for UP that's not an issue).
Quoted 2 lines
question that. You also can't question the benchmarks that show improvements in average _and_ worst case latency _and_ throughput.
Quoted 8 lines
I don't question some benchmark is faster with -preempt, the interesting thing is to find why because it shouldn't be the case, Andrew for example mentioned software raid, there are good reasons for which -preempt could be faster there, so we added a single sechdule point and we just have that case covered in 18pre2aa1, we don't need reschedule points all over the place like in -preempt to cover things like that. It is good to find them out so we can fix those bugs, I consider them bugs :).
I think robert love is trying to give the kernel the highest flexibility.
Making it flexible in key areas will improve your worst cases but a lot of the time during normal use it's the multitude of smaller cases that is noticeable.
Quoted 6 lines
Again: I'm not completly against preempt, it can reach an mean latency much lower than mainline (it can reschedule immediatly in the middle of long copy-users for example), so it definitely has a value, it's just that I'm not sure if it worth it.
Andrea
Ok so the medicine is worse than the disease. I take it that you only want
some key points made for rescheduling instead of the full preempt patch by
Robert. That seems logical enough. The only issue i see is that for the
most part people dont like the idea of needing to add scheduling points. So how would the kernel need to be fixed in order to not need them and still be fully preemptible like it's getting in Robert's patch. If it just cant then is it really best to hang out somewhere on the edge of preemptible multitasking because some people are in denial that the kernel needs to be patched so much to work correctly and for the sake of single tasking performance?
Now in just my own opinion i think of linux as a multitasking kernel and as thus it should perform that function as best as possible. If you want to run a single program as fast as possible then absolutely dont run anything
else and nothing can preempt it to degrade it's performance. The fact that
you can run multiple apps and run a single program as fast as possible without degrading it's performance is a bug if those other apps (at the same priority) have to wait longer than they should if we want linux to be a multitasking kernel. Just to sum things up, if there is a way to be fully preemptible without scheduling points linux, then perhaps that should be a major focus for 2.5 instead of picking and choosing (ugly)scheduling points, but if not then the argument about them not being elegant is mute because then the kernel, itself, is far from elegant already, so what exactly are you saving?
- Formerly safemode
Quoted 8 lines · Daniel Phillips
Quoted 7 lines · Andrea Arcangeli
Quoted 5 lines · Daniel Phillips
BTW, I find your main argument confusing. First you don't want -preempt with
CONFIG_EXERIMENTALbecause it might not get wide enough testing, so you want to enable it by default in the mainline kernel, then you argue it's too risky because everybody will use it and it might break some obscure driver. Sorry, you lost me back there.
Quoted 4 lines
Quoted 2 lines
the point I am making is very simple: _if_ we include it, it should _not_ be a config option.
That doesn't make any sense to me. Why should
_SMPbe a config option and not
getting the drivers tested with preempt enable makes lots of sense to me.
Quoted 1 line
_PREEMPT?
SMP in 2.1 wasn't a config option.
Andrea
Quoted 3 lines · Ed Sweetman
Ok so the medicine is worse than the disease. I take it that you only want
some key points made for rescheduling instead of the full preempt patch by
Robert. That seems logical enough. The only issue i see is that for the
My ideal is to have the kernel to be as low worst latency as -preempt, but without being preemptive. that's possible to achieve, I don't think we're that far.
mean latency is another matter, but I personally don't mind about mean latency and I much prefer to save cpu cycles instead.
Andrea
Quoted 6 lines · Andrea Arcangeli
Quoted 3 lines · Ed Sweetman
Ok so the medicine is worse than the disease. I take it that you only want
some key points made for rescheduling instead of the full preempt patch by
Robert. That seems logical enough. The only issue i see is that for the
Quoted 6 lines
My ideal is to have the kernel to be as low worst latency as -preempt, but without being preemptive. that's possible to achieve, I don't think we're that far.
mean latency is another matter, but I personally don't mind about mean latency and I much prefer to save cpu cycles instead.
hear hear!
The akpm patch is achieving a MUCH better latency than pure -preempt, and only has 40
or so coded preemption points instead of a few hundred (eg every spin_unlock)....
and if with 40 we can get <= 1ms then everybody will be happy; if you want, say, 50 usec
latency instead you need RTLinux anyway. With 1ms _worst case_ latency the "mean" latency
is obviously also very good.......
Quoted 3 lines
The high-end audio synth guys claim that two milliseconds is getting to be too much. They are generating real-time audio and they do have more than one round-trip through the software. It adds up.
Most of the stuff I've seen from high end audio people consists of overthreaded, chains of code written without any consideration for the actual cost of execution. There are exceptions - including people dynamically compiling filters to get ideal cache and latency behaviour, but not enough.
Alan
Quoted 4 lines · John Alvord
Incidently human visual perception runs around 200 milliseconds minimum and hearing/touch perception around 100 milliseconds if the signal has to go through the brain. Of course we extend our perceptions with
tools/programsetc.
Cool! That means movies don't need to run faster than 5 frames/second. Maybe 10 frames/second for plenty of overkill. No need to look at keyboard and mice any more frequently either, what a relief. (Any why do silly gamers want to go so much higher?)
Sarcasm mode "off" now...just because some experiments show it takes humans a long time to push the correct button when you show them a picture of a banana doesn't mean there is no reason to have a user interface do anything any faster. (I can come up with plenty of examples if you would like.)
OK, now that I have pissed off a big hunk of the folks on the list, let me bring up a different question:
How does all this fit into doing a tick-less kernel?
There is something appealing about doing stuff only when there is stuff to do, like: respond to input, handle some device that becomes ready, or let another process run for a while. Didn't IBM do some nice work on this for Linux? (*Was* it nice work?) I was under the impression that the current kernel isn't that far from being tickless.
A tickless kernel would be wonderful for battery powered devices that could literally shut off when there be nothing to do, and it seems it would (trivially?) help performance on high end power hogs too.
Why do we have regular HZ ticks? (Other than I think I remember Linus saying that he likes them.)
Thanks,
-kb, the Kent who knows more about user interfaces than he does preemption.
Quoted 14 lines · Arjan van de Ven
Quoted 6 lines · Andrea Arcangeli
Quoted 4 lines · Ed Sweetman
Ok so the medicine is worse than the disease. I take it that you only
want some key points made for rescheduling instead of the full preempt
patch by Robert. That seems logical enough. The only issue i see is
that for theQuoted 6 lines
My ideal is to have the kernel to be as low worst latency as -preempt, but without being preemptive. that's possible to achieve, I don't think we're that far.
mean latency is another matter, but I personally don't mind about mean latency and I much prefer to save cpu cycles instead.
Quoted 6 lines
hear hear!
The akpm patch is achieving a MUCH better latency than pure -preempt, and only has 40
or so coded preemption points instead of a few hundred (eg everyspin_unlock)....
The difference is that the preemptive kernel mostly uses existing infrastructure. When SMP scalability gets better due to holding locks for a shorter time then the preemptive kernel will improve as well!
AND it can be used on a UP computer to "simulate" SMP and that should help the quality of the total code base...
This is my idea:
* Add the preemptive kernel
* "Remove" reschedule points from main kernel.
note: that reschedule points that does nothing more than test and schedule can be NOOPed since they will never trigger in a preemptive kernel...
Quoted 6 lines
and if with 40 we can get <= 1ms then everybody will be happy; if you want, say, 50 usec
latency instead you need RTLinux anyway. With 1ms_worstcase_latency the "mean" latency
is obviously also very good.......
Worst case latency... is VERY hard to prove if you rely on schedule points. Since they are typically added after the fact...
If the code suddenly end up on a road less travelled...
With preemptive kernel your worst latency is the longest held spinlock. PERIOD.
(you can of cause be delayed by an even higher priority process)
* Make sure that there are no "infinite" loops inside any spinlock.
"infinite" == over ALL or ALL/x of something since someone, somewere
will have ALL close to infinite... (infinity/x is still infinity... :-)
example code is looping through LRU list to find a victim page... once it was not infinite due to the small number of pages...
Note: that akpm patches usually hava a - "do not do this list" with known problem spots (ok, usually in a hard to break spinlocks).
/RogerL
Signature · 3 lines
Roger Larsson Skellefteå Sweden
Quoted 11 lines · Arjan van de Ven
Quoted 10 lines · Andrea Arcangeli
Quoted 3 lines · Ed Sweetman
Ok so the medicine is worse than the disease. I take it that you only want
some key points made for rescheduling instead of the full preempt patch by
Robert. That seems logical enough. The only issue i see is that for theMy ideal is to have the kernel to be as low worst latency as -preempt, but without being preemptive. that's possible to achieve, I don't think we're that far.
Quoted 6 lines
Quoted 2 lines
mean latency is another matter, but I personally don't mind about mean latency and I much prefer to save cpu cycles instead.
hear hear!
The akpm patch is achieving a MUCH better latency than pure -preempt,
Can you please point us at the benchmark results that support your claim?
Quoted 3 lines
and only has 40
or so coded preemption points instead of a few hundred (eg everyspin_unlock)....
So? The cost of this is, in theory, a dec and a branch normally not taken. Robert hasn't coded it that way in the current incarnation, and personally, I'd rather see the correctness proven before the microoptimizations are done, but that's where it's going in theory. Big deal.
On the other hand, I just did a test for myself that pretty well makes up my mind about this patch. I'm typing this right now on a 64 Meg laptop with a slow disk, dma turned off. On this machine, debian apt-get dist-upgrade is essentially a DoS - once it gets to unpacking packages and configuring, for whatever reason, the machine becomes almost ununsable. Changing windows for example, can take 10-15 seconds. Updatedb, while not quite as bad, is definitely an irritant as far as interactive use goes.
With Robert's patch, the machine is a little sluggish during apt-get, but quite usable. This is a *huge* difference. And during updatedb, well, I hardly notice it's happening, except for the disk light.
So I like this patch. What was your complaint again? If you've got hard numbers and repeatable benchmarks, please trot them out.
--
Daniel
Quoted 3 lines · Roger Larsson
The difference is that the preemptive kernel mostly uses existing infrastructure. When SMP scalability gets better due to holding locks for a shorter time then the preemptive kernel will improve as well!
Ehm. Holding locks for a shorter time is not guaranteed to improve smp scalability. In fact it can completely kill it due to cacheline pingpong effects.
Quoted 7 lines
Quoted 5 lines
and if with 40 we can get <= 1ms then everybody will be happy; if you want, say, 50 usec
latency instead you need RTLinux anyway. With 1ms_worstcase_latency the "mean" latency
is obviously also very good.......Worst case latency... is VERY hard to prove if you rely on schedule points.
Agreed. It's "worst case" in the soft real time sence. But we've beaten the kernel quite hard during such tests....
Quoted 2 lines
With preemptive kernel your worst latency is the longest held spinlock. PERIOD.
Yes and without the same stuff akpm does that's about 80 to 90 ms right now.
Quoted 2 lines
Note: that akpm patches usually hava a - "do not do this list" with known problem spots (ok, usually in a hard to break spinlocks).
Usually in hardware related parts. Even with -preempt you'll get this. Hopefully only during hardware initialisation, but there are just cases where you need to go WAAAY too far if you want to go below, say, 5ms during device init.
Quoted 11 lines · Alan Cox
Quoted 3 lines
The high-end audio synth guys claim that two milliseconds is getting to be too much. They are generating real-time audio and they do have more than one round-trip through the software. It adds up.
Most of the stuff I've seen from high end audio people consists of overthreaded, chains of code written without any consideration for the actual cost of execution. There are exceptions - including people dynamically compiling filters to get ideal cache and latency behaviour, but not enough.
Alan
News flash: people are writing sub-optimal apps in user space.
Do you want an operating system capable of running real-world code written by people who know more about their specific problem domain (audio) than about optimal coding in general, or do you want an operating system intended to only run well-behaved applications designed and implemented by experts?
Rob
Quoted 12 lines · Rob Landley
Quoted 10 lines · Alan Cox
Quoted 3 lines
The high-end audio synth guys claim that two milliseconds is getting to be too much. They are generating real-time audio and they do have more than one round-trip through the software. It adds up.
Most of the stuff I've seen from high end audio people consists of overthreaded, chains of code written without any consideration for the actual cost of execution. There are exceptions - including people dynamically compiling filters to get ideal cache and latency behaviour, but not enough.
Quoted 3 lines
Quoted 1 line
Alan
News flash: people are writing sub-optimal apps in user space.
Not only in user=space :)
Quoted 4 lines
Do you want an operating system capable of running real-world code written by people who know more about their specific problem domain (audio) than about optimal coding in general, or do you want an operating system intended to only run well-behaved applications designed and implemented by experts?
The people with whom I dealt (Benno Senoner, Dave Philips, Paul Barton-Davis) with are deeply clueful about this stuff.
I'll quote from an email Paul set me a year ago. I don't think he'll mind. This is, of course, a quite specialised application area:
....
There are two kinds of situations where its needed:
1) real-time effects ("FX") processing
2) real-time synthesis influenced by external controllers
In (1), we have an incoming audio signal that is to be processed in some way (echo/flange/equalization/etc. etc.) and then delivered back to the output audio stream. If the delay between the input and output is more than a few msecs, there are several possible consequences:
* if the original source was acoustic (non-electronic), and the processed material is played back over monitors close to the acoustic source, you will get interesting filtering effects as the two signals interfere with each other.
* the musician will get confused by material in the processed stream arriving "late"
* the result may be useless.
In (2), a musician is using, for example, a keyboard that sends MIDI "note on/note off" messages to the computer which are intended to cause the synthesis engine to start/stop generating certain sounds. If the delay between the musician pressing the key and hearing the sound exceeds about 5msec, the system will feel difficult to play; worse, if there is actual jitter in the +/- 5msec range, it will feel impossible to play.
....
Without LL, Linux cannot reasonably be used for professional audio work that involves real time FX or real time synthesis. The default kernel has worst-case latencies noticeably worse than Windows, and most people are reluctant to use that system already, not just because of instability but latencies also. Its not a matter of it being "a bit of a problem" - the 100msec worst case latencies visible in the standard kernel make it totally implausible that you would ever deploy Linux in a situation where RT FX/synthesis were going to happen.
By contrast, if we get LL in place, then we can potentially use Linux in "black box"/"embedded" systems designed specifically for audio users; all the flexibility of Linux, but if they choose to ignore most of that, they'll still have a black rack-mounted box capable of doing everything (more mostly everything) currently done by dedicated hardware. As general purpose CPU performance continues to increase, this becomes more and more overwhelmingly obvious as the way forward for audio processing.
....
Quoted 4 lines
Do you want an operating system capable of running real-world code written by people who know more about their specific problem domain (audio) than about optimal coding in general, or do you want an operating system intended to only run well-behaved applications designed and implemented by experts?
I want an OS were a reasonably cluefully written audio program works. That to me means aiming at the 1mS latency mark. Which doesn't seem to be needing pre-empt. Beyond a typical 1mS latency you have hardware fun to worry about, and the BIOS SMM code eating you.
On Wed, Jan 09, 2002 at 12:10:38AM +0000, Alan Cox wrote:
| That is generally not true. Pe-emption is used in user space to prevent | applications doing very stupid things. Pre-emption in a trusted environment | can often be most efficient if done by the programs themselves. | Userspace is not a trusted environment
That's true, but at some point in the future I think the work involved in making sure all new additional kernel code and all new intra-kernel interactions are "tuned" becomes larger than going preemptive all the way down.
Apple had its arguments for cooperative, along the same lines as what you've mentioned I believe. And while I agree that the kernel is a much _more_ trusted environment, I think the possibilities easily remain for abuse given that there are A) more and more people contributing kernel code every day, and B) countless unspeakably evil modules out there.
And the preempt tunability that has been mentioned sounds like it would go a long way.
| Andrew's patches give you 1mS worst case latency for normal situations, that | is below human perception, and below scheduling granularity. In other words | without the efficiency loss and the debugging problems you can place the | far enough latency below other effects that it isnt worth attacking any more.
It sounds like the LL patches are easier and less prone to locking issues with a lot of the benefit. But I can't help but feel that it's not using the right tool for the job. I think the end result of stabilizing a preemptive kernel (in 2.5?) is worth the price, IMHO.
Signature · 2 lines
Ken. [email protected]
Quoted 4 lines
That's true, but at some point in the future I think the work involved in making sure all new additional kernel code and all new intra-kernel interactions are "tuned" becomes larger than going preemptive all the way down.
It makes no difference to the kernel the work is the same in all cases because you cannot pre-empt while holding a lock. Therefore you have to do all the lock analysis anyway
On Wednesday 09 January 2002 13:57, Andrew Morton wrote:
[snip]
Quoted 10 lines
Without LL, Linux cannot reasonably be used for professional audio work that involves real time FX or real time synthesis. The default kernel has worst-case latencies noticeably worse than Windows, and most people are reluctant to use that system already, not just because of instability but latencies also. Its not a matter of it being "a bit of a problem" - the 100msec worst case latencies visible in the standard kernel make it totally implausible that you would ever deploy Linux in a situation where RT FX/synthesis were going to happen.
Quoted 9 lines
By contrast, if we get LL in place, then we can potentially use Linux in "black box"/"embedded" systems designed specifically for audio users; all the flexibility of Linux, but if they choose to ignore most of that, they'll still have a black rack-mounted box capable of doing everything (more mostly everything) currently done by dedicated hardware. As general purpose CPU performance continues to increase, this becomes more and more overwhelmingly obvious as the way forward for audio processing.
I keep on seeing these "Blackbox" apps like Tivo using Linux but the fact remains the average folks cannot get any reasonable kind of A/V
performance and support under Linux. That's what we need.
Needing to save money and get some fast cash (I'm unemployed), yesterday, I swapped out my dual P-III motherboard in my BeOS box
for a Via C-III (700MHz) based system. And I got my first real hiccups
while using the OS when I was playing MP3s and _launching_ the TV program _full screen_(640x480 on 640x480 virtual desktop window).
Obviously, when this stuff is done right, more CPU power can only help, but it still has to be done right. As I am sure that you know, BeOS claims average latency of 250 microseconds.
Signature · 1 line
[email protected].
Quoted 10 lines · Alan Cox
Quoted 5 lines
Do you want an operating system capable of running real-world code written by people who know more about their specific problem domain (audio) than about optimal coding in general, or do you want an operating system intended to only run well-behaved applications designed and implemented by experts?
I want an OS were a reasonably cluefully written audio program works. That to me means aiming at the 1mS latency mark. Which doesn't seem to be needing pre-empt. Beyond a typical 1mS latency you have hardware fun to worry about, and the BIOS SMM code eating you.
I don't know what BIOS SMM code is, or what you mean by "hardware fun". But the worst audio dropouts I have are "cp file.wav /dev/audio" when I forgot to kill cron and updatedb started up. (This is considerably WORSE than mp3 playing.) I take it "cp" is badly written? :)
And a sound card with only 1mS of buffer in it is definitely not useable on windoze, the minimum buffer in the cheapest $12 PCI sound card I've seen is about 1/4 second (250ms). (Is this what you mean by "hardware fun"?) Even if the app was taking half that, it's still a > 100ms big gap where the OS leaves it hanging before you get a dropout. (Okay, some of that's watermark policy, not sending more data to the card until half the buffer is exhausted...) What sound output device DOESN'T have this much cache? (You mentioned USB speakers in your diary at one point, which seemed to be like those old "paralell port cable plus a few resistors equals sound output" hacks...)
Now VIDEO is a slightly more interesting problem. (Or synchronizing audio and video by sending really tiny chunks of audio.) There's no hardware buffer there to cover our latency sins. Then again, dropping frames is considered normal in the video world, isn't it? :)
Rob
Quoted 4 lines
I don't know what BIOS SMM code is, or what you mean by "hardware fun". But the worst audio dropouts I have are "cp file.wav
/dev/audio" when I forgot to kill cron and updatedb started up. (This is considerably WORSE than mp3 playing.) I take it "cp" is badly written? :)
Those are ones that Andrew's patch should fix nicely. You might need a decent VM as well though.
The fun below 1mS comes from
1. APM bios calls where the bios decides to take >1mS to have
a chat with your batteries
2. Video cards pulling borderline legal PCI tricks to get
better benchmarketing by stalling the entire bus
Quoted 3 lines
And a sound card with only 1mS of buffer in it is definitely not useable on windoze, the minimum buffer in the cheapest $12 PCI sound card I've seen is about 1/4 second (250ms). (Is this what you mean by "hardware fun"?) Even
For video conferencing and for real world audio mixing you can't use that 250ms. Not even for games. If your audio is 150mS late in quake you will notice it, really notice it. And the buffers on the audio card are btw generally in RAM not the fifo on the chip, so they dont help when the PCI bus loads up
Quoted 4 lines
exhausted...) What sound output device DOESN'T have this much cache? (You mentioned USB speakers in your diary at one point, which seemed to be like those old "paralell port cable plus a few resistors equals sound output" hacks...)
Umm no USB audio is rather good. USB sends isosynchronous, time guaranteed sample streams down the USB bus, to the speakers where the A to D is clear of the machine proper.
Quoted 4 lines
Now VIDEO is a slightly more interesting problem. (Or synchronizing audio and video by sending really tiny chunks of audio.) There's no hardware buffer there to cover our latency sins. Then again, dropping frames is considered normal in the video world, isn't it? :)
You'll see those too. Pure playback is ok because you have to buffer equally rather than reliably hit deadlines
Quoted 5 lines · John Alvord
Incidently human visual perception runs around 200 milliseconds minimum and hearing/touch perception around 100 milliseconds if the signal has to go through the brain. Of course we extend our perceptions with
tools/programsetc.
Have you ever tried to play piano with 100 ms latency from pressing the key to sound? I can tell you that it's pretty difficult...
- Jussi Laako
Signature · 2 lines
PGP key fingerprint: 161D 6FED 6A92 39E2 EB5B 39DD A4DE 63EB C216 1E4B Available at PGP keyservers
Quoted 7 lines · Rob Landley
And a sound card with only 1mS of buffer in it is definitely not useable on windoze, the minimum buffer in the cheapest $12 PCI sound card I've seen is about 1/4 second (250ms). (Is this what you mean by "hardware fun"?) Even if the app was taking half that, it's still a > 100ms big gap where the OS leaves it hanging before you get a dropout. (Okay, some of that's watermark policy, not sending more data to the card until half the buffer is exhausted...) What sound output device DOESN'T have this much cache?
Imagine taking an input, doing dsp-type calculations on it, and sending it back as output. Now...imagine doing it in realtime with the output being fed back to a monitor speaker. Think about what would happen if the output of the monitor speaker is 1/4 second behind the input at the mike. Now do you see the problem? A few ms of delay might be okay. A few hundred ms definately is not.
Quoted 4 lines
Now VIDEO is a slightly more interesting problem. (Or synchronizing audio and video by sending really tiny chunks of audio.) There's no hardware buffer there to cover our latency sins. Then again, dropping frames is considered normal in the video world, isn't it? :)
If I'm trying to watch a DVD on my computer, and assuming my CPU is powerful enough to decode in realtime, then I want the DVD player to take priority--dropping frames just because I'm starting up netscape is not acceptable.
Chris
Signature · 4 lines
Chris Friesen | MailStop: 043/33/F10 Nortel Networks | work: (613) 765-0557 3500 Carling Avenue | fax: (613) 765-2986 Nepean, ON K2H 8E9 Canada | email: [email protected]
Quoted 21 lines · Chris Friesen
Quoted 7 lines · Rob Landley
And a sound card with only 1mS of buffer in it is definitely not useable on windoze, the minimum buffer in the cheapest $12 PCI sound card I've seen is about 1/4 second (250ms). (Is this what you mean by "hardware fun"?) Even if the app was taking half that, it's still a > 100ms big gap where the OS leaves it hanging before you get a dropout. (Okay, some of that's watermark policy, not sending more data to the card until half the buffer is exhausted...) What sound output device DOESN'T have this much cache?
Imagine taking an input, doing dsp-type calculations on it, and sending it back as output. Now...imagine doing it in realtime with the output being fed back to a monitor speaker. Think about what would happen if the output of the monitor speaker is 1/4 second behind the input at the mike. Now do you see the problem? A few ms of delay might be okay. A few hundred ms definately is not.
Quoted 4 lines
Now VIDEO is a slightly more interesting problem. (Or synchronizing audio and video by sending really tiny chunks of audio.) There's no hardware buffer there to cover our latency sins. Then again, dropping frames is considered normal in the video world, isn't it? :)
Quoted 4 lines
If I'm trying to watch a DVD on my computer, and assuming my CPU is powerful enough to decode in realtime, then I want the DVD player to take priority--dropping frames just because I'm starting up netscape is not acceptable.
Ummm, and you couldn't consider refraining from firing up Netscape while watching the DVD, could you?!
I get your point, but the example was poorly chosen, imho.
Regards: David Weinehall
_ _
// David Weinehall <[email protected]> /> Northern lights wander \\
// Maintainer of the v2.0 kernel // Dance across the winter sky // \> http://www.acc.umu.se/~tao/ </ Full colour fire </
Quoted 8 lines · David Weinehall
Quoted 4 lines · Chris Friesen
If I'm trying to watch a DVD on my computer, and assuming my CPU is powerful enough to decode in realtime, then I want the DVD player to take priority--dropping frames just because I'm starting up netscape is not acceptable.
Quoted 4 lines
Ummm, and you couldn't consider refraining from firing up Netscape while watching the DVD, could you?!
I get your point, but the example was poorly chosen, imho.
I chose netscape because it is probably the largest single app that I have on my machine. Other possibilities would be running a kernel compile, a recursive search for specific file content through the entire filesystem, or anything else that is likely to cause problems. It might even be someone else in the house logged into it and running stuff over the network.
Signature · 4 lines
Chris Friesen | MailStop: 043/33/F10 Nortel Networks | work: (613) 765-0557 3500 Carling Avenue | fax: (613) 765-2986 Nepean, ON K2H 8E9 Canada | email: [email protected]
Quoted 6 lines · Chris Friesen
machine. Other possibilities would be running a kernel compile, a recursive search for specific file content through the entire filesystem, or anything else that is likely to cause problems. It might even be someone else in the house logged into it and running stuff over the network.
It's not enjoyable late night DVD watching when updatedb fires up at middle of the movie. Nor when you are trying to record some audio to the disk. Vanilla kernel really chokes up on those situations. Lowlatency patches help a lot on this.
- Jussi Laako
Signature · 2 lines
PGP key fingerprint: 161D 6FED 6A92 39E2 EB5B 39DD A4DE 63EB C216 1E4B Available at PGP keyservers
Quoted 5 lines · In article <[email protected]> you wrote:
Imagine taking an input, doing dsp-type calculations on it, and sending it back as output. Now...imagine doing it in realtime with the output being fed back to a monitor speaker. Think about what would happen if the output of the monitor speaker is 1/4 second behind the input at the mike. Now do you see the problem? A few ms of delay might be okay.
What kind of signal run time do you normally have in digital sound processing equipment? AFAIK one can expect a feew frames with of delay (n x 13ms).
Just dont feed back the processed signal to the singers monitor box.
Quoted 4 lines
If I'm trying to watch a DVD on my computer, and assuming my CPU is powerful enough to decode in realtime, then I want the DVD player to take priority--dropping frames just because I'm starting up netscape is not acceptable.
You do not start up netscape while you do realtime av processing in professional environemnt.
Well, an easy fix is to have the LL patch and do not use swap. Then you only need reliable/predictable hardware (which is not so easy to get for PC).
Greetings
Bernd
Quoted 6 lines · Alan Cox
The fun below 1mS comes from
1. APM bios calls where the bios decides to take >1mS to have
a chat with your batteries
2. Video cards pulling borderline legal PCI tricks to get
better benchmarketing by stalling the entire bus
Don't forget the embedded space, where the hardware vendor can ensure that their hardware is well-behaved. Even on a PC, it is possible for someone who cares about realtime to spec a reasonable system.
On good hardware, we can easily do much better than 1ms latency with a preemptible kernel and a spinlock cleanup. I don't think the limitations of some PC hardware should limit our goals for Linux.
Nigel Gamble [email protected]
Mountain View, CA, USA. http://www.nrg.org/
Quoted 9 lines · Nigel Gamble
Quoted 6 lines · Alan Cox
The fun below 1mS comes from
1. APM bios calls where the bios decides to take >1mS to have
a chat with your batteries
2. Video cards pulling borderline legal PCI tricks to get
better benchmarketing by stalling the entire bus
Quoted 8 lines
Don't forget the embedded space, where the hardware vendor can ensure that their hardware is well-behaved. Even on a PC, it is possible for someone who cares about realtime to spec a reasonable system.
On good hardware, we can easily do much better than 1ms latency with a preemptible kernel and a spinlock cleanup. I don't think the limitations of some PC hardware should limit our goals for Linux.
On 700MHz x86 running Cerberus we can do 50 microseconds average and 1300 microseconds worst-case today.
Below 1000 uSec, the required changes get exponentially larger and more complex. I doubt that it's sane to try to go below a millisecond on a desktop-class machine with desktop-class workload, disk, memory and swap capacities.
On a more constrained system, which is what I expect you're referring to, 250 microseconds should be achievable. Whether or not that is achieved via preemptability is pretty irrelevant.
-
Quoted 3 lines
On good hardware, we can easily do much better than 1ms latency with a preemptible kernel and a spinlock cleanup. I don't think the limitations of some PC hardware should limit our goals for Linux.
Its more than a spinlock cleanup at that point. To do anything useful you have to tackle both priority inversion and some kind of at least semi-formal validation of the code itself. At the point it comes down to validating the code I'd much rather validate rtlinux than the entire kernel
Alan
Quoted 4 lines · Alan Cox
Its more than a spinlock cleanup at that point. To do anything useful you have to tackle both priority inversion and some kind of at least semi-formal validation of the code itself. At the point it comes down to validating the code I'd much rather validate rtlinux than the entire kernel
The preemptible kernel plus the spinlock cleanup could really take us far. Having locked at a lot of the long-held locks in the kernel, I am confident at least reasonable progress could be made.
Beyond that, yah, we need a better locking construct. Priority inversion could be solved with a priority-inheriting mutex, which we can tackle if and when we want to go that route. Not now.
I want to lay the groundwork for a better kernel. The preempt-kernel patch gives real-world improvements, it provides a smoother user desktop experience -- just look at the positive feedback. Most importantly, however, it provides a framework for superior response with our standard kernel in its standard programming model.
Robert Love
Quoted 8 lines · Robert Love
On Fri, 2002-01-11 at 07:37, Alan Cox wrote:
The preemptible kernel plus the spinlock cleanup could really take us far. Having locked at a lot of the long-held locks in the kernel, I am confident at least reasonable progress could be made.Beyond that, yah, we need a better locking construct. Priority inversion could be solved with a priority-inheriting mutex, which we can tackle if and when we want to go that route. Not now.
Backing the car up to the edge of the cliff really gives us good results. Beyond that, we could jump off the cliff if we want to go that route.
Preempt leads to inheritance and inheritance leads to disaster.
All the numbers I've seen show Morton's low latency just works better. Are there other numbers I should look at.
Quoted 6 lines · On Friday 11 January 2002 09:50 pm, [email protected] wrote:
Quoted 5 lines · Robert Love
On Fri, 2002-01-11 at 07:37, Alan Cox wrote:
The preemptible kernel plus the spinlock cleanup could really take us far. Having locked at a lot of the long-held locks in the kernel, I am confident at least reasonable progress could be made.
Quoted 8 lines
Quoted 3 lines
Beyond that, yah, we need a better locking construct. Priority inversion could be solved with a priority-inheriting mutex, which we can tackle if and when we want to go that route. Not now.
Backing the car up to the edge of the cliff really gives us good results. Beyond that, we could jump off the cliff if we want to go that route.
Preempt leads to inheritance and inheritance leads to disaster.
I preempt leads to disaster than Linux can't do SMP. Are you saying that's the case?
The preempt patch is really "SMP on UP". If pre-empt shows up a problem, then it's a problem SMP users will see too. If we can't take advantage of the existing SMP locking infrastructure to improve latency and interactive feel on UP machines, than SMP for linux DOES NOT WORK.
Quoted 2 lines
All the numbers I've seen show Morton's low latency just works better. Are there other numbers I should look at.
This approach is basically a collection of heuristics. The kernel has been profiled and everywhere a latency spike was found, a band-aid was put on it (an explicit scheduling point). This doesn't say there aren't other latency spikes, just that with the collection of hardware and software being benchmarked, the latency spikes that were found have each had a band-aid individually applied to them.
This isn't a BAD thing. If the benchmarks used to find latency spikes are at all like real-world use, then it helps real-world applications. But of COURSE the benchmarks are going to look good, since tuning the kernel to those benchmarks is the way the patch was developed!
The majority of the original low latency scheduling point work is handled automatically by the SMP on UP kernel. You don't NEED to insert scheduling points anywhere you aren't inside a spinlock. So the SMP on UP patch makes most of the explicit scheduling point patch go away, accomplishing the same thing in a less intrusive manner. (Yes, it makes all kernels act like SMP kernels for debugging purposes. But you can turn it off for debugging if you want to, that's just another toggle in the magic sysreq menu. And this isn't entirely a bad thing: applying the enormous UP userbase to the remaining SMP bugs is bound to squeeze out one or two more obscure ones, but those bugs DO exist already on SMP.)
However, what's left of the explicit scheduling work is still very useful. When you ARE inside a spinlock, you can't just schedule, you have to save state, drop the lock(s), schedule, re-acquire the locks, and reload your state in case somebody else diddled with the structures you were using. This is a lot harder than just scheduling, but breaking up long-held locks like this helps SMP scalability, AND helps latency in the SMP-on-UP case.
So the best approach is a combination of the two patches. SMP-on-UP for everything outside of spinlocks, and then manually yielding locks that cause problems. Both Robert Love and Andrew Morton have come out in favor of each other's patches on lkml just in the past few days. The patches work together quite well, and each wants to see the other's patch applied.
Rob
Quoted 4 lines · Rob Landley
I preempt leads to disaster than Linux can't do SMP. Are you saying that's the case?
The preempt patch is really "SMP on UP". If pre-empt shows up a problem,
People keep repeating this, it must feel reassuring.
/* in kernel mode: does it need a lock? */ m = next_free_page_from_per_cpu_cache();
To start, preemptive means that the optimizations for SMP that reduce locking by per cpu localization do not work.
So, as I understand it:
the preempt patch is really "crappy SMP on UP"
may be correct. But what you wrote is not.
Did I miss something? That's not a rhetorical question - I recall being wrong before so go ahead and explain what's wrong with my logic.
Quoted 8 lines
then it's a problem SMP users will see too. If we can't take advantage of the existing SMP locking infrastructure to improve latency and interactive feel on UP machines, than SMP for linux DOES NOT WORK.
Quoted 2 lines
All the numbers I've seen show Morton's low latency just works better. Are there other numbers I should look at.
This approach is basically a collection of heuristics. The kernel has been
One patch makes the numbers look good (sort of)
One patch does not but "improves feel" and breaks a exceptionally useful
rule: per cpu data in kernel that is not touched by interrupt code does not need to be locked.
The basic assumption of the preempt trick is that locking for SMP is based on the same principles as locking for preemption and that's completely false.
I believe that the preempt path leads inexorably to mutex-with-stupid-priority-trick and that would be very unfortunate indeed. It's unavoidable because sooner or later someone will find that preempt + SCHED_FIFO leads to
niced app 1 in K mode gets Sem A
SCHED_FIFO app prempts and blocks on Sem A whoops! app 2 in K more preempts niced app 1
Hey my DVD player has stalled, lets add sem_with_revolting_priority_trick! Why the hell is UP Windows XP3 blowing away my Linux box on DVD playing while Linux now runs with the grace and speed of IRIX?
And has anyone fixed all those mysterious hangs caused by the interesting interaction of hundreds of preempted semaphores?
Quoted 11 lines
profiled and everywhere a latency spike was found, a band-aid was put on it (an explicit scheduling point). This doesn't say there aren't other latency spikes, just that with the collection of hardware and software being benchmarked, the latency spikes that were found have each had a band-aid individually applied to them.
This isn't a BAD thing. If the benchmarks used to find latency spikes are at all like real-world use, then it helps real-world applications. But of COURSE the benchmarks are going to look good, since tuning the kernel to those benchmarks is the way the patch was developed!
Quoted 10 lines
The majority of the original low latency scheduling point work is handled automatically by the SMP on UP kernel. You don't NEED to insert scheduling points anywhere you aren't inside a spinlock. So the SMP on UP patch makes most of the explicit scheduling point patch go away, accomplishing the same thing in a less intrusive manner. (Yes, it makes all kernels act like SMP kernels for debugging purposes. But you can turn it off for debugging if you want to, that's just another toggle in the magic sysreq menu. And this isn't entirely a bad thing: applying the enormous UP userbase to the remaining SMP bugs is bound to squeeze out one or two more obscure ones, but those bugs DO exist already on SMP.)
This is the logic of _every_ variant of "lets put X windows in the kernel and let the kernel hackers fix it" . Konquerer crashed when I used it yesterday. Let's put it in the kernel too and apply that enormous UP userbase to the remaining bugs.
Quoted 17 lines
However, what's left of the explicit scheduling work is still very useful. When you ARE inside a spinlock, you can't just schedule, you have to save state, drop the lock(s), schedule, re-acquire the locks, and reload your state in case somebody else diddled with the structures you were using. This is a lot harder than just scheduling, but breaking up long-held locks like this helps SMP scalability, AND helps latency in the SMP-on-UP case.
So the best approach is a combination of the two patches. SMP-on-UP for everything outside of spinlocks, and then manually yielding locks that cause problems. Both Robert Love and Andrew Morton have come out in favor of each other's patches on lkml just in the past few days. The patches work together quite well, and each wants to see the other's patch applied.
Rob
Signature · 4 lines
--------------------------------------------------------- Victor Yodaiken Finite State Machine Labs: The RTLinux Company. www.fsmlabs.com www.rtlinux.com
Quoted 12 lines · Rob Landley
Quoted 10 lines · On Friday 11 January 2002 09:50 pm, [email protected] wrote:
Quoted 8 lines · Robert Love
On Fri, 2002-01-11 at 07:37, Alan Cox wrote:
The preemptible kernel plus the spinlock cleanup could really take us far. Having locked at a lot of the long-held locks in the kernel, I am confident at least reasonable progress could be made.Beyond that, yah, we need a better locking construct. Priority inversion could be solved with a priority-inheriting mutex, which we can tackle if and when we want to go that route. Not now.
Quoted 7 lines
Quoted 4 lines
Backing the car up to the edge of the cliff really gives us good results. Beyond that, we could jump off the cliff if we want to go that route.
Preempt leads to inheritance and inheritance leads to disaster.I preempt leads to disaster than Linux can't do SMP. Are you saying that's the case?
Victor is referring to priority inheritance, to solve priority inversion.
Priority inheritance seems undesirable for Linux - these applications are
already in the minority. A realtime application on Linux should simply
avoid complex system calls which can lead to blockage on a SCHED_OTHER thread.
If the app is well-designed, the only place in which it is likely to be unexpectedly blocked inside the kernel is in the page allocator. My approach to this problem is to cause non-SCHED_OTHER processes to perform atomic (non-blocking) memory allocations, with a fallback to non-atomic.
Quoted 8 lines
The preempt patch is really "SMP on UP". If pre-empt shows up a problem, then it's a problem SMP users will see too. If we can't take advantage of the existing SMP locking infrastructure to improve latency and interactive feel on UP machines, than SMP for linux DOES NOT WORK.
Quoted 2 lines
All the numbers I've seen show Morton's low latency just works better. Are there other numbers I should look at.
Quoted 6 lines
This approach is basically a collection of heuristics. The kernel has been profiled and everywhere a latency spike was found, a band-aid was put on it (an explicit scheduling point). This doesn't say there aren't other latency spikes, just that with the collection of hardware and software being benchmarked, the latency spikes that were found have each had a band-aid individually applied to them.
The preempt patch needs all this as well.
Quoted 7 lines
This isn't a BAD thing. If the benchmarks used to find latency spikes are at all like real-world use, then it helps real-world applications. But of COURSE the benchmarks are going to look good, since tuning the kernel to those benchmarks is the way the patch was developed!
The majority of the original low latency scheduling point work is handled automatically by the SMP on UP kernel.
No it is not.
The preempt code only obsoletes a handful of the low-latency patch's resceduling. The most trivial ones. generic_file_read, generic_file_write and a couple of /proc functions.
Of the sixty or so rescheduling points in the low-latency patch, about fifty are inside locks. Many of these are just lock_kernel(). About half are not.
Quoted 2 lines
You don't NEED to insert scheduling
points anywhere you aren't inside a spinlock.
I know of only four or five places in the kernel where large amount of time are spent in unlocked code. All the other problem areas are inside locks.
Quoted 2 lines
So the SMP on UP patch makes
most of the explicit scheduling point patch go away,
s/most/a trivial minority/
Quoted 2 lines
accomplishing the same
thing in a less intrusive manner.
s/less/more/
Quoted 6 lines
(Yes, it makes all kernels act like SMP
kernels for debugging purposes. But you can turn it off for debugging if you want to, that's just another toggle in the magic sysreq menu. And this isn't entirely a bad thing: applying the enormous UP userbase to the remaining SMP bugs is bound to squeeze out one or two more obscure ones, but those bugs DO exist already on SMP.)
Saying "it's a config option" is a cop-out. The kernel developers should be aiming at producing a piece of software which can be shrink-wrap deployed to millions of people.
Arguably, enabling it on UP and disabling it on SMP may be a sensible approach, meraly because SMP tends to map onto applications which do not require lower latencies.
Quoted 6 lines
However, what's left of the explicit scheduling work is still very useful. When you ARE inside a spinlock, you can't just schedule, you have to save state, drop the lock(s), schedule, re-acquire the locks, and reload your state in case somebody else diddled with the structures you were using. This is a lot harder than just scheduling, but breaking up long-held locks like this helps SMP scalability, AND helps latency in the SMP-on-UP case.
Yes, it _may_ help SMP scalability. But a better approach is to replace spinlocks with rwlocks when a lock is fond to have this access pattern.
Quoted 3 lines
So the best approach is a combination of the two patches. SMP-on-UP for everything outside of spinlocks, and then manually yielding locks that cause problems.
Well the ideal approach is to simply make the long-running locked code faster, by better choice of algorithm and data structure. Unfortunately, in the majority of cases, this isn't possible.
-
Quoted 5 lines · Rob Landley
So the best approach is a combination of the two patches. SMP-on-UP for everything outside of spinlocks, and then manually yielding locks that cause problems. Both Robert Love and Andrew Morton have come out in favor of each other's patches on lkml just in the past few days. The patches work together quite well, and each wants to see the other's patch applied.
Right. Here is what I want for 2.5 as a _general_ step towards a better kernel that will yield better performance:
Merge the preemptible kernel patch. A version is now out for 2.5.2-pre11 with support for Ingo's scheduler:
ftp://ftp.kernel.org/pub/linux/kernel/people/rml/preempt-kernel
Next, make available a tool for profiling kernel latencies. I have one available now, preempt-stats, at the above url. Andrew has some excellent tools available at his website, too. Something like this could even be merged. Daniel Phillips suggested a passive tool on IRC. Preempt-stats works like this. It is off-by-default and, when enabled, measures time between lock and unlock, reporting the top 20 worst-cases.
Begin working on the worst-case locks. Solutions like Andrew's low-latency and my lock-break are a start. Better (at least in general) solutions are to analyze the locks. Localize them; make them finer grained. Analyze the algorithms. Find the big problems. Anyone look at the tty layer lately? Ugh. Using the preemptive kernel as a base and the analysis of the locks as a list of culprits, clean this cruft up. This would benefit SMP, too. Perhaps a better locking construct is useful.
The immediate result is good; the future is better.
Robert Love
Quoted 1 line · In article <20020112042404.WCSI23959.femail47.sdc1.sfba.home.com@there> you…
The preempt patch is really "SMP on UP".
Ok I've seen this misconception quite a lot now. THIS IS NOT TRUE. For one, constructs that are ok on SMP are not automatically ok with the -preempt patch, like per-cpu data. And there's a LOT more of that than you think. Basically with preempt you change the locking rules from under all existing code. Most will work, even more will appear to work as preemption isn't an event THAT common (by this I mean the chance of getting preempted in your 4 lines of C code where you have per cpu data).
Also, once you add locks around the per-cpu data, for the core code it might be close to smp. For drivers it's not though. Drivers assume that when they do
outb(foo,bar);outb(foo2,bar2);
that those happen "close" to eachother in time. Especially in initialisation paths (where the driver thread is the only thread that can see the datastructures/device) there's no spinlocks helt so preempt can trigger here. Sure in the current situation you can get an interrupt but the linux interrupt delay is not more than, say, 1ms while a schedule-out can take a second or two easily. Do we know all devices can stand such delays ? I dare to say we don't as the hardware requirements currently aren't coded in the drivers.
Add to that that there's no actual benefit of -preempt over the -lowlat patch latency wise (you REALLY need to combine them or -preempt sucks raw eggs for latency)....
Greetings,
Arjan van de Ven
Quoted 11 lines · Robert Love
Quoted 4 lines · Alan Cox
Its more than a spinlock cleanup at that point. To do anything useful you have to tackle both priority inversion and some kind of at least semi-formal validation of the code itself. At the point it comes down to validating the code I'd much rather validate rtlinux than the entire kernel
The preemptible kernel plus the spinlock cleanup could really take us far. Having locked at a lot of the long-held locks in the kernel, I am confident at least reasonable progress could be made.
Quoted 8 lines
Beyond that, yah, we need a better locking construct. Priority inversion could be solved with a priority-inheriting mutex, which we can tackle if and when we want to go that route. Not now.
I want to lay the groundwork for a better kernel. The preempt-kernel patch gives real-world improvements, it provides a smoother user desktop experience -- just look at the positive feedback. Most importantly, however, it provides a framework for superior response with our standard
I don't know how to tell you, positive feedback compared to mainline kernel is totally irrelevant, mainline has broken read/write/sendfile syscalls that can hang the machine etc... That was fixed ages ago in many ways, current way is very lightweight, if you can get positive feedback compared to -aa _that_ will matter.
Andrea
Hi,
Quoted 7 lines · [email protected] wrote:
I believe that the preempt path leads inexorably to mutex-with-stupid-priority-trick and that would be very unfortunate indeed. It's unavoidable because sooner or later someone will find that preempt +
SCHED_FIFOleads to
niced app 1 in K mode gets Sem A
SCHED_FIFOapp prempts and blocks on Sem A whoops! app 2 in K more preempts niced app 1
Please explain what's different without the preempt patch.
Quoted 3 lines
Hey my DVD player has stalled, lets add
sem_with_revolting_priority_trick! Why the hell is UP Windows XP3 blowing away my Linux box on DVD playing while Linux now runs with the grace and speed of IRIX?
Because the IRIX implementation sucks, every implementation has to suck? Somehow I have the suspicion you're trying to discourage everyone from even trying, because if he'd succeeded you'd loose a big chunk of potential RTLinux customers.
bye, Roman
Quoted 12 lines · Roman Zippel
Hi,
Quoted 7 lines · [email protected] wrote:
I believe that the preempt path leads inexorably to mutex-with-stupid-priority-trick and that would be very unfortunate indeed. It's unavoidable because sooner or later someone will find that preempt +
SCHED_FIFOleads to
niced app 1 in K mode gets Sem A
SCHED_FIFOapp prempts and blocks on Sem A whoops! app 2 in K more preempts niced app 1
Quoted 1 line
Please explain what's different without the preempt patch.
See that "preempt" in line 2 . Linux does not
preempt kernel mode processes otherwise. The beauty of the non-preemptive kernel is that "in K mode every process makes progress" and even the "niced app" will complete its use of SemA and release it in one run. If you have a reasonably fair scheduler you can make very useful analysis with Linux now of the form
Under 50 active proceses in the system means that in every 2 second interval every process
will get at least 10ms of time to run.
That's a very valuable property and it goes away in a preemptive kernel to get you something vague.
Quoted 9 lines
Quoted 4 lines
Hey my DVD player has stalled, lets add
sem_with_revolting_priority_trick! Why the hell is UP Windows XP3 blowing away my Linux box on DVD playing while Linux now runs with the grace and speed of IRIX?Because the IRIX implementation sucks, every implementation has to suck? Somehow I have the suspicion you're trying to discourage everyone from even trying, because if he'd succeeded you'd loose a big chunk of potential RTLinux customers.
So your argument is that I'm advocating Andrew Morton's patch which reduces latencies more than the preempt patch because I have a financial interest in not reducing latencies? Subtle.
In any case, motive has no bearing on a technical argument. Your motive could be to make the 68K look better by reducing performance on other processors for all I know.
Signature · 4 lines
--------------------------------------------------------- Victor Yodaiken Finite State Machine Labs: The RTLinux Company. www.fsmlabs.com www.rtlinux.com
Quoted 3 lines · Robert Love
could even be merged. Daniel Phillips suggested a passive tool on IRC. Preempt-stats works like this. It is off-by-default and, when enabled, measures time between lock and unlock, reporting the top 20 worst-cases.
I think one of the problems with this entire debate is lack of meaningful numbers. Not for the first time, I propose that you test with something that tests application benefits instead of internal numbers that may not mean anything. For example, there is a simple test
/* user code */
get time.
count = 200*3600; /* one hour */
while(count--){
read cycle timer
clock_nanosleep(5 milliseconds)
read cycle timer
compute actual delay and difference from 5 milliseconds
store the worst case
}
get time.
printf("After one hour the worst deviation is %d clock ticks\n",worst);
printf("This was supposed to take one hour and it took %d", compute_elapsed());Quoted 5 lines
Begin working on the worst-case locks. Solutions like Andrew's low-latency and my lock-break are a start. Better (at least in general) solutions are to analyze the locks. Localize them; make them finer grained. Analyze the algorithms. Find the big problems. Anyone look
The theory that "fine grained = better" is not proved. It's obvious that "fine grained = more time spent in the overhead of locking and unlocking locks and
potentially more time spent in lock contention
and lots more opportunities of cache ping-pong in real smp and much harder to debug"
But the performance gain that is supposed to balance that is often elusive.
Quoted 6 lines
at the tty layer lately? Ugh. Using the preemptive kernel as a base and the analysis of the locks as a list of culprits, clean this cruft up. This would benefit SMP, too. Perhaps a better locking construct is useful.
The immediate result is good; the future is better.
Removing synchronization by removing contention
is better engineering than fiddling about with synchronization primitives, but it is much harder.
Signature · 4 lines
--------------------------------------------------------- Victor Yodaiken Finite State Machine Labs: The RTLinux Company. www.fsmlabs.com www.rtlinux.com
Hi,
Quoted 5 lines · [email protected] wrote:
Quoted 5 lines
Quoted 4 lines
SCHED_FIFOleads to
niced app 1 in K mode gets Sem ASCHED_FIFOapp prempts and blocks on Sem A whoops! app 2 in K more preempts niced app 1
Quoted 7 lines
Quoted 1 line
Please explain what's different without the preempt patch.
See that "preempt" in line 2 . Linux does not
preempt kernel mode processes otherwise. The beauty of the non-preemptive kernel is that "in K mode every process makes progress" and even the "niced app" will complete its use of SemA and release it in one run.
The point of using semaphores is that one can sleep while holding them, whether this is forced by preemption or voluntary makes no difference.
Quoted 9 lines
If you have a reasonably fair scheduler you
can make very useful analysis with Linux now of the formUnder 50 active proceses in the system means that in every 2 second interval every process
will get at least 10ms of time to run.That's a very valuable property and it goes away in a preemptive kernel to get you something vague.
How is that changed? AFAIK inserting more schedule points does not change the behaviour of the scheduler. The niced app will still get its time.
Quoted 3 lines
So your argument is that I'm advocating Andrew Morton's patch which reduces latencies more than the preempt patch because I have a financial interest in not reducing latencies? Subtle.
Andrew's patch requires constant audition and Andrew can't audit all drivers for possible problems. That doesn't mean Andrew's work is wasted, since it identifies problems, which preempting can't solve, but it will always be a hunt for the worst cases, where preempting goes for the general case.
Quoted 3 lines
In any case, motive has no bearing on a technical argument. Your motive could be to make the 68K look better by reducing performance on other processors for all I know.
I am more than busy to keep it running (together with a few others, who are left) and more important I make no money of it.
bye, Roman
Quoted 11 lines · Roman Zippel
Hi,
Quoted 7 lines · [email protected] wrote:
Quoted 6 lines
Quoted 4 lines
SCHED_FIFOleads to
niced app 1 in K mode gets Sem ASCHED_FIFOapp prempts and blocks on Sem A whoops! app 2 in K more preempts niced app 1Please explain what's different without the preempt patch.
Quoted 8 lines
Quoted 5 lines
See that "preempt" in line 2 . Linux does not
preempt kernel mode processes otherwise. The beauty of the non-preemptive kernel is that "in K mode every process makes progress" and even the "niced app" will complete its use of SemA and release it in one run.The point of using semaphores is that one can sleep while holding them, whether this is forced by preemption or voluntary makes no difference.
No. The point of using semaphores is that one can sleep while _waiting_ for the resource. Sleeping while holding semaphores is a different kettle of lampreys entirely.
And it makes a very big difference
A:
get sem on memory pool
do something horrible to pool
release sem on memory pool
In a preemptive kernel this can cause a deadlock. In a non preemptive it cannot. You are correct in that
B:
get sem on memory pool
do potentially blocking operations
release sem
is also dangerous - but I don't think that helps your case. To fix B, we can enforce a coding rule - one of the reasons why we have all those atomic ops in the kernel is to be able to avoid this problem.
To fix A in a preemptive kernel we need to start messing about with priorities and that's a major error.
"The current kernel has too many places where processes can sleep while holding semaphores so we should always have the potential of blocking with held semaphores" is, to me, a backwards argument.
Quoted 7 lines
Quoted 7 lines
If you have a reasonably fair scheduler you
can make very useful analysis with Linux now of the formUnder 50 active proceses in the system means that in every 2 second interval every process
will get at least 10ms of time to run.
Quoted 6 lines
Quoted 2 lines
That's a very valuable property and it goes away in a preemptive kernel to get you something vague.
How is that changed? AFAIK inserting more schedule points does not change the behaviour of the scheduler. The niced app will still get its time.
How many times can an app be preempted? In a non preempt kernel is can be preempted during user mode at timer frequency and no more and it cannot be preempted during kernel mode. So
while(1){
read mpeg data
process
write bitmap
}Assuming Andrew does not get too ambitious about read/write granularity, once this process is scheduled on a non-preempt system it will always make progress. The non preempt kernel says, "your kernel request will complete - if we have resources". A preempt kernel says: "well, if nobody more important activates you get some time" Now you do the analysis based on the computation of "goodness" to show that there is a bound on preemption count during an execution of this process. I don't want to have to think that hard.
Let's suppose the Gnome desktop constantly creates and
destroys new fresh i/o bound tasks to do something. So with the old fashioned non preempt (ignoring Andrew) we get
wait no more than 1 second
I'm scheduled and start a read
wait no more than one second
I'm scheduled and in user mode for at least 10milliseconds wait no more than 1 second
I'm scheduled and do my write
...
with preempt we get
wait no more than 1 second
I'm scheduled and start a read
I'm preempted
read not done
come back for 2 microseconds
preempted again
haven't issued the damn read request yet
ok a miracle happens, I finish the read request go to usermode and an interrupt happens
well it would be stupid to have a goodness function in a preempt kernel that lets a low priority task finish its time slice so preempt
...
Quoted 10 lines
Quoted 4 lines
So your argument is that I'm advocating Andrew Morton's patch which reduces latencies more than the preempt patch because I have a financial interest in not reducing latencies? Subtle.
Andrew's patch requires constant audition and Andrew can't audit all drivers for possible problems. That doesn't mean Andrew's work is wasted, since it identifies problems, which preempting can't solve, but it will always be a hunt for the worst cases, where preempting goes for the general case.
the preempt requires constant auditing too - and more complex auditing. After all, a missed audit in Andrew will simply increase worst case timing. A missed audit in preempt will hang the system.
Quoted 7 lines
Quoted 4 lines
In any case, motive has no bearing on a technical argument. Your motive could be to make the 68K look better by reducing performance on other processors for all I know.
I am more than busy to keep it running (together with a few others, who are left) and more important I make no money of it.
Come on! First of all, you are causing me a great deal of pain by making me struggle not to make some bad joke about the economics of Linux companies. More important, not making money has nothing to do with purity of motivation - don't you read this list?
And how do I know that you haven't got a stockpile of 68K boards that may be worth big money once it's known that 68K linux is at the top of the heap? Much less plausible money making schemes have been tried.
Seriously: for our business, a Linux kernel that can reliably run at millisecond level latencies is only good. If you could get a Linux kernel to run at latencies of 100 microseconds worst case on a 486, I'd be a little more worried but even then ...
On a 800Mhz Athlon, RTLinux scheduling jitter is 17microseconds worst case right now.
Signature · 4 lines
--------------------------------------------------------- Victor Yodaiken Finite State Machine Labs: The RTLinux Company. www.fsmlabs.com www.rtlinux.com
Quoted 21 lines · Andrea Arcangeli
Quoted 11 lines · Robert Love
Quoted 4 lines · Alan Cox
Its more than a spinlock cleanup at that point. To do anything useful you have to tackle both priority inversion and some kind of at least semi-formal validation of the code itself. At the point it comes down to validating the code I'd much rather validate rtlinux than the entire kernel
The preemptible kernel plus the spinlock cleanup could really take us far. Having locked at a lot of the long-held locks in the kernel, I am confident at least reasonable progress could be made.
Quoted 8 lines
Beyond that, yah, we need a better locking construct. Priority inversion could be solved with a priority-inheriting mutex, which we can tackle if and when we want to go that route. Not now.
I want to lay the groundwork for a better kernel. The preempt-kernel patch gives real-world improvements, it provides a smoother user desktop experience -- just look at the positive feedback. Most importantly, however, it provides a framework for superior response with our standard
Quoted 5 lines
I don't know how to tell you, positive feedback compared to mainline kernel is totally irrelevant, mainline has broken read/write/sendfile syscalls that can hang the machine etc... That was fixed ages ago in many ways, current way is very lightweight, if you can get positive feedback compared to -aa _that_ will matter.
Hello Andrea,
I did my usual compile testings (untar kernel archive, apply patches, make -j<value> ...
Here are some results (Wall time + Percent cpu) for each of the consecutive five runs:
13-pre5aa1 18-pre2aa2 18-pre3 18-pre3s 18-pre3sp j100: 6:59.79 78% 7:07.62 76% * 6:39.55 81% 6:24.79 83% j100: 7:03.39 77% 8:10.04 66% * 8:07.13 66% 6:21.23 83% j100: 6:40.40 81% 7:43.15 70% * 6:37.46 81% 6:03.68 87% j100: 7:45.12 70% 7:11.59 75% * 7:14.46 74% 6:06.98 87% j100: 6:56.71 79% 7:36.12 71% * 6:26.59 83% 6:11.30 86%
j75: 6:22.33 85% 6:42.50 81% 6:48.83 80% 6:01.61 89% 5:42.66 93% j75: 6:41.47 81% 7:19.79 74% 6:49.43 79% 5:59.82 89% 6:00.83 88% j75: 6:10.32 88% 6:44.98 80% 7:01.01 77% 6:02.99 88% 5:48.00 91% j75: 6:28.55 84% 6:44.21 80% 9:33.78 57% 6:19.83 85% 5:49.07 91% j75: 6:17.15 86% 6:46.58 80% 7:24.52 73% 6:23.50 84% 5:58.06 88%
* build incomplete (OOM killer killed several cc1 ... )
So far 2.4.13-pre5aa1 had been the king of the block in compile times. But this has changed. Now the (by far) fastest kernel is 2.4.18-pre
+ Ingos scheduler patch (s) + preemptive patch (p). I did not test preemptive patch alone so far since I don't know if the one I have applies cleanly against -pre3 without Ingos patch. I used the following patches:
s: sched-O1-2.4.17-H6.patch
p: preempt-kernel-rml-2.4.18-pre3-ingo-1.patch
I hope this info is useful to someone.
Kind regards,
Jogi
Signature · 3 lines
Well, yeah ... I suppose there's no point in getting greedy, is there?
<< Calvin & Hobbes >>Quoted 57 lines · On Sat, Jan 12, 2002 at 04:07:14PM +0100, [email protected] wrote:
Quoted 21 lines · Andrea Arcangeli
Quoted 11 lines · Robert Love
Quoted 4 lines · Alan Cox
Its more than a spinlock cleanup at that point. To do anything useful you have to tackle both priority inversion and some kind of at least semi-formal validation of the code itself. At the point it comes down to validating the code I'd much rather validate rtlinux than the entire kernel
The preemptible kernel plus the spinlock cleanup could really take us far. Having locked at a lot of the long-held locks in the kernel, I am confident at least reasonable progress could be made.
Quoted 8 lines
Beyond that, yah, we need a better locking construct. Priority inversion could be solved with a priority-inheriting mutex, which we can tackle if and when we want to go that route. Not now.
I want to lay the groundwork for a better kernel. The preempt-kernel patch gives real-world improvements, it provides a smoother user desktop experience -- just look at the positive feedback. Most importantly, however, it provides a framework for superior response with our standard
Quoted 5 lines
I don't know how to tell you, positive feedback compared to mainline kernel is totally irrelevant, mainline has broken read/write/sendfile syscalls that can hang the machine etc... That was fixed ages ago in many ways, current way is very lightweight, if you can get positive feedback compared to -aa _that_ will matter.
Hello Andrea,
I did my usual compile testings (untar kernel archive, apply patches, make -j<value> ...
Here are some results (Wall time + Percent cpu) for each of the consecutive five runs:
13-pre5aa1 18-pre2aa2 18-pre3 18-pre3s 18-pre3sp j100: 6:59.79 78% 7:07.62 76% * 6:39.55 81% 6:24.79 83% j100: 7:03.39 77% 8:10.04 66% * 8:07.13 66% 6:21.23 83% j100: 6:40.40 81% 7:43.15 70% * 6:37.46 81% 6:03.68 87% j100: 7:45.12 70% 7:11.59 75% * 7:14.46 74% 6:06.98 87% j100: 6:56.71 79% 7:36.12 71% * 6:26.59 83% 6:11.30 86%j75: 6:22.33 85% 6:42.50 81% 6:48.83 80% 6:01.61 89% 5:42.66 93% j75: 6:41.47 81% 7:19.79 74% 6:49.43 79% 5:59.82 89% 6:00.83 88% j75: 6:10.32 88% 6:44.98 80% 7:01.01 77% 6:02.99 88% 5:48.00 91% j75: 6:28.55 84% 6:44.21 80% 9:33.78 57% 6:19.83 85% 5:49.07 91% j75: 6:17.15 86% 6:46.58 80% 7:24.52 73% 6:23.50 84% 5:58.06 88%* build incomplete (OOM killer killed several cc1 ... )
So far 2.4.13-pre5aa1 had been the king of the block in compile times. But this has changed. Now the (by far) fastest kernel is 2.4.18-pre
+ Ingos scheduler patch (s) + preemptive patch (p). I did not test preemptive patch alone so far since I don't know if the one I have applies cleanly against -pre3 without Ingos patch. I used the following patches:
Quoted 4 lines
s: sched-O1-2.4.17-H6.patch
p: preempt-kernel-rml-2.4.18-pre3-ingo-1.patchI hope this info is useful to someone.
the improvement of "sp" compared to "s" is quite visible, not sure how can a little different time spent in kernel make such a difference on the final numbers, also given compilation is mostly an userspace task, I assume you were swapping out or running out of cache at the very least, right?
btw, I'd be curious if you could repeat the same test with -j1 or -j2? (actually real world)
Still the other numbers remains interesting for a trashing machine, but a few percent difference with a trashing box isn't a big difference, vm changes can infulence those numbers more than any preempt or scheduler number (of course if my guess that you're swapping out is really right :). I guess "p" helps because we simply miss some schedule point in some vm routine. Hints?
Andrea
Quoted 2 lines · On Sat, Jan 12, 2002 at 04:07:14PM +0100, [email protected] wrote:
I did my usual compile testings (untar kernel archive, apply patches, make -j<value> ...
If I understand your test,
you are testing different loads - you are compiling kernels that may differ in size and makefile organization, not to mention different layout on the file system and disk.
What happens when you do the same test, compiling one kernel under multiple different kernels?
Quoted 8 lines · On Sat, Jan 12, 2002 at 09:52:09AM -0700, [email protected] wrote:
Quoted 2 lines · On Sat, Jan 12, 2002 at 04:07:14PM +0100, [email protected] wrote:
I did my usual compile testings (untar kernel archive, apply patches, make -j<value> ...
If I understand your test,
you are testing different loads - you are compiling kernels that may differ in size and makefile organization, not to mention different layout on the file system and disk.
Ouch, I assumed this wasn't the case indeed.
Quoted 3 lines
What happens when you do the same test, compiling one kernel under multiple different kernels?
Andrea
Hi,
Quoted 5 lines · [email protected] wrote:
No. The point of using semaphores is that one can sleep while _waiting_ for the resource.
[...]
In a preemptive kernel this can cause a deadlock. In a non preemptive it cannot. You are correct in that
Quoted 8 lines
B:
get sem on memory pool
do potentially blocking operations
release sem
is also dangerous - but I don't think that helps your case. To fix B, we can enforce a coding rule - one of the reasons why we have all those atomic ops in the kernel is to be able to avoid this problem.
Sorry I can't follow you. First, one can sleep while waiting for the semaphore _and_ while holding it. Second we use atomic ops (e.g. for resource management) exactly because there are not protected by any semaphore/spinlock.
Quoted 4 lines
Let's suppose the Gnome desktop constantly creates and
destroys new fresh i/o bound tasks to do something. So with the old fashioned non preempt (ignoring Andrew) we get
[...]
There is no priority problem! If there is a more important task to run, the less important one simply has to wait, but it will still get its time. Your deadlock situation does not exists. The average time a process has to wait for a lower priority process might be increased, but the worst case behaviour is still the same.
The problem that does exist is the coarse time slice accounting, which is easier to exploit with the preempt kernel, but it's not a new problem. On the other hand it's a solvable problem, which requires no priority inversion.
Quoted 9 lines
Quoted 5 lines
Andrew's patch requires constant audition and Andrew can't audit all drivers for possible problems. That doesn't mean Andrew's work is wasted, since it identifies problems, which preempting can't solve, but it will always be a hunt for the worst cases, where preempting goes for the general case.
the preempt requires constant auditing too - and more complex auditing. After all, a missed audit in Andrew will simply increase worst case timing. A missed audit in preempt will hang the system.
As long as the scheduler isn't changed, this isn't true and as I said there are latency problems which preempting can't solve, but it will automatically take care of the rest.
Quoted 2 lines
Come on! First of all, you are causing me a great deal of pain by making me struggle not to make some bad joke about the economics of Linux companies.
Feel free, I'm not a big believer in the economics of software companies in general, anyway.
Quoted 2 lines
More important, not making money has nothing to do with purity of motivation - don't you read this list?
Everyone has its motivation and I do respect that, but I'm getting suspicious as soon as money is involved. If people disagree, they can still get along nicely and do their thing independently. But if they have to make a living by getting a share of a cake, it usually only works as long as there is enough cake, otherwise it can get nasty very quickly (and usually there is never enough cake).
bye, Roman
Quoted 5 lines · Andrew Morton
Priority inheritance seems undesirable for Linux - these applications are
already in the minority. A realtime application on Linux should simply
avoid complex system calls which can lead to blockage on aSCHED_OTHERthread.
I think it's very common to have SCHED_FIFO thread communicating with various other processes through pipe/fifo/socket or some other IPC mechanism.
It would be great to have priority inheritance where process receiving data through fifo from SCHED_FIFO process would have raised priority for transfer time. (see QNX priority inheriting message queues) Too bad we don't have message queues so we could have send/receive/reply time priority inheritance.
So we could have
Process 1 at SCHED_FIFO sending data to two processes. Process 2 at SCHED_FIFO receiving data from process 1. Process 3 at SCHED_OTHER receiving data from process 1. Process 4 at SCHED_OTHER sending data to process 5. Process 5 at SCHED_OTHER receiving data from process 4.
And (2) would get the data first from (1) and then (3). And if (1) starts sending data to (2) system would immediately start running (1/2) and even pre-empt the ongoing system call of (3). Also (1/3) would take over/pre-empt (4/5) because (3) inherits priority from sending process (1).
If this is currently _not_ done I think it's very strange.
But I think I have misunderstood the whole point of original message... :)
- Jussi Laako
Signature · 2 lines
PGP key fingerprint: 161D 6FED 6A92 39E2 EB5B 39DD A4DE 63EB C216 1E4B Available at PGP keyservers
Quoted 8 lines
Quoted 3 lines
Hey my DVD player has stalled, lets add
sem_with_revolting_priority_trick! Why the hell is UP Windows XP3 blowing away my Linux box on DVD playing while Linux now runs with the grace and speed of IRIX?Because the IRIX implementation sucks, every implementation has to suck? Somehow I have the suspicion you're trying to discourage everyone from even trying, because if he'd succeeded you'd loose a big chunk of potential RTLinux customers.
Victor has had the same message for years, as have others like Larry McVoy (in fact if Larry and Victor agree on something its unusual enough to
remember). So I can vouch for the fact Victor hasn't changed his tune from
before rtlinux was ever any real commercial toy. I think you owe him an apology.
Now rtlinux and low latency in the main kernel are two different things. One gives you effectively a small embedded system to program for which talks to Linux. From that you draw extremely reliable behaviour and very bounded delay times. Its small enough you can validate it too
RtLinux isn't going to help you one bit when it comes to smooth movie playback because the DVD playback is dependant on the Linux file system layers and a whole pile of other code. Low-latency does this quite nicely, and it takes you to the point where hardware becomes the biggest latency cause for the general case. Pre-empt doesn't buy you anything more. You can spend a millisecond locked in an I/O instruction to an irritating device.
Alan
Another example is in the network drivers. The 8390 core for one example carefully disables an IRQ on the card so that it can avoid spinlocking on uniprocessor boxes.
So with pre-empt this happens
driver magic disable_irq(dev->irq)
PRE-EMPT:
[large periods of time running other code]
PRE-EMPT:
We get back and we've missed 300 packets, the serial port sharing the IRQ has dropped our internet connection completely.
["Don't do that then" isnt a valid answer here. If I did hold a lock
it would be for several milliseconds at a time anyway and would reliably trash performance this time]
There are numerous other examples in the kernel tree where the current code knows that there is a small bounded time between two actions in kernel space that do not have a sleep. They are not spin locked, and putting spin locks everywhere will just trash performance. They are pure hardware interactions so you can't automatically detect them.
That is why the pre-empt code is a much much bigger problem and task than the low latency code.
Alan
Quoted 2 lines
Right. Here is what I want for 2.5 as a _general_ step towards a better kernel that will yield better performance:
I see absolutely _no_ evidence to support this repeated claim. I'm still waiting to see any evidence that low latency patches are not sufficient, or an explanation of who is going to fix all the drivers you break in subtle ways
Quoted 9 lines · On Sat, Jan 12, 2002 at 09:52:09AM -0700, [email protected] wrote:
Quoted 6 lines · On Sat, Jan 12, 2002 at 04:07:14PM +0100, [email protected] wrote:
Quoted 2 lines
I did my usual compile testings (untar kernel archive, apply patches, make -j<value> ...
If I understand your test,
you are testing different loads - you are compiling kernels that may
differ
Quoted 1 line
Quoted 1 line
in size and makefile organization, not to mention different layout on
the
Quoted 1 line
Quoted 1 line
file system and disk.
Can someone tell me why we're "testing" the preempt kernel by running make -j on a build? What exactly is this going to show us? The only thing i can think of is showing us that throughput is not damaged when you want to run single apps by using preempt. You dont get to see the effects of the kernel preemption because all the damn thing is doing is preempting itself.
If you want to test the preempt kernel you're going to need something that can find the mean latancy or "time to action" for a particular program or all programs being run at the time and then run multiple programs that you
would find on various peoples' systems. That is the "feel" people talk
about when they praise the preempt patch. make -j'ing something and not testing anything else but that will show you nothing important except "does
throughput get screwed by the preempt patch." Perhaps checking the
latencies on a common program on people's systems like mozilla or konqueror while doing a 'make -j N bzImage' would be a better idea.
Quoted 4 lines
Ouch, I assumed this wasn't the case indeed.
Quoted 2 lines
What happens when you do the same test, compiling one kernel under
multiple
Quoted 3 lines
Quoted 1 line
different kernels?
Andrea
You should _always_ use the same kernel tree at the same point each time you rerun the test under a different kernel. Always make clean before rebooting to the next kernel. setting up the test bed should be pretty straight
forward. make sure the build tree is clean then make dep it. reboot to
the next kernel. load up mozilla but nothing else (mozilla should be
modified a bit to display the time it takes to do certain functions such as displaying drop down menus, loading, opening a new window. Also you should make the homepage something on the drive or blank.). start make -j 4 bzImage then load mozilla (no other gnome gtk libraries or having them loaded via running gnome doesn't matter, just as long as it's the same each time). Mozilla should then output times it takes to do certain things and that should give you a good idea of how the preempt patch is performing assuming everything is running on the same priority and your memory isn't being maxed out and your hdd isn't eating the majority of the cpu time.
But i really think make -j'ing and only testing that or reporting those numbers is a complete waste of time if you're trying to look at the preempt's patch performance. I like using mozilla in this example because it's a big bulky app that most people have (kde users possibly excluded) where an improvement in latency or "time to action" is actually important to people, and cant be easily ignored.
well those are just my two cents, i'd do it myself but i'm waiting for hardware to replace the broken crap i have now. but if nobody has done it by then i'll set that up.
-formerly safemode
Quoted 16 lines
Another example is in the network drivers. The 8390 core for one example carefully disables an IRQ on the card so that it can avoid spinlocking on uniprocessor boxes.
So with pre-empt this happens
driver magic
disable_irq(dev->irq)
PRE-EMPT:
[large periods of time running other code]
PRE-EMPT:
We get back and we've missed 300 packets, the serial port sharing the IRQ has dropped our internet connection completely.
Quoted 5 lines
["Don't do that then" isnt a valid answer here. If I did hold a lock
it would be for several milliseconds at a time anyway and would reliably trash performance this timeThere are numerous other examples in the kernel tree where the current
code
Quoted 1 line
knows that there is a small bounded time between two actions in kernel
space
Quoted 2 lines
that do not have a sleep. They are not spin locked, and putting spin locks everywhere will just trash performance. They are pure hardware
interactions
Quoted 1 line
so you can't automatically detect them.
hardware to hardware could have a higher priority than normal programs being
run. That way they're not preempted by simple programs, it would have to
be purposely preempted by the user.
Quoted 1 line
That is why the pre-empt code is a much much bigger problem and task than
the
Quoted 1 line
low latency code.
Lowering the latency, sure the low latency code probably does nearly as well as the preempt patch. that's fine. Shortening the time locks are held by better code can help to a certain extent (unless a lot of the kernel code is poorly written, which i doubt). at it's present state though, my idea to fix the kernel would be to give parts of the kernel where locks are made, that shouldn't be broken normally, higher priorities. That way we can distinguish between safe locks to preempt at and the ones that can do harm. But those people who require their app to be treated special can run it
with -20 and preempt everything. To me that makes sense. Is there a
reason why it doesn't? Besides ethstetics. the only way the ethsetic
argument people are going to be pleased is if the kernel is designed from
the ground up to be better latency and lock-wise. A lot of people would
like to not have to wait until that time in the meantime.
Quoted 6 lines · Alan Cox
Another example is in the network drivers. The 8390 core for one example carefully disables an IRQ on the card so that it can avoid spinlocking on uniprocessor boxes.
So with pre-empt this happens
Quoted 7 lines
driver magic disable_irq(dev->irq)PRE-EMPT:
[large periods of time running other code]
PRE-EMPT:
We get back and we've missed 300 packets, the serial port sharing the IRQ has dropped our internet connection completely.
We don't preempt while IRQ are disabled.
Robert Love
Quoted 18 lines · Roman Zippel
Hi,
Quoted 5 lines · [email protected] wrote:
No. The point of using semaphores is that one can sleep while _waiting_ for the resource.
[...]
In a preemptive kernel this can cause a deadlock. In a non preemptive it cannot. You are correct in thatQuoted 8 lines
B:
get sem on memory pool
do potentially blocking operations
release sem
is also dangerous - but I don't think that helps your case. To fix B, we can enforce a coding rule - one of the reasons why we have all those atomic ops in the kernel is to be able to avoid this problem.
Quoted 1 line
Sorry I can't follow you. First, one can sleep while waiting for the
We're having a write only discussion - time to stop.
Quoted 3 lines · Ed Sweetman
hardware to hardware could have a higher priority than normal programs being
run. That way they're not preempted by simple programs, it would have to
be purposely preempted by the user.
Priority is currently, and sensibly, by process. A process may run user code, do sys-calls, or field interrupts both soft and hard. Now do you want to adjust the priority at every transition?
Quoted 5 lines
Lowering the latency, sure the low latency code probably does nearly as well as the preempt patch. that's fine. Shortening the time locks are held by better code can help to a certain extent (unless a lot of the kernel code is poorly written, which i doubt). at it's present state though, my idea to fix the kernel would be to give parts of the kernel where locks are made,
"Fix" what? What is the objective of your fix?
Quoted 4 lines
that shouldn't be broken normally, higher priorities. That way we can distinguish between safe locks to preempt at and the ones that can do harm. But those people who require their app to be treated special can run it
with -20 and preempt everything. To me that makes sense. Is there a
So:
get semaphore on slab memory and raise priority
get preempted by "treated special" app that then
does an operation on the slab queues
Is that what you want?
Quoted 1 line
reason why it doesn't? Besides ethstetics. the only way the ethsetic
It doesn't work? Is that a sufficient reason?
Signature · 4 lines
--------------------------------------------------------- Victor Yodaiken Finite State Machine Labs: The RTLinux Company. www.fsmlabs.com www.rtlinux.com
Quoted 15 lines · Robert Love
Quoted 6 lines · Alan Cox
Another example is in the network drivers. The 8390 core for one example carefully disables an IRQ on the card so that it can avoid spinlocking on uniprocessor boxes.
So with pre-empt this happens
Quoted 7 lines
driver magic disable_irq(dev->irq)PRE-EMPT:
[large periods of time running other code]
PRE-EMPT:
We get back and we've missed 300 packets, the serial port sharing the IRQ has dropped our internet connection completely.
Quoted 1 line
We don't preempt while IRQ are disabled.
You read the mask map? and somehow figure out which masked irqs correspond to active devices?
Quoted 8 lines
Robert Love
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Signature · 4 lines
--------------------------------------------------------- Victor Yodaiken Finite State Machine Labs: The RTLinux Company. www.fsmlabs.com www.rtlinux.com
Quoted 5 lines
Quoted 3 lines
PRE-EMPT:
We get back and we've missed 300 packets, the serial port sharing the IRQ has dropped our internet connection completely.We don't preempt while IRQ are disabled.
I must have missed that in the code. I can see you check __cli() status but I didn't see anywhere you check disable_irq(). Even if you did it doesnt help when I mask the irq on the chip rather than using disable_irq() calls.
Alan
Quoted 3 lines
hardware to hardware could have a higher priority than normal programs being
run. That way they're not preempted by simple programs, it would have to
be purposely preempted by the user.
How do you know they are there. How do you detect the situation, or do you plan to audit every driver ?
Quoted 2 lines
Lowering the latency, sure the low latency code probably does nearly as well as the preempt patch. that's fine. Shortening the time locks are held by
Not nearly as well. The tests I've seen it runs _better_ than just pre-empt and pre-empt + low latency is the same as pure low latency - 1mS
Alan
Quoted 5 lines · Alan Cox
Quoted 1 line
We don't preempt while IRQ are disabled.
I must have missed that in the code. I can see you check
__cli()status but I didn't see anywhere you checkdisable_irq(). Even if you did it doesnt help when I mask the irq on the chip rather than usingdisable_irq()calls.
Well, if IRQs are disabled we won't have the timer... would not the system panic anyhow if schedule() was called while in an interrupt handler?
Robert Love
Quoted 6 lines
Quoted 2 lines
I didn't see anywhere you check
disable_irq(). Even if you did it doesnt help when I mask the irq on the chip rather than usingdisable_irq()calls.Well, if IRQs are disabled we won't have the timer... would not the system panic anyhow if
schedule()was called while in an interrupt handler?
You completely misunderstand.
disable_irq(n)
I disable a single specific interrupt, I don't disable the timer interrupt. Your code doesn't seem to handle that. Its just one of the examples of where you really need priority handling, and thats a horrible dark and slippery slope
Alan
Quoted 6 lines · Roman Zippel
Andrew's patch requires constant audition and Andrew can't audit all drivers for possible problems. That doesn't mean Andrew's work is wasted, since it identifies problems, which preempting can't solve, but it will always be a hunt for the worst cases, where preempting goes for the general case.
Guys,
I've heard this so many times, and it just ain't so. The overwhelming
majority of problem areas are inside locks. All the complexity and maintainability difficulties to which you refer exist in the preempt
patch as well. There just is no difference.
-
Quoted 6 lines · Ed Sweetman
If you want to test the preempt kernel you're going to need something that can find the mean latancy or "time to action" for a particular program or all programs being run at the time and then run multiple programs that you
would find on various peoples' systems. That is the "feel" people talk
about when they praise the preempt patch.
Right. And that is precisely why I created the "mini-ll" patch. To give the improved "feel" in a way which is acceptable for merging into the 2.4 kernel.
And guess what? Nobody has tested the damn thing, so it's going
nowhere.
Here it is again:
fs/buffer.c +11 -2
@@ -249,12 +249,19 @@ static int wait_for_buffers(kdev_t dev,struct buffer_head * next;int nr; - next = lru_list[index]; nr = nr_buffers_type[index]; +repeat: + next = lru_list[index];while (next && --nr >=0 ) {struct buffer_head *bh = next; next = bh->b_next_free; +if (dev ==NODEV && current->need_resched) { +spin_unlock (&lru_list_lock); +conditional_schedule (); +spin_lock (&lru_list_lock); + goto repeat; + }if (!buffer_locked (bh)) {if (refile)__refile_buffer (bh);
@@ -1174,8 +1181,10 @@ struct buffer_head * bread(kdev_t dev, i bh =getblk (dev, block, size);touch_buffer (bh); -if (buffer_uptodate (bh)) +if (buffer_uptodate (bh)) { +conditional_schedule ();return bh; + }ll_rw_block (READ ,1 , &bh);wait_on_buffer (bh);if (buffer_uptodate (bh))
fs/dcache.c +2 -1
@@ -71,7 +71,7 @@ static inline void d_free(struct dentry* d_iput() operation if defined. * Called with dcache_lock held, drops it. */ -static inline void dentry_iput (struct dentry * dentry) +static void dentry_iput (struct dentry * dentry) {struct inode *inode = dentry->d_inode;if (inode) {
@@ -84,6 +84,7 @@ static inline void dentry_iput(struct deiput (inode); }else spin_unlock (&dcache_lock); +conditional_schedule (); }/*
fs/jbd/commit.c +10 -0
@@ -212,6 +212,16 @@ write_out_data_locked:__journal_remove_journal_head (bh);refile_buffer (bh);__brelse (bh); +if (current->need_resched) { +if (commit_transaction->t_sync_datalist) + commit_transaction->t_sync_datalist = + next_jh; +if (bufs) +break ; +spin_unlock (&journal_datalist_lock); +conditional_schedule (); + goto write_out_data; + } } }if (bufs ==ARRAY_SIZE (wbuf)) {
fs/proc/array.c +2 -0
@@ -415,6 +415,8 @@ static inline void statm_pte_range(pmd_tpte_t page = *pte;struct page *ptpage; +conditional_schedule (); + address +=PAGE_SIZE ; pte++;if (pte_none (page))
fs/proc/generic.c +3 -1
@@ -98,7 +98,9 @@ proc_file_read(struct file * file, char retval = n;break ; } - + +conditional_schedule (); +/* This is a hack to allow mangling of file pos independent * of actual bytes read. Simply place the data at page, * return the bytes, and set `start' to the desired offset
include/linux/condsched.h +18 -0
@@ -0,0 +1,18 @@ +#ifndef _LINUX_CONDSCHED_H +#define _LINUX_CONDSCHED_H + +#ifndef __LINUX_COMPILER_H +#include <linux/compiler.h> +#endif + +#ifndef __ASSEMBLY__ +#define conditional_schedule () \ +do { \ + if (unlikely(current->need_resched)) { \ + __set_current_state(TASK_RUNNING); \ + schedule(); \ + } \ +} while(0) +#endif + +#endif
include/linux/sched.h +1 -0
@@ -13,6 +13,7 @@ extern unsigned long event;#include <linux/times.h> #include <linux/timex.h> #include <linux/rbtree.h> +#include <linux/condsched.h> #include <asm/system.h> #include <asm/semaphore.h>
mm/filemap.c +7 -4
@@ -296,10 +296,7 @@ static int truncate_list_pages(struct lipage_cache_release (page); -if (current->need_resched) { -__set_current_state (TASK_RUNNING ); -schedule (); - } +conditional_schedule ();spin_lock (&pagecache_lock); goto restart;
@@ -609,6 +606,7 @@ void filemap_fdatasync(struct address_spUnlockPage (page);page_cache_release (page); +conditional_schedule ();spin_lock (&pagecache_lock); }spin_unlock (&pagecache_lock);
@@ -1392,6 +1390,9 @@ page_ok: offset &= ~PAGE_CACHE_MASK ;page_cache_release (page); + +conditional_schedule (); +if (ret == nr && desc->count)continue ;break ;
@@ -3025,6 +3026,8 @@ unlock:SetPageReferenced (page);UnlockPage (page);page_cache_release (page); + +conditional_schedule ();if (status <0 )break ;
drivers/block/ll_rw_blk.c +1 -0
@@ -917,6 +917,7 @@ void submit_bh(int rw, struct buffer_hea kstat.pgpgin += count;break ; } +conditional_schedule (); }/**
Quoted 11 lines · Alan Cox
Quoted 5 lines
Quoted 3 lines
PRE-EMPT:
We get back and we've missed 300 packets, the serial port sharing the IRQ has dropped our internet connection completely.We don't preempt while IRQ are disabled.
I must have missed that in the code. I can see you check
__cli()status but I didn't see anywhere you checkdisable_irq(). Even if you did it doesnt help when I mask the irq on the chip rather than usingdisable_irq()calls.Alan
But you get interrupted by other interrups then so you have the same problem reagardless of any preemtion patch you hopefully lose the cpu for a much shorter time but still the same problem.
Hi,
Quoted 10 lines · Alan Cox
Quoted 4 lines
Because the IRIX implementation sucks, every implementation has to suck? Somehow I have the suspicion you're trying to discourage everyone from even trying, because if he'd succeeded you'd loose a big chunk of potential RTLinux customers.
Victor has had the same message for years, as have others like Larry McVoy (in fact if Larry and Victor agree on something its unusual enough to
remember). So I can vouch for the fact Victor hasn't changed his tune from
before rtlinux was ever any real commercial toy. I think you owe him an apology.
Did I really say something that bad? I would be actually surprised, if Victor wouldn't act in the best interest of his company. The other possibility is that Victor must have had such a terrible experience with IRIX, so that he thinks any attempts to add better soft realtime or even hard realtime capabilities (not just as addon) must be doomed to fail.
Quoted 6 lines
RtLinux isn't going to help you one bit when it comes to smooth movie playback because the DVD playback is dependant on the Linux file system layers and a whole pile of other code. Low-latency does this quite nicely, and it takes you to the point where hardware becomes the biggest latency cause for the general case. Pre-empt doesn't buy you anything more. You can spend a millisecond locked in an I/O instruction to an irritating device.
Preemption doesn't solve of course every problem. It's mainly useful to get an event as fast as possible from kernel to user space. This can be the mouse click or the buffer your process is waiting for. Latencies can quickly sum up here to be sensible.
bye, Roman
Hi,
Quoted 9 lines · Alan Cox
So with pre-empt this happens
driver magic disable_irq(dev->irq)PRE-EMPT:
[large periods of time running other code]
PRE-EMPT:
We get back and we've missed 300 packets, the serial port sharing the IRQ has dropped our internet connection completely.
But it shouldn't deadlock as Victor is suggesting.
Quoted 5 lines
There are numerous other examples in the kernel tree where the current code knows that there is a small bounded time between two actions in kernel space that do not have a sleep. They are not spin locked, and putting spin locks everywhere will just trash performance. They are pure hardware interactions so you can't automatically detect them.
Why should spin locks trash perfomance, while an expensive disable_irq() doesn't?
bye, Roman
Quoted 8 lines · Andrew Morton
Quoted 6 lines · Ed Sweetman
If you want to test the preempt kernel you're going to need something that can find the mean latancy or "time to action" for a particular program or all programs being run at the time and then run multiple programs that you
would find on various peoples' systems. That is the "feel" people talk
about when they praise the preempt patch.
Quoted 6 lines
Right. And that is precisely why I created the "mini-ll" patch. To give the improved "feel" in a way which is acceptable for merging into the 2.4 kernel.
And guess what? Nobody has tested the damn thing, so it's going
nowhere.
I've tested it. I've been running it on my box for the last several days. Works just great. My box has been quite solid with it and I've not seen anything to prevent your sending it to Marcelo for 2.4.18...
-Erik
--
Erik B. Andersen http://codepoet-consulting.com/
--This message was written using 73% post-consumer electrons--
Quoted 11 lines · On Sat, 12 Jan 2002 12:23:09 -0800 Andrew Morton <[email protected]> wrote:
Quoted 6 lines · Ed Sweetman
If you want to test the preempt kernel you're going to need something that can find the mean latancy or "time to action" for a particular program or all programs being run at the time and then run multiple programs that you
would find on various peoples' systems. That is the "feel" people talk
about when they praise the preempt patch.Right. And that is precisely why I created the "mini-ll" patch. To give the improved "feel" in a way which is acceptable for merging into the 2.4 kernel.
Hm, I am not quite sure about what you expect to hear about it, but:
a) It applies cleanly to 2.4.18-pre3.
b) It compiles
c) During a load of around 150 produced by (of course :-) "make -j bzImage" and concurrent XMMS playing while my mail-client and mozilla are open, I cannot "feel" a real big difference in interactivity compared to vanilla kernel. XMMS hickups sometimes, mouse does kangaroo'ing, switching around different X-screens and screen refresh (especially mozilla of course) are no big hit.
This is a dual PIII-1GHz/2 GB RAM and some swap. During make no swapping is going on.
Sorry, but I cannot see (feel) the difference in _this_ test (if this is really a test for what you intend to do). Compile time btw makes no difference either. Perhaps this try is rather something for ingo and the scheduler...
Regards,
Stephan
Quoted 7 lines · On Sat, 12 Jan 2002 14:02:13 -0700 Erik Andersen <[email protected]> wrote:
Quoted 2 lines
And guess what? Nobody has tested the damn thing, so it's going
nowhere.I've tested it. I've been running it on my box for the last several days. Works just great. My box has been quite solid with it and I've not seen anything to prevent your sending it to Marcelo for 2.4.18...
Sorry for this dumb question:
What is the difference to vanilla exactly like in your setup? Better interactive feeling? Throughput?
Regards,
Stephan
Hi,
Quoted 1 line · [email protected] wrote:
We're having a write only discussion - time to stop.
Sorry, but I'm still waiting for the proof that preempting deadlocks the system.
If n running processes have together m time slices, after m ticks every process will have run it's full share of the time, no matter how often you schedule. (I assume here a correct time accounting, which is currently not the case, but that's a different (and not new) problem.) So even the low priority process will have the same time as before to do it's job, it will be delayed, but it will not be delayed forever, so I'm failing to see how preempting Linux should deadlock.
bye, Roman
Quoted 15 lines · Roman Zippel
Hi,
Quoted 10 lines · Alan Cox
Quoted 4 lines
Because the IRIX implementation sucks, every implementation has to suck? Somehow I have the suspicion you're trying to discourage everyone from even trying, because if he'd succeeded you'd loose a big chunk of potential RTLinux customers.
Victor has had the same message for years, as have others like Larry McVoy (in fact if Larry and Victor agree on something its unusual enough to
remember). So I can vouch for the fact Victor hasn't changed his tune from
before rtlinux was ever any real commercial toy. I think you owe him an apology.
Quoted 5 lines
Did I really say something that bad? I would be actually surprised, if Victor wouldn't act in the best interest of his company. The other possibility is that Victor must have had such a terrible experience with IRIX, so that he thinks any attempts to add better soft realtime or even hard realtime capabilities (not just as addon) must be doomed to fail.
Well, how about a third possibility - that I see a problem you have not seen and that you should try to argue on technical terms instead of psychoanlyzing me or looking for financial motives?
Signature · 4 lines
--------------------------------------------------------- Victor Yodaiken Finite State Machine Labs: The RTLinux Company. www.fsmlabs.com www.rtlinux.com
[Cc: trimmed]
Andrew Morton <[email protected]> :
[mini-ll]
Quoted 2 lines
And guess what? Nobody has tested the damn thing, so it's going
nowhere.
It allows me to del^W read NFS-mounted mail behind a linux router while I copy files locally on the router. If I don't apply mini-ll to the router, it's a "server foo not responding, still trying" fest. You know what "interactivity feel" means when it happens.
If someone suspects the hardware is crap, it's a PIV motherboard with built-in Promise20265 and four IBM IC35L060AVER07-0 on their own channel. Each disk has been able to behave normally during RAID1 rebuild.
Without mini-ll:
well choosen file I/O => no file I/O, no networking, no console, *big pain*.
With mini-ll:
well choosen file I/O => *only* those I/O suck (less than before btw).
Signature · 1 line
Ueimor
Quoted 9 lines · Kenneth Johansson
Quoted 5 lines
I must have missed that in the code. I can see you check
__cli()status but I didn't see anywhere you checkdisable_irq(). Even if you did it doesnt help when I mask the irq on the chip rather than usingdisable_irq()calls.Alan
But you get interrupted by other interrups then so you have the same problem reagardless of any preemtion patch you hopefully lose the cpu for a much shorter time but still the same problem.
Agreed. Further, you can't put _any_ upper bound on the number of interrupts that could occur, preempt or not. Sure, preempt can make it worse, but I don't see it. I have no bug reports to correlate.
Robert Love
Quoted 6 lines · Stephan von Krawczynski
Quoted 3 lines · On Sat, 12 Jan 2002 14:02:13 -0700 Erik Andersen <[email protected]> wrote:
Quoted 2 lines
And guess what? Nobody has tested the damn thing, so it's going
nowhere.
Quoted 8 lines
Quoted 4 lines
I've tested it. I've been running it on my box for the last several days. Works just great. My box has been quite solid with it and I've not seen anything to prevent your sending it to Marcelo for 2.4.18...
Sorry for this dumb question:
What is the difference to vanilla exactly like in your setup? Better interactive feeling? Throughput?
To be honest, not a _huge_ difference. I've been mostly doing development, and when I happen to have, for example, a kernel compile and a gcc compile going on, xmms isn't skipping for me at all, while previously I would hear skips every so often.
-Erik
--
Erik B. Andersen http://codepoet-consulting.com/
--This message was written using 73% post-consumer electrons--
Quoted 2 lines · Robert Love
Agreed. Further, you can't put _any_ upper bound on the number of interrupts that could occur, preempt or not. Sure, preempt can make it worse, but I don't see it. I have no bug reports to correlate.
OTOH we do have a pile of user reports which say the low latency patches give better results.
From my view here, low latency provides a more silky feel when e.g. playing RtCW or Q3A -
BTW I have checked out 2.4.18pre2-aa2 and am now running 2.4.18-pre3 + mini low latency.
* -aa absolutely kicks major booty in benchmarks.
* -mini-low-latency seems to do no worse than stock kernel benchmark-wise, but seems to be somehow smoother. I played some mp3s while running dbench 16 and heard no hitches. Also the RtCW test was successful, e.g. movement was fluid and I was victorious in most skirmishes with win32 opponents.
Regards,
jjs
Quoted 4 lines · Alan Cox
I see absolutely _no_ evidence to support this repeated claim. I'm still waiting to see any evidence that low latency patches are not sufficient, or an explanation of who is going to fix all the drivers you break in subtle ways
I'll work on fixing things the patch breaks. I don't think it will be that bad. I've been working on preemption for a long long time, and before me others have been working for a long long time, and I just don't see the hordes of broken drivers or the tons of race-conditions due to per-CPU data. I have seen some, and I have fixed them.
For a solution to latency concerns, I'd much prefer to lay a framework down that provides a proper solution and then work on fine tuning the kernel to get the desired latency out of it.
Robert Love
Quoted 3 lines
So even the low priority process will have the same time as before to do it's job, it will be delayed, but it will not be delayed forever, so I'm failing to see how preempting Linux should deadlock.
First task scheduled takes a resource that a second task needs. 150 other threads schedule via pre-emption, the one that it should share the resource with cannot run but the rest do. Repeat. It doesn't deadlock but it goes massively unfair
Quoted 5 lines
Quoted 2 lines
everywhere will just trash performance. They are pure hardware interactions so you can't automatically detect them.
Why should spin locks trash perfomance, while an expensive
disable_irq()doesn't?
disable_irq only blocks _one_ interrupt line, spin_lock_irqsave locks the interrupt off on a uniprocessor, and 50% of the time off on a dual processor.
If I use a spin lock you can't run a modem and an NE2000 card together on Linux 2.4. Thats why I had to do that work on the code. Its one of myriads of basic obvious cases that the pre-empt patch gets wrong
Quoted 4 lines
Preemption doesn't solve of course every problem. It's mainly useful to get an event as fast as possible from kernel to user space. This can be the mouse click or the buffer your process is waiting for. Latencies can quickly sum up here to be sensible.
The pre-emption patch doesn't change the average latencies. Go run some real benchmarks. Its lost in the noise after the low latency patch. A single inw from some I/O cards can cost as much as the latency target we hit.
Its not a case of the 90% of the result with 10% of the work, the pre-empt patch is firmly in the all pain no gain camp
Quoted 7 lines
Quoted 3 lines
I must have missed that in the code. I can see you check
__cli()status but I didn't see anywhere you checkdisable_irq(). Even if you did it doesnt help when I mask the irq on the chip rather than usingdisable_irq()calls.But you get interrupted by other interrups then so you have the same problem reagardless of any preemtion patch you hopefully lose the cpu for a much shorter time but still the same problem.
Interrupt paths are well sub millisecond, a pre empt might mean I don't get the CPU back for measurable chunks of a second. They are totally different guarantees.
Quoted 2 lines
And guess what? Nobody has tested the damn thing, so it's going
nowhere.
I've been testing it. It works for me, its not as good as the full one, it seems obviously correct. What else am I supposed to say.
I'm pretty much exclusively running Andre's new IDE code too. In fact I'm back to a page long list of applied diffs versus 2.4.18pre3, most of which I need to feed Marcelo
Quoted 7 lines
Quoted 3 lines
But you get interrupted by other interrups then so you have the same problem reagardless of any preemtion patch you hopefully lose the cpu for a much shorter time but still the same problem.
Agreed. Further, you can't put _any_ upper bound on the number of interrupts that could occur, preempt or not. Sure, preempt can make it worse, but I don't see it. I have no bug reports to correlate.
How may full benchmark sets have you done on an NE2000. Its quite obvious from your earlier mail you hadn't even considered problems like this.
Let me ask you the _right_ question instead
- Prove to me that there are no cases that pre-empt doesn't screw up
like this.
- Prove to me that pre-empt is better than the big low latency patch
All I have seen so far is benchmarks that say low latency is better as is, and evidence that preempt patches cause far more problems than they solve and have complex and subtle side effects nobody yet understands.
Furthermore its obvious that the only way to fix these side effects is to implement full priority handling to avoid priority inversion issues (which is precisely what the IRQ problem is) , that means implementing interrupt handlers as threads, heavyweight locks and an end result I'm really not interested in using.
Alan
Quoted 3 lines
For a solution to latency concerns, I'd much prefer to lay a framework down that provides a proper solution and then work on fine tuning the kernel to get the desired latency out of it.
As the low latency patch proves, the framework has always been there, the ll patches do the rest
Quoted 8 lines · On 20020112 Andrew Morton wrote:
Quoted 6 lines · Ed Sweetman
If you want to test the preempt kernel you're going to need something that can find the mean latancy or "time to action" for a particular program or all programs being run at the time and then run multiple programs that you
would find on various peoples' systems. That is the "feel" people talk
about when they praise the preempt patch.
Quoted 7 lines
Right. And that is precisely why I created the "mini-ll" patch. To give the improved "feel" in a way which is acceptable for merging into the 2.4 kernel.
And guess what? Nobody has tested the damn thing, so it's going
nowhere.
I have been running mini-ll on -pre3 for a time. And have just booted pre3 with full-ll. I see no marvelous diff between them, but I am not pushing my box to their knees.
I can get numbers for you, but is there any test out there that gives them ? Something like 'under this damned test your system just delayed as much as xxx us'. That kind of 'my xmms does not skip' does not look like a very serious measure.
And could you tell me if some of this patches can interfere with results ? This is what I am running just now:
- 2.4.18-pre3
- vm fixes from aa (vm-22, vm-raend, truncate-garbage)
- ext3-0.9.17 update
- ide-20011210 (hint: plz, make it in mainline for the time of .18...)
- irqrate-A1
- interrupts-seq-file
- spinlock-cacheline + fast-pte from -aa
- scalable timers
- sensors-cvs
- bproc 3.1.5
On that i have run full-ll+ll_fixes (from -aa) or mini-ll+ll_fixes.
(If someone is interested, patches are at
http://giga.cps.unizar.es/~magallon/linux/ )
TIA.
Signature · 4 lines
J.A. Magallon # Let the source be with you... mailto:[email protected] Mandrake Linux release 8.2 (Cooker) for i586 Linux werewolf 2.4.18-pre3-beo #5 SMP Sun Jan 13 02:14:04 CET 2002 i686
Quoted 6 lines · Alan Cox
You completely misunderstand.
disable_irq(n)I disable a single specific interrupt, I don't disable the timer interrupt. Your code doesn't seem to handle that.
It can if we increment the preempt_count in disable_irq_nosync and decrement it on enable_irq.
Robert Love
Hi,
Quoted 2 lines · [email protected] wrote:
Well, how about a third possibility - that I see a problem you have not seen and that you should try to argue on technical terms
I just don't see any problem that is really new. Alan's example is one of more extreme ones, but the only effect is that an operation can be delayed far more than usual, but not indefinitely.
If you think preemption can cause a deadlock, maybe you could give me a hint, which of the conditions for a deadlock is changed by preemption?
Quoted 2 lines
instead of psychoanlyzing
me or looking for financial motives?
If I had known, how easily people are offended by implying they could act out of financial interest, I hadn't made that comment. Sorry, but I'm just annoyed, how you attack any attempt to add realtime capabilities to the kernel, mostly with the argument that it sucks under IRIX. I people want to try it, let them. I prefer to see patches and if they should really suck, I would be first one to say so.
bye, Roman
Quoted 16 lines · Roman Zippel
Hi,
Quoted 2 lines · [email protected] wrote:
Well, how about a third possibility - that I see a problem you have not seen and that you should try to argue on technical terms
I just don't see any problem that is really new. Alan's example is one of more extreme ones, but the only effect is that an operation can be delayed far more than usual, but not indefinitely.
If you think preemption can cause a deadlock, maybe you could give me a hint, which of the conditions for a deadlock is changed by preemption?Quoted 2 lines
instead of psychoanlyzing
me or looking for financial motives?
Quoted 6 lines
If I had known, how easily people are offended by implying they could act out of financial interest, I hadn't made that comment. Sorry, but I'm just annoyed, how you attack any attempt to add realtime capabilities to the kernel, mostly with the argument that it sucks under IRIX. I people want to try it, let them. I prefer to see patches and if they should really suck, I would be first one to say so.
I'm annoyed that you take a comment in which I said that the Morton approach was much preferrable to the preempt patch and respond by saying I "attack any attempt to add realtime capabilities to the kernel".
I'm all in favor of people trying all sorts of things. My original comment was that the numbers I'd seen all favored the Morton patch and I still haven't seen any evidence to the contrary.
I also made two very simple and specific comments:
1) I don't see how processor specific caching, which seems essential for smp performance and will be more essential with numa, works with this patch
2) preempt seems to lead inescapably to priority inherit. If this is true, people better understand the ramifications now before they commit.
Of course, I think there are strong limits to what you can get for RT performance in the kernel - I think the RTLinux method is far superior. Believe what you want - it won't change the numbers.
Signature · 4 lines
--------------------------------------------------------- Victor Yodaiken Finite State Machine Labs: The RTLinux Company. www.fsmlabs.com www.rtlinux.com
Quoted 13 lines · Roman Zippel
Hi,
Quoted 9 lines · Alan Cox
So with pre-empt this happens
driver magic disable_irq(dev->irq)PRE-EMPT:
[large periods of time running other code]
PRE-EMPT:
We get back and we've missed 300 packets, the serial port sharing the IRQ has dropped our internet connection completely.
Quoted 1 line
But it shouldn't deadlock as Victor is suggesting.
Um, hang on...
Obvioiusly, Alan, you know more about the networking stack than I do. :) But could you define "large periods of time running other code"?
The real performance KILLER is when your code gets swapped out, and that simply doesn't happen in-kernel. Yes, the niced app may get swapped out, but the syscall it's making is pinned in ram and it will only block on disk access when it returns. So we're talking what kind of delay here, one second?
As for scheduling, even a nice 19 task will still get SOME time, and we can find out exactly what the worst case is since we hand out time slices and we don't hand out more until EVERYBODY exhausts theirs, including seriously niced processes. So this isn't exactly non-deterministic behavior, is it? There IS an upper bound here...
There ISN'T an upper bound on interrupts. We've got some nasty interrupts in the system. How long does the PCI bus get tied up with spinning video cards flooding the bus to make their benchmarks look 5% better? How long of a latency spike did we (until recently) get switching between graphics and text consoles? (I heard that got fixed, moved into a tasklet or some such. Haven't looked at it yet.) Without Andre's IDE patches, how much latency can the disk insert at random?
Yes, it's possible than if you have a fork bomb trying to take down your system, and you're using an old 10baseT ethernet driver built with some serious assumptions about how the kernel works, that you could drop some packets. But I find it interesting that make -j can be considered a fairly unrealistic test intentionally overloading the system, yet an example with 150 active threads all eating CPU time is NOT considered an example of how your process's receive buffer could easily fill up and drop packets no matter HOW fast the interrupt is working since even 10baseT feeds you 1.1 megabytes per second and with a 1 second delay we might have to swap stuff out to make room for them if we don't read from the socket in that long...
One other fun little thing about the scheduler: a process that is submitting network packets probably isn't entirely CPU bound, is it? It's doing I/O. So even if it's niced, if it's competing with totally CPU bound tasks isn't it likely to get promoted? How real-world is your overload-induced failure case example?
As for dropping 300 packets killing your connection, are you saying 802.11 cards can't have a static burst that blocks your connection for half a second? I've had full second gaps in network traffic on my cable modem, all time time, and the current overload behavior of most routers is dropping lots and lots of packets on the floor. (My in-house network is still using an ancient 10baseT half-duplex hub. I'm lazy, and it's still way faster than my upstream connection to the internet.) Datagram delivery is not guaranteed. It never has been. Maybe it will be once ECN comes in, but that's not yet.
What's one of the other examples you were worried about, besides NE2K (which can't do 100baseT, even on PCI, and a 100baseT PCI card is now $9 new. Just a data point.)
Rob
(P.S. The only behavior difference between preempt and SMP, apart from contention for per-cpu data, is the potential insertion of latency spikes in kernel code, which interrupts do anyway. You're saying it can matter when something disables an interrupt. Robert Love suggested the macro that disables an interrupt can count as a preemption guard just like a spinlock. Is this NOT enough to fix the objection?)
Quoted 2 lines · On Sat, 12 Jan 2002 12:23:09 -0800 Andrew Morton <[email protected]> wrote:
And guess what? Nobody has tested the damn thing, so it's going
nowhere.
Haven't had latency problems, to be honest. Maybe I should start playing mp3s while I code?
1) conditional_schedule? Hmmm... Why the __set_current_state? I think I prefer an explicit "if (need_schedule()) schedule()", with
#define need_schedule() unlikely(current->need_resched)
2) I hate condsched.h: Use sched.h please!
3) Why this:
include/linux/condsched.h line 6
Quoted 3 lines
include/linux/condsched.h +3
-0+#ifndef __LINUX_COMPILER_H +#include <linux/compiler.h> +#endif
Other than that, I like this patch. Linus?
Rusty.
Signature · 1 line
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
Quoted 2 lines · Robert Love
It can if we increment the
preempt_countindisable_irq_nosyncand decrement it onenable_irq.
Who says you're going to be enabling IRQs any time soon? AFAIK, there is nothing that requires enable_irq to be called after disable_irq_nosync.
In fact, you could well have the following in a driver:
/* initial shutdown of device */ disable_irq_nosync(i); /* or disable_irq(i); */ /* other shutdown stuff */ free_irq(i, private);
and you would have to audit all drivers to find out if they did this - this would seriously damage your preempt_count.
Signature · 2 lines
Russell King ([email protected]) The developer of ARM Linux http://www.arm.linux.org.uk/personal/aboutme.html
Hi,
Quoted 7 lines · Alan Cox
disable_irqonly blocks _one_ interrupt line,spin_lock_irqsavelocks the interrupt off on a uniprocessor, and 50% of the time off on a dual processor.If I use a spin lock you can't run a modem and an NE2000 card together on Linux 2.4. Thats why I had to do that work on the code. Its one of myriads of basic obvious cases that the pre-empt patch gets wrong
I wouldn't say it gets it wrong, the driver also has to take a non irq spinlock anyway, so the window is quite small and even then the packet is only delayed.
But now I really have to look at that driver and try a more optimistic irq disabling approach, otherwise it will happily disable the most important shared interrupt on my Amiga for ages.
bye, Roman
Quoted 3 lines
I wouldn't say it gets it wrong, the driver also has to take a non irq spinlock anyway, so the window is quite small and even then the packet is only delayed.
Or you lose a pile of them
Quoted 3 lines
But now I really have to look at that driver and try a more optimistic irq disabling approach, otherwise it will happily disable the most important shared interrupt on my Amiga for ages.
If you play with the code remember that the irq delivery on x86 is asynchronous. You can disable the irq on the chip, synchronize_irq() on the result and very occasionally get the irq delivered after all of that
Hi,
Quoted 1 line · Alan Cox
All I have seen so far is benchmarks that say low latency is better as is,
If Andrew did a good job (what he obviously did), I don't doubt that.
Quoted 2 lines
and evidence that preempt patches cause far more problems than they solve and have complex and subtle side effects nobody yet understands.
I'm aware of two side effects:
- preempt exposes already existing problems, which are worth fixing independent of preempt.
- it can cause unexpected delays, which should be nonfatal, otherwise worth fixing as well.
What somehow got lost in this discussion, that both patches don't necessarily conflict with each other, they both attack the same problem with different approaches, which complement each other. I prefer to get the best of both patches.
The ll patch identifies problem, which preempt alone can't fix, on the other hand the ll patch inserts schedule calls all over the place, where preempt can handle this transparently. So far I haven't seen any evidence, that preempt introduces any _new_ serious problems, so I'd rather like to see to get the best out of both.
Quoted 5 lines
Furthermore its obvious that the only way to fix these side effects is to implement full priority handling to avoid priority inversion issues (which is precisely what the IRQ problem is) , that means implementing interrupt handlers as threads, heavyweight locks and an end result I'm really not interested in using.
It's not really needed to go that far, it's generally a good idea to keep interrupt handler as short as possible, we use bh or tasklets for exactly that reason. I don't think we need to work around broken hardware, but halfway decent hardware should not be a problem to get decent latency.
bye, Roman
Quoted 20 lines · Ed Sweetman
Quoted 9 lines · On Sat, Jan 12, 2002 at 09:52:09AM -0700, [email protected] wrote:
Quoted 6 lines · On Sat, Jan 12, 2002 at 04:07:14PM +0100, [email protected] wrote:
Quoted 2 lines
I did my usual compile testings (untar kernel archive, apply patches, make -j<value> ...
If I understand your test,
you are testing different loads - you are compiling kernels that maydiffer
Quoted 1 line
Quoted 1 line
in size and makefile organization, not to mention different layout on
the
Quoted 1 line
Quoted 1 line
file system and disk.
Can someone tell me why we're "testing" the preempt kernel by running make -j on a build? What exactly is this going to show us? The only thing i can think of is showing us that throughput is not damaged when you want to run single apps by using preempt. You dont get to see the effects of the kernel preemption because all the damn thing is doing is preempting itself.
Quoted 9 lines
If you want to test the preempt kernel you're going to need something that can find the mean latancy or "time to action" for a particular program or all programs being run at the time and then run multiple programs that you
would find on various peoples' systems. That is the "feel" people talk
about when they praise the preempt patch. make -j'ing something and not testing anything else but that will show you nothing important except "does
throughput get screwed by the preempt patch." Perhaps checking the
latencies on a common program on people's systems like mozilla or konqueror while doing a 'make -j N bzImage' would be a better idea.
That's the second test I am normally running. Just running xmms while doing the kernel compile. I just wanted to check if the system slows down because of preemption but instead it compiled the kernel even faster :-) But so far I was not able to test the latency and furthermore it is very difficult to "measure" skipping of xmms ...
Quoted 1 line
Quoted 1 line
Ouch, I assumed this wasn't the case indeed.
Sorry for not answering immedeatly but I am compiling the same kernel source with the same .config and everything I could think of being the same! I even do a 'rm -rf linux' after every run and untar the same sources *every* time.
Regards,
Jogi
Signature · 3 lines
Well, yeah ... I suppose there's no point in getting greedy, is there?
<< Calvin & Hobbes >>Quoted 8 lines · On Sat, Jan 12, 2002 at 09:52:09AM -0700, [email protected] wrote:
Quoted 2 lines · On Sat, Jan 12, 2002 at 04:07:14PM +0100, [email protected] wrote:
I did my usual compile testings (untar kernel archive, apply patches, make -j<value> ...
If I understand your test,
you are testing different loads - you are compiling kernels that may differ in size and makefile organization, not to mention different layout on the file system and disk.
No, I use a script which is run in single user mode after a reboot. So there are only a few processes running when I start the script (see attachment) and the jobs should start from the same environment.
Quoted 2 lines
What happens when you do the same test, compiling one kernel under multiple different kernels?
That is exactly what I am doing. I even try to my best to have the exact same starting environment ...
Regards,
Jogi
Signature · 3 lines
Well, yeah ... I suppose there's no point in getting greedy, is there?
<< Calvin & Hobbes >>Quoted 1 line · Andrea Arcangeli
On Sat, Jan 12, 2002 at 04:07:14PM +0100, [email protected] wrote:
[...]
Quoted 32 lines
Quoted 32 lines
Hello Andrea,
I did my usual compile testings (untar kernel archive, apply patches, make -j<value> ...
Here are some results (Wall time + Percent cpu) for each of the consecutive five runs:
13-pre5aa1 18-pre2aa2 18-pre3 18-pre3s 18-pre3sp j100: 6:59.79 78% 7:07.62 76% * 6:39.55 81% 6:24.79 83% j100: 7:03.39 77% 8:10.04 66% * 8:07.13 66% 6:21.23 83% j100: 6:40.40 81% 7:43.15 70% * 6:37.46 81% 6:03.68 87% j100: 7:45.12 70% 7:11.59 75% * 7:14.46 74% 6:06.98 87% j100: 6:56.71 79% 7:36.12 71% * 6:26.59 83% 6:11.30 86%j75: 6:22.33 85% 6:42.50 81% 6:48.83 80% 6:01.61 89% 5:42.66 93% j75: 6:41.47 81% 7:19.79 74% 6:49.43 79% 5:59.82 89% 6:00.83 88% j75: 6:10.32 88% 6:44.98 80% 7:01.01 77% 6:02.99 88% 5:48.00 91% j75: 6:28.55 84% 6:44.21 80% 9:33.78 57% 6:19.83 85% 5:49.07 91% j75: 6:17.15 86% 6:46.58 80% 7:24.52 73% 6:23.50 84% 5:58.06 88%* build incomplete (OOM killer killed several cc1 ... )
So far 2.4.13-pre5aa1 had been the king of the block in compile times. But this has changed. Now the (by far) fastest kernel is 2.4.18-pre
+ Ingos scheduler patch (s) + preemptive patch (p). I did not test preemptive patch alone so far since I don't know if the one I have applies cleanly against -pre3 without Ingos patch. I used the following patches:s: sched-O1-2.4.17-H6.patch
p: preempt-kernel-rml-2.4.18-pre3-ingo-1.patch
Quoted 7 lines
Quoted 1 line
I hope this info is useful to someone.
the improvement of "sp" compared to "s" is quite visible, not sure how can a little different time spent in kernel make such a difference on the final numbers, also given compilation is mostly an userspace task, I assume you were swapping out or running out of cache at the very least, right?
The system is *heavily* swapping. Plain 2.4.18-pre3 can not even finish the jobs because it runs out of memory. That's why I used j75 or j100 initially. Otherwise there was not even a difference between the 2.4.10+ vm and the 2.4.9-ac+ vm. All I want to test with this "benchmark" is how well the system reacts when I throw *lots* of compilation jobs at it ...
Quoted 2 lines
btw, I'd be curious if you could repeat the same test with -j1 or -j2? (actually real world)
Using just -j1 or -j2 will probably be no difference (I will test it anyway and post the results).
Quoted 6 lines
Still the other numbers remains interesting for a trashing machine, but a few percent difference with a trashing box isn't a big difference, vm changes can infulence those numbers more than any preempt or scheduler number (of course if my guess that you're swapping out is really right :). I guess "p" helps because we simply miss some schedule point in some vm routine. Hints?
But what *I* like most about the preemptive results are that the results for all runs do not vary that much. Looking at plain 2.4.18-pre3 there is a huge difference in runtime between the fastest and the longest run.
Regards,
Jogi
Signature · 3 lines
Well, yeah ... I suppose there's no point in getting greedy, is there?
<< Calvin & Hobbes >>Quoted 4 lines
What somehow got lost in this discussion, that both patches don't necessarily conflict with each other, they both attack the same problem with different approaches, which complement each other. I prefer to get the best of both patches.
When you look at the benchmark there is no difference between ll and ll+pre-empt. ll alone takes you to the 1ms point. pre-empt takes you no further and to get much out of pre-emption requires you go and do all the hideously slow and complex priority inversion stuff.
Quoted 3 lines
exactly that reason. I don't think we need to work around broken hardware, but halfway decent hardware should not be a problem to get decent latency.
We have to work around common hardware not designed for SMP - the 8390 isnt a broken chip in that sense, its just from a different era, and there are a lot of them.
Quoted 4 lines · Roman Zippel
What somehow got lost in this discussion, that both patches don't necessarily conflict with each other, they both attack the same problem with different approaches, which complement each other. I prefer to get the best of both patches.
If you do this (and I've seen the results of doing both at once vs only either of then vs pure) then there's NO benifit for the preemption left. Sure AVERAGE latency goes down slightly, however this is talking in the usec range since worst case is already 1msec or less. Below the 1msec range it really doesn't matter anymore however.
At that point you're adding all the complexity for the negliable-to-no-gain case...
Greetings,
Arjan van de Ven
Quoted 2 lines
Obvioiusly, Alan, you know more about the networking stack than I do. :) But could you define "large periods of time running other code"?
10ths of a second if there is a lot to let run instead of this thread. Even 1/100th is bad news.
Quoted 3 lines
There ISN'T an upper bound on interrupts. We've got some nasty interrupts in the system. How long does the PCI bus get tied up with spinning video cards flooding the bus to make their benchmarks look 5% better? How long of a
They dont flood the bus with interrupts, the lock the bus off for several millseconds worst case. Which btw you'll note means that lowlatency already achieves the best value you can get
Quoted 3 lines
latency spike did we (until recently) get switching between graphics and text consoles? (I heard that got fixed, moved into a tasklet or some such. Haven't looked at it yet.) Without Andre's IDE patches, how much latency can
Been fixed in -ac for ages, and finally made Linus tree.
Quoted 1 line
the disk insert at random?
IDE with or without Andre's changes can insert multiple millisecond delays on the bus in some situations. Again pre-empt patch can offer you nothing because the hardware limit is easily met by low latency
Quoted 2 lines
One other fun little thing about the scheduler: a process that is submitting network packets probably isn't entirely CPU bound, is it? It's doing I/O.
Network packets get submitted from _outside_
Alan
Quoted 5 lines
Quoted 2 lines
I disable a single specific interrupt, I don't disable the timer interrupt. Your code doesn't seem to handle that.
It can if we increment the
preempt_countindisable_irq_nosyncand decrement it onenable_irq.
A driver that knows about how its irq is handled and that it is sole user (eg ISA) may and some do leave it disabled for hours at a time
Quoted 8 lines · Andrew Morton
Quoted 6 lines · Ed Sweetman
If you want to test the preempt kernel you're going to need something that can find the mean latancy or "time to action" for a particular program or all programs being run at the time and then run multiple programs that you
would find on various peoples' systems. That is the "feel" people talk
about when they praise the preempt patch.
Quoted 6 lines
Right. And that is precisely why I created the "mini-ll" patch. To give the improved "feel" in a way which is acceptable for merging into the 2.4 kernel.
And guess what? Nobody has tested the damn thing, so it's going
nowhere.
Ok, as promised, here are the results:
13-pre5aa1 18-pre2aa2 18-pre3 18-pre3s 18-pre3sp 18-pre3minill j100: 6:59.79 78% 7:07.62 76% * 6:39.55 81% 6:24.79 83% * j100: 7:03.39 77% 8:10.04 66% * 8:07.13 66% 6:21.23 83% * j100: 6:40.40 81% 7:43.15 70% * 6:37.46 81% 6:03.68 87% * j100: 7:45.12 70% 7:11.59 75% * 7:14.46 74% 6:06.98 87% * j100: 6:56.71 79% 7:36.12 71% * 6:26.59 83% 6:11.30 86% *
j75: 6:22.33 85% 6:42.50 81% 6:48.83 80% 6:01.61 89% 5:42.66 93% 7:07.56 77% j75: 6:41.47 81% 7:19.79 74% 6:49.43 79% 5:59.82 89% 6:00.83 88% 7:17.15 74% j75: 6:10.32 88% 6:44.98 80% 7:01.01 77% 6:02.99 88% 5:48.00 91% 6:47.48 80% j75: 6:28.55 84% 6:44.21 80% 9:33.78 57% 6:19.83 85% 5:49.07 91% 6:34.02 83% j75: 6:17.15 86% 6:46.58 80% 7:24.52 73% 6:23.50 84% 5:58.06 88% 7:01.39 77%
Regards,
Jogi
Signature · 3 lines
Well, yeah ... I suppose there's no point in getting greedy, is there?
<< Calvin & Hobbes >>Quoted 5 lines · On Sun, Jan 13, 2002 at 04:18:23PM +0100, [email protected] wrote:
Quoted 4 lines · On Sat, Jan 12, 2002 at 09:52:09AM -0700, [email protected] wrote:
Quoted 2 lines · On Sat, Jan 12, 2002 at 04:07:14PM +0100, [email protected] wrote:
I did my usual compile testings (untar kernel archive, apply patches, make -j<value> ...
Quoted 8 lines
Quoted 4 lines
If I understand your test,
you are testing different loads - you are compiling kernels that may differ in size and makefile organization, not to mention different layout on the file system and disk.No, I use a script which is run in single user mode after a reboot. So there are only a few processes running when I start the script (see attachment) and the jobs should start from the same environment.
But your description makes it sound like you do
untar kernel X
apply patches Y
make -j Tree
I'm sorry if I'm getting you wrong, but each of these steps is variable.
Even if X and Y are the same each time, "Tree" is different.
The test should be
reboot
N times
make clean
time make -j Tree
Am I misunderstaning your test?
Quoted 16 lines
Quoted 3 lines
What happens when you do the same test, compiling one kernel under multiple different kernels?
That is exactly what I am doing. I even try to my best to have the exact same starting environment ...
Regards,
Jogi
Signature · 3 lines
Well, yeah ... I suppose there's no point in getting greedy, is there? << Calvin & Hobbes >>
Signature · 4 lines
--------------------------------------------------------- Victor Yodaiken Finite State Machine Labs: The RTLinux Company. www.fsmlabs.com www.rtlinux.com
Quoted 9 lines · On Sun, 2002-01-13 at 10:18, [email protected] wrote:
No, I use a script which is run in single user mode after a reboot. So there are only a few processes running when I start the script (see attachment) and the jobs should start from the same environment.
Quoted 2 lines
What happens when you do the same test, compiling one kernel under multiple different kernels?
That is exactly what I am doing. I even try to my best to have the exact same starting environment ...
So there you go, his testing is accurate. Now we have results that preempt works and is best and it is still refuted. Everyone is running around with these "ll is best" or "preempt sucks throughput" and that is not true. Further, with preempt we can improve things cleanly, and I don't think that necessarily implies priority inversion problems.
Robert Love
Quoted 15 lines · On Sun, Jan 13, 2002 at 10:51:04AM -0700, [email protected] wrote:
Quoted 5 lines · On Sun, Jan 13, 2002 at 04:18:23PM +0100, [email protected] wrote:
Quoted 4 lines · On Sat, Jan 12, 2002 at 09:52:09AM -0700, [email protected] wrote:
Quoted 2 lines · On Sat, Jan 12, 2002 at 04:07:14PM +0100, [email protected] wrote:
I did my usual compile testings (untar kernel archive, apply patches, make -j<value> ...
Quoted 8 lines
Quoted 4 lines
If I understand your test,
you are testing different loads - you are compiling kernels that may differ in size and makefile organization, not to mention different layout on the file system and disk.No, I use a script which is run in single user mode after a reboot. So there are only a few processes running when I start the script (see attachment) and the jobs should start from the same environment.
Quoted 8 lines
But your description makes it sound like you do
untar kernel X
apply patches Y
make -j TreeI'm sorry if I'm getting you wrong, but each of these steps is variable.
Even if X and Y are the same each time, "Tree" is different.
X and Y are the same. But I don't really get why this is still "different" ... If you think this could be because of the fs fragmentation then I will enhance my test. I think I have a spare partition somewhere which I can format each time before untar the kernel sources and so on. But why can I reproduce the results then? Ok, not exactly but the results do get close ...
Furthermore I am timing not only the make -j<value> but also the complete untar and applying of patches. So basically I am timing the following:
tar xvf linux-x.y.z.tar
patch -p0 < some_patches
cd linux; cp ../config-x.y.z .config
make oldconfig dep
make -j $PAR bzImage modules
and afterwards
cd .. ; rm -rf linux
and start again. Its just the same as doing 'rpm --rebuild' with
MAKE=make -j $PAR
Quoted 7 lines
The test should be
reboot
N times
make clean
time make -j TreeAm I misunderstaning your test?
No, but I don't understand why this should make any difference. I do not propose my way of testing as *the* benchmark. Its just a benchmark of something which I do most of the time on my system (compiling) in an extreme way ...
Kind regards,
Jogi
Signature · 3 lines
Well, yeah ... I suppose there's no point in getting greedy, is there?
<< Calvin & Hobbes >>Quoted 9 lines · Roman Zippel
What somehow got lost in this discussion, that both patches don't necessarily conflict with each other, they both attack the same problem with different approaches, which complement each other. I prefer to get the best of both patches.
The ll patch identifies problem, which preempt alone can't fix, on the other hand the ll patch inserts schedule calls all over the place, where preempt can handle this transparently. So far I haven't seen any evidence, that preempt introduces any _new_ serious problems, so I'd rather like to see to get the best out of both.
Good point. In fact, I have an "ll patch" for preempt-kernel, it is called lock-break and available at
ftp://ftp.kernel.org/pub/linux/kernel/people/rml/lock-break
While I am not so sure this sort of explicit work is the answer -- I'd much prefer to work on the algorithms to shorten lock time or lock into different locks -- it does work. The work is based heavily on Andrew's ll patch but designed for use with preempt-kernel. This means we can drop some of the conditional schedules that aren't needed, and in others we don't need to call schedule (just drop the locks).
Robert Love
Quoted 7 lines · On Sun, 2002-01-13 at 12:42, [email protected] wrote:
13-pre5aa1 18-pre2aa2 18-pre3 18-pre3s 18-pre3sp 18-pre3minill j100: 6:59.79 78% 7:07.62 76% * 6:39.55 81% 6:24.79 83% * j100: 7:03.39 77% 8:10.04 66% * 8:07.13 66% 6:21.23 83% * j100: 6:40.40 81% 7:43.15 70% * 6:37.46 81% 6:03.68 87% * j100: 7:45.12 70% 7:11.59 75% * 7:14.46 74% 6:06.98 87% * j100: 6:56.71 79% 7:36.12 71% * 6:26.59 83% 6:11.30 86% *
Quoted 5 lines
j75: 6:22.33 85% 6:42.50 81% 6:48.83 80% 6:01.61 89% 5:42.66 93% 7:07.56 77% j75: 6:41.47 81% 7:19.79 74% 6:49.43 79% 5:59.82 89% 6:00.83 88% 7:17.15 74% j75: 6:10.32 88% 6:44.98 80% 7:01.01 77% 6:02.99 88% 5:48.00 91% 6:47.48 80% j75: 6:28.55 84% 6:44.21 80% 9:33.78 57% 6:19.83 85% 5:49.07 91% 6:34.02 83% j75: 6:17.15 86% 6:46.58 80% 7:24.52 73% 6:23.50 84% 5:58.06 88% 7:01.39 77%
Again, preempt seems to reign supreme. Where is all the information correlating preempt is inferior? To be fair, however, we should bench a mini-ll+s test.
But I stand by my original point that none of this matters all too much. A preemptive kernel will allow for future latency reduction _without_ using explicit scheduling points everywhere there is a problem. This means we can tackle the problem and not provide a million bandaids.
Robert Love
Quoted 5 lines · Alan Cox
Quoted 2 lines
I disable a single specific interrupt, I don't disable the timer interrupt. Your code doesn't seem to handle that.
It can if we increment the
preempt_countindisable_irq_nosyncand decrement it onenable_irq.
OK, Alan, you spooked me with the disable_irq mess and admittedly my initial solution wasn't ideal for a few reasons.
But it isn't a problem after all. In hw_irq.h we bump the count in the interrupt path. This should handle any handler, however we end up in it.
I realized it because if we did not have a global solution to interrupt request handlers, dropping spinlocks in the handler, even with IRQs disabled, would cause a preemptive schedule. All interrupts are properly protected.
Robert Love
Quoted 17 lines · Russell King
Quoted 2 lines · Robert Love
It can if we increment the
preempt_countindisable_irq_nosyncand decrement it onenable_irq.Who says you're going to be enabling IRQs any time soon? AFAIK, there is nothing that requires
enable_irqto be called afterdisable_irq_nosync.In fact, you could well have the following in a driver:
/* initial shutdown of device */ disable_irq_nosync(i); /* or disable_irq(i); */ /* other shutdown stuff */ free_irq(i, private);
Quoted 2 lines
and you would have to audit all drivers to find out if they did this - this would seriously damage your
preempt_count.
I wasn't thinking. Anytime we are in an interrupt handler, preemption is disabled. Regardless of how (or even if) interrupts are disabled. We bump preempt_count on the entry path. So, no problem.
Robert Love
Quoted 16 lines · Robert Love
Quoted 15 lines · Russell King
Quoted 2 lines · Robert Love
It can if we increment the
preempt_countindisable_irq_nosyncand decrement it onenable_irq.Who says you're going to be enabling IRQs any time soon? AFAIK, there is nothing that requires
enable_irqto be called afterdisable_irq_nosync.In fact, you could well have the following in a driver:
/* initial shutdown of device */ disable_irq_nosync(i); /* or disable_irq(i); */ /* other shutdown stuff */
Quoted 8 lines
Quoted 4 lines
free_irq(i, private);and you would have to audit all drivers to find out if they did this - this would seriously damage your
preempt_count.I wasn't thinking. Anytime we are in an interrupt handler, preemption is disabled. Regardless of how (or even if) interrupts are disabled. We bump
preempt_counton the entry path. So, no problem.
Err. This isn't *inside* an interrupt handler. This could well be in the driver shutdown code (eg, when fops->release is called).
Signature · 2 lines
Russell King ([email protected]) The developer of ARM Linux http://www.arm.linux.org.uk/personal/aboutme.html
Quoted 3 lines
I wasn't thinking. Anytime we are in an interrupt handler, preemption is disabled. Regardless of how (or even if) interrupts are disabled. We bump
preempt_counton the entry path. So, no problem.
The code path isnt in an interrupt handler.
Quoted 3 lines
Again, preempt seems to reign supreme. Where is all the information correlating preempt is inferior? To be fair, however, we should bench a mini-ll+s test.
How about some actual latency numbers ?
The problem here is that when people report that the low latency patch works better for them than the preempt patch, they aren't talking about bebnchmarking the time to compile a kernel, they are talking about interactive feel and smoothness.
You're speaking to a peripheral issue.
I've no agenda other than wanting to see linux as an attractive option for the multimedia and gaming crowds - and in my experience, the low latency patches simply give a much smoother feel and a more pleasant experience. Kernel compilation time is the farthest thing from my mind when e.g. playing Q3A!
I'd be happy to check out the preempt patch again and see if anything's changed, if the problem of tux+preempt oopsing has been dealt with -
Regards,
jjs
Quoted 34 lines · Robert Love
Quoted 7 lines · On Sun, 2002-01-13 at 12:42, [email protected] wrote:
13-pre5aa1 18-pre2aa2 18-pre3 18-pre3s 18-pre3sp 18-pre3minill j100: 6:59.79 78% 7:07.62 76% * 6:39.55 81% 6:24.79 83% * j100: 7:03.39 77% 8:10.04 66% * 8:07.13 66% 6:21.23 83% * j100: 6:40.40 81% 7:43.15 70% * 6:37.46 81% 6:03.68 87% * j100: 7:45.12 70% 7:11.59 75% * 7:14.46 74% 6:06.98 87% * j100: 6:56.71 79% 7:36.12 71% * 6:26.59 83% 6:11.30 86% *Quoted 6 lines
j75: 6:22.33 85% 6:42.50 81% 6:48.83 80% 6:01.61 89% 5:42.66 93% 7:07.56 77% j75: 6:41.47 81% 7:19.79 74% 6:49.43 79% 5:59.82 89% 6:00.83 88% 7:17.15 74% j75: 6:10.32 88% 6:44.98 80% 7:01.01 77% 6:02.99 88% 5:48.00 91% 6:47.48 80% j75: 6:28.55 84% 6:44.21 80% 9:33.78 57% 6:19.83 85% 5:49.07 91% 6:34.02 83% j75: 6:17.15 86% 6:46.58 80% 7:24.52 73% 6:23.50 84% 5:58.06 88% 7:01.39 77%Again, preempt seems to reign supreme. Where is all the information correlating preempt is inferior? To be fair, however, we should bench a mini-ll+s test.
But I stand by my original point that none of this matters all too much. A preemptive kernel will allow for future latency reduction _without_ using explicit scheduling points everywhere there is a problem. This means we can tackle the problem and not provide a million bandaids.
Robert Love
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Quoted 4 lines · Robert Love
Again, preempt seems to reign supreme. Where is all the information correlating preempt is inferior? To be fair, however, we should bench a mini-ll+s test.
I can't say that I have ever seen any significant change in throughput of anything with any of this stuff.
Benchmarks are well and good, but until we have a solid explanation for the throughput changes which people are seeing, it's risky to claim that there is a general benefit.
-
Quoted 2 lines · Andrew Morton
I can't say that I have ever seen any significant change in throughput of anything with any of this stuff.
I can send you some numbers. It is typically 5-10% throughput increase under load. Obviously this work won't help a single task on a single user system. But things like (ack!) dbench 16 show a marked improvement.
Quoted 3 lines
Benchmarks are well and good, but until we have a solid explanation for the throughput changes which people are seeing, it's risky to claim that there is a general benefit.
I have an explanation. We can schedule quicker off a woken task. When an event occurs that allows an I/O-blocked task to run, its time-to-run is shorter. Same event/response improvement that helps interactivity.
Robert Love
Quoted 15 lines · Robert Love
Quoted 7 lines · On Sun, 2002-01-13 at 12:42, [email protected] wrote:
13-pre5aa1 18-pre2aa2 18-pre3 18-pre3s 18-pre3sp 18-pre3minill j100: 6:59.79 78% 7:07.62 76% * 6:39.55 81% 6:24.79 83% * j100: 7:03.39 77% 8:10.04 66% * 8:07.13 66% 6:21.23 83% * j100: 6:40.40 81% 7:43.15 70% * 6:37.46 81% 6:03.68 87% * j100: 7:45.12 70% 7:11.59 75% * 7:14.46 74% 6:06.98 87% * j100: 6:56.71 79% 7:36.12 71% * 6:26.59 83% 6:11.30 86% *Quoted 5 lines
j75: 6:22.33 85% 6:42.50 81% 6:48.83 80% 6:01.61 89% 5:42.66 93% 7:07.56 77% j75: 6:41.47 81% 7:19.79 74% 6:49.43 79% 5:59.82 89% 6:00.83 88% 7:17.15 74% j75: 6:10.32 88% 6:44.98 80% 7:01.01 77% 6:02.99 88% 5:48.00 91% 6:47.48 80% j75: 6:28.55 84% 6:44.21 80% 9:33.78 57% 6:19.83 85% 5:49.07 91% 6:34.02 83% j75: 6:17.15 86% 6:46.58 80% 7:24.52 73% 6:23.50 84% 5:58.06 88% 7:01.39 77%
Quoted 3 lines
Again, preempt seems to reign supreme. Where is all the information correlating preempt is inferior? To be fair, however, we should bench a mini-ll+s test.
Your wish is granted. Here are the results for mini-ll + scheduler:
j100: 8:26.54 j100: 7:50.35 j100: 6:49.59 j100: 6:39.30 j100: 6:39.70 j75: 6:01.02 j75: 6:12.16 j75: 6:04.60 j75: 6:24.58 j75: 6:28.00
Jogi
Signature · 3 lines
Well, yeah ... I suppose there's no point in getting greedy, is there?
<< Calvin & Hobbes >>Hi,
Quoted 7 lines · Alan Cox
Quoted 4 lines
What somehow got lost in this discussion, that both patches don't necessarily conflict with each other, they both attack the same problem with different approaches, which complement each other. I prefer to get the best of both patches.
When you look at the benchmark there is no difference between ll and ll+pre-empt. ll alone takes you to the 1ms point.
I don't doubt that, but would you seriously consider the ll patch for inclusion into the main kernel?
It's a useful patch for anyone, who needs good latencies now, but it's still a quick&dirty solution. Preempt offers a clean solution for a certain part of the problem, as it's possible to cleanly localize the needed changes for preemption (at least for UP). That means the ll patch becomes smaller and future work on ll becomes simpler, since a certain type of latency problems is handled automatically (and transparently), so you do gain something by it.
The remaining places pointed out in the ll patch are worth a closer look as well, as mostly now we hold a spinlock for too long. These should be fixed as well, as they mean possible contention problems on SMP.
Quoted 3 lines
pre-empt takes you no
further and to get much out of pre-emption requires you go and do all the hideously slow and complex priority inversion stuff.
The possibility of priority inversion problems are not new, it was already discussed before. It was considered not a serious problem, since all processes will still make progress. Preempt now increases the likeliness such a situation occurs, but nonetheless the processes will still make progress. In the past I can't remember any report that indicated a problem caused by priority inversion and so I simply can't believe it should become a massive problem now with preempt.
Quoted 7 lines
Quoted 3 lines
exactly that reason. I don't think we need to work around broken hardware, but halfway decent hardware should not be a problem to get decent latency.
We have to work around common hardware not designed for SMP - the 8390 isnt a broken chip in that sense, its just from a different era, and there are a lot of them.
Please let me rephrase, I just don't expect terrible good latency numbers with non dma hardware.
bye, Roman
Quoted 10 lines · Robert Love
...
Quoted 3 lines
Benchmarks are well and good, but until we have a solid explanation for the throughput changes which people are seeing, it's risky to claim that there is a general benefit.
I have an explanation. We can schedule quicker off a woken task. When an event occurs that allows an I/O-blocked task to run, its time-to-run is shorter. Same event/response improvement that helps interactivity.
Sounds more like handwaving that an explanation :)
The way to speed up dbench is to allow the processes which want to delete files to actually do that. This reduces the total amount of IO which the test performs. Another way is to increase usable memory (or at least to delay the onset of balance_dirty going synchronous). Possibly it's something to do with letting kswapd schedule earlier. Or bdflush.
In the swapstorm case, it's again not clear to me. Perhaps it's due to prompter kswapd activity, perhaps due somehow to improved request merging.
As I say, without a precise and detailed understanding of the mechanisms I wouldn't be prepared to claim more than "speeds up dbench and swapstorms for some reason".
(I'd _like_ to know the complete reason - that way we can stare at it and maybe make things even better. Doing a binary search through the various chunks of the mini-ll patch would be instructive).
-
Quoted 2 lines
I don't doubt that, but would you seriously consider the ll patch for inclusion into the main kernel?
The mini ll patch definitely. The full ll one needs some head scratching to be sure its correct. pre-empt is a 2.5 thing which in some ways is easier because it doesnt matter if it breaks something.
Quoted 2 lines
Please let me rephrase, I just don't expect terrible good latency numbers with non dma hardware.
Expect the same with DMA hardware too at times.
Quoted 7 lines · Alan Cox
Quoted 6 lines
Quoted 2 lines
I didn't see anywhere you check
disable_irq(). Even if you did it doesnt help when I mask the irq on the chip rather than usingdisable_irq()calls.Well, if IRQs are disabled we won't have the timer... would not the system panic anyhow if
schedule()was called while in an interrupt handler?
Quoted 8 lines
You completely misunderstand.
disable_irq(n)I disable a single specific interrupt, I don't disable the timer interrupt. Your code doesn't seem to handle that. Its just one of the examples of where you really need priority handling, and thats a horrible dark and slippery slope
He just needs to disable preemption there, it's just a slight mod to disable/enable_irq. You probably have a few more of those, though...
--
Daniel
Quoted 8 lines · Alan Cox
Another example is in the network drivers. The 8390 core for one example carefully disables an IRQ on the card so that it can avoid spinlocking on uniprocessor boxes.
So with pre-empt this happens
driver magic disable_irq(dev->irq)
inc task's preempt inhibit
Quoted 5 lines
PRE-EMPT:
[large periods of time running other code]
PRE-EMPT:
We get back and we've missed 300 packets, the serial port sharing the IRQ has dropped our internet connection completely.
We are ok
dec tasks's preempt inhibit
jmp if nonzero
--
Daniel
Quoted 30 lines · Mark Hahn
Quoted 19 lines
Quoted 13 lines
Quoted 7 lines
13-pre5aa1 18-pre2aa2 18-pre3 18-pre3s 18-pre3sp 18-pre3minill j100: 6:59.79 78% 7:07.62 76% * 6:39.55 81% 6:24.79 83% * j100: 7:03.39 77% 8:10.04 66% * 8:07.13 66% 6:21.23 83% * j100: 6:40.40 81% 7:43.15 70% * 6:37.46 81% 6:03.68 87% * j100: 7:45.12 70% 7:11.59 75% * 7:14.46 74% 6:06.98 87% * j100: 6:56.71 79% 7:36.12 71% * 6:26.59 83% 6:11.30 86% *Quoted 5 lines
j75: 6:22.33 85% 6:42.50 81% 6:48.83 80% 6:01.61 89% 5:42.66 93% 7:07.56 77% j75: 6:41.47 81% 7:19.79 74% 6:49.43 79% 5:59.82 89% 6:00.83 88% 7:17.15 74% j75: 6:10.32 88% 6:44.98 80% 7:01.01 77% 6:02.99 88% 5:48.00 91% 6:47.48 80% j75: 6:28.55 84% 6:44.21 80% 9:33.78 57% 6:19.83 85% 5:49.07 91% 6:34.02 83% j75: 6:17.15 86% 6:46.58 80% 7:24.52 73% 6:23.50 84% 5:58.06 88% 7:01.39 77%Quoted 3 lines
Again, preempt seems to reign supreme. Where is all the information correlating preempt is inferior? To be fair, however, we should bench a mini-ll+s test.
Your wish is granted. Here are the results for mini-ll + scheduler:
Quoted 10 lines
j100: 8:26.54 j100: 7:50.35 j100: 6:49.59 j100: 6:39.30 j100: 6:39.70 j75: 6:01.02 j75: 6:12.16 j75: 6:04.60 j75: 6:24.58 j75: 6:28.00
Quoted 1 line
how about a real benchmark like -j2 or so (is this a dual machine?)
Why does everybody think this is no *real* benchmark? When I remember the good old days at the university the systems I tried to compile some applications on were *always* overloaded. Would it make a difference for you if I would run
for a in lots_of.srpm; do
rpm --rebuild $a &
done
Basically this gives the same result: lots of compile jobs running in parallel. All *I* am doing is doing it a little extreme since running the compile with make -j2 does not make a *noticable* difference at all. And as I said previously my idea was to get the system into high memory pressure and test the different vms (AA and RvR) ...
Furthermore some people think this combination (sched+preempt) is only good for latency (if at all) all I can say is that this works *very* well for me latency wise. Since I don't know how to measure latency exactly I tried to run my compile script (make -j50) while running my usual desktop + xmms. Result: xmms was *not* skipping, although the system was ~70MB into swap and the load was >50. Changing workspaces worked immedeatly all the time. But I was able to get xmms to skip for a short while by starting galeon, StarOffice, gimp with ~10 pictures all at the same time. But when all applications came up xmms was not skipping any more and the system was ~130MB into swap. This is the best result for me so far but I have to admit that I did not test mini-ll +sched in this area (I can test this earliest on wednesday, sorry).
Since it is a little while since I posted my system specs here they are:
- Athlon 1.2GHz (single proc)
- 256 MB
- IDE drive (quantum)
Quoted 2 lines
also, I've often found the user/sys/elapsed components to all be interesting; how do they look? (I'd expect preempt to have more sys, for instance.)
13-pre5aa1 18-pre2aa2 18-pre3 18-pre3s 18-pre3sp 18-pre3smini
(sys) (user)
j100: 30.78 297.07 32.40 294.38 * 27.74 296.02 27.55 292.95 28.30 297.67
j100: 30.92 297.11 33.04 295.15 * 29.14 296.25 26.88 292.77 28.13 296.44
j100: 29.58 297.90 34.01 294.16 * 27.56 295.76 26.25 293.79 27.96 296.47
j100: 30.62 297.13 32.00 294.30 * 28.47 296.46 27.64 293.42 27.50 297.47
j100: 30.48 299.43 32.28 295.42 * 27.77 296.44 27.53 292.10 27.23 297.24As expected the system and the user times are almost identical. The "fastest" compile results are always where the job gets the most %cpu time. So I guess it would be more interesting to see how much cpu time e.g. kswapd gets.
Probably I have to enhance my script to run vmstat in the background ... Would this provide useful data?
Regards,
Jogi
Signature · 3 lines
Well, yeah ... I suppose there's no point in getting greedy, is there?
<< Calvin & Hobbes >>Quoted 7 lines · Alan Cox
[somebody wrote]
Quoted 3 lines
For a solution to latency concerns, I'd much prefer to lay a framework down that provides a proper solution and then work on fine tuning the kernel to get the desired latency out of it.
As the low latency patch proves, the framework has always been there, the ll patches do the rest
For that matter, the -preempt patch proves that the framework has always - i.e., since genesis of SMP - been there for a preemptible kernel.
--
Daniel
Quoted 3 lines · Daniel Phillips
I'd like to add my 'me too' to those who have requested a re-run of this test, building the *identical* kernel tree every time, starting from the same initial conditions. Maybe that's what you did, but it's not clear from your post.
He later said he did in fact build the same tree, from the same initial condition, in single user mode, etc etc ... sounded like good testing methodology to me.
I later asked for a test of Ingo's sched with ll (to compare to Ingo's sched with preempt). In this test, like the others, preempt gives the best times.
Robert Love
Well to start with:
1) Maybe I should be more precise: The latency measures I've seen posted all favor Morton and not preempt. Since the claimed purpose of both patches is improving latency isn't that more interesting than measuremts of kernel compile?
2) In these measurements
the tree is different each time so the measurement doesn't seem very stable. It's not exactly a secret that file layout can have an affect on performance.
3) There is no measure of preempt without Ingo's scheduler
4) this is what I want to see:
Run the periodic SCHED_FIFO task I've posted multiple times Let's see worst case error
Let's see effect on the background kernel compile
All the rest is just so much talk about "interactive feel". I saw exactly the same claims from the people who wanted kernel graphics.
Quoted 26 lines · Robert Love
Quoted 7 lines · On Sun, 2002-01-13 at 12:42, [email protected] wrote:
13-pre5aa1 18-pre2aa2 18-pre3 18-pre3s 18-pre3sp 18-pre3minill j100: 6:59.79 78% 7:07.62 76% * 6:39.55 81% 6:24.79 83% * j100: 7:03.39 77% 8:10.04 66% * 8:07.13 66% 6:21.23 83% * j100: 6:40.40 81% 7:43.15 70% * 6:37.46 81% 6:03.68 87% * j100: 7:45.12 70% 7:11.59 75% * 7:14.46 74% 6:06.98 87% * j100: 6:56.71 79% 7:36.12 71% * 6:26.59 83% 6:11.30 86% *Quoted 5 lines
j75: 6:22.33 85% 6:42.50 81% 6:48.83 80% 6:01.61 89% 5:42.66 93% 7:07.56 77% j75: 6:41.47 81% 7:19.79 74% 6:49.43 79% 5:59.82 89% 6:00.83 88% 7:17.15 74% j75: 6:10.32 88% 6:44.98 80% 7:01.01 77% 6:02.99 88% 5:48.00 91% 6:47.48 80% j75: 6:28.55 84% 6:44.21 80% 9:33.78 57% 6:19.83 85% 5:49.07 91% 6:34.02 83% j75: 6:17.15 86% 6:46.58 80% 7:24.52 73% 6:23.50 84% 5:58.06 88% 7:01.39 77%Again, preempt seems to reign supreme. Where is all the information correlating preempt is inferior? To be fair, however, we should bench a mini-ll+s test.
But I stand by my original point that none of this matters all too much. A preemptive kernel will allow for future latency reduction _without_ using explicit scheduling points everywhere there is a problem. This means we can tackle the problem and not provide a million bandaids.
Robert Love
Signature · 4 lines
--------------------------------------------------------- Victor Yodaiken Finite State Machine Labs: The RTLinux Company. www.fsmlabs.com www.rtlinux.com
Quoted 7 lines · Roman Zippel
I don't doubt that, but would you seriously consider the ll patch for inclusion into the main kernel?
It's a useful patch for anyone, who needs good latencies now, but it's still a quick&dirty solution. Preempt offers a clean solution for a certain part of the problem, as it's possible to cleanly localize the needed changes for preemption (at least for UP). That means the ll patch becomes smaller and future work on ll becomes simpler, since a certain
That is exactly what Andrew Morton disputes. So why do you think he is wrong?
Quoted 9 lines · Robert Love
Quoted 3 lines · Daniel Phillips
I'd like to add my 'me too' to those who have requested a re-run of this test, building the *identical* kernel tree every time, starting from the same initial conditions. Maybe that's what you did, but it's not clear from your post.
He later said he did in fact build the same tree, from the same initial condition, in single user mode, etc etc ... sounded like good testing methodology to me.
Really? You think that
unpack a tar archive
make
is a repeatable benchmark?
Quoted 1 line
Quoted 1 line
I don't doubt that, but would you seriously consider the ll patch
for
Quoted 3 lines
Quoted 1 line
inclusion into the main kernel?
The mini ll patch definitely.
Huh?
Can you point at anyone who experienced a significant benefit from it? I can see a lot of interesting patches ahead if you let this go. Tell me honestly that the idea behind this patch is not _crap_. You can only make this basic idea work if you patch a tremendous lot of those conditional_schedules() through the kernel. We already saw it starting off in some graphics drivers, network drivers. Why not just all of it? You will not be far away in the end from the 'round 4000 I already stated in earlier post.
I do believe Roberts' preempt is a lot cleaner in its idea _how_ to achieve basically the same goal. Although I am at least as sceptic as you about a race-free implementation.
Quoted 2 lines
The full ll one needs some head scratching to
be sure its correct.
You may simply call it _counting_ (the files to patch).
Quoted 2 lines
pre-empt is a 2.5 thing which in some ways is easier because it doesnt matter if it breaks something.
So I understand you agree somehow with me in the answer to "what idea is really better?"...
Regards,
Stephan
Quoted 6 lines
Tell me honestly that the idea behind this patch is not _crap_. You can only make this basic idea work if you patch a tremendous lot of those
conditional_schedules()through the kernel. We already saw it starting off in some graphics drivers, network drivers. Why not just all of it? You will not be far away in the end from the 'round 4000 I already stated in earlier post.
There are very few places you need to touch to get a massive benefit. Most of the kernel already behaves extremely well.
Quoted 2 lines
So I understand you agree somehow with me in the answer to "what idea is really better?"...
Do you want a clean simple solution or complex elegance ? For 2.4 I definitely favour clean and simple. For 2.5 its an open debate
Hi,
Quoted 8 lines · [email protected] wrote:
Quoted 5 lines
It's a useful patch for anyone, who needs good latencies now, but it's still a quick&dirty solution. Preempt offers a clean solution for a certain part of the problem, as it's possible to cleanly localize the needed changes for preemption (at least for UP). That means the ll patch becomes smaller and future work on ll becomes simpler, since a certain
That is exactly what Andrew Morton disputes. So why do you think he is wrong?
Please explain, what do you mean?
bye, Roman
Quoted 9 lines · Andrea Arcangeli
I'm not against preemption (I can see the benefits about the mean latency for real time DSP) but the claims about preemption making the kernel faster doesn't make sense to me. more frequent scheduling, overhead of branches in the locks (you've to
conditional_scheduleafter the last preemption lock is released and the cachelines for the per-cpu preemption locks) and the other preemption stuff can only make the kernel slower. Furthmore for multimedia playback any sane kernel out there with lowlatency fixes applied will work as well as a preemption kernel that pays for all the preemption overhead.
I'm not sure I have seen claims that it makes the kernel faster, but it sure makes the latency lower, and improves performance for systems doing a lot of network activity (DNS servers) with anything else going on in the systems, such as daily reports and backups.
I will try the low latency kernel stuff, but I think intrinsically that if you want to service the incoming requests quickly you have to dispatch to them quickly, not at the end of a time slice. Preempt is a way to avoid having to play with RT processes, and I think it's desirable in general as an option where the load will benefit from such behaviour.
I'm not sure it "competes" with low latency, since many of the thing LL is doing are "good things" in general.
Finally, I doubt that any of this will address my biggest problem with Linux, which is that as memory gets cheap a program doing significant disk writing can get buffers VERY full (perhaps a while CD worth) before the kernel decides to do the write, at which point the system becomes non-responsive for seconds at a time while the disk light comes on and stays on. That's another problem, and I did play with some patches this weekend without making myself really happy :-( Another topic, unfortunately.
Signature · 3 lines
bill davidsen <[email protected]> CTO, TMR Associates, Inc Doing interesting things with little computers since 1979.
Quoted 8 lines · Daniel Phillips
Quoted 5 lines · Andrew Morton
There's no point in just merging the preempt patch and saying "there, that's done". It doesn't do anything.
Instead, a decision needs to be made: "Linux will henceforth be a low-latency kernel".
I thought the intention was to make it a config option?
Irrelevant, it has to be implemented in order to be an option, so the amount of work involved is the same either way. And if you want to make it a runtime setting you add a slight bit of work and overhead deciding if LL is wanted.
I'm not advocating that, but it would allow admins to enable LL when the system was slow and see if it really made a change. Rebooting is bound to change the load ;-)
Quoted 9 lines
Quoted 9 lines
Now, IF we can come to this decision, then
internal preemption is the way to do it. But it affects ALL kernel developers. Because we'll need to introduce a new rule: "it is a bug to spend more than five milliseconds holding any locks".So. Do we we want a low-latency kernel? Are we prepared to mandate
the five-millisecond rule? It can be done, but won't be easy, and
we'll never get complete coverage. But I don't see the will around here.
Really? You have people working on low latency, people working on preempt, and at least a few of us trying to characterize the problems with large memory and i/o. I would say latency has become a real issue, and you only need enough "will" to have one person write useful code, this is a committee.
Since changes of this type don't need to be perfect and address all cases, just help some and not make other worse, I think we will see improvement in 2.4.xx without waiting for 2.5 or 2.6. No one is complaining that the Linux overall thruput is bad, that network performance is bad, etc. But responsiveness has become an issue, and I'm sure there's enough will to solve it. "Solve" means getting most of the delays to be caused by hardware capacity instead of kernel ineptitude.
Signature · 3 lines
bill davidsen <[email protected]> CTO, TMR Associates, Inc Doing interesting things with little computers since 1979.
Quoted 10 lines · Roman Zippel
Hi,
Quoted 6 lines · [email protected] wrote:
Quoted 5 lines
It's a useful patch for anyone, who needs good latencies now, but it's still a quick&dirty solution. Preempt offers a clean solution for a certain part of the problem, as it's possible to cleanly localize the needed changes for preemption (at least for UP). That means the ll patch becomes smaller and future work on ll becomes simpler, since a certain
Quoted 4 lines
Quoted 2 lines
That is exactly what Andrew Morton disputes. So why do you think he is wrong?
Please explain, what do you mean?
I mean, that these conversations are not very useful if you don't read what the other people write.
Here's a prior response by Andrew to a post by you.
Quoted 1 line
From [email protected] Sat Jan 12 13:15:22 2002
Quoted 6 lines · Roman Zippel
Andrew's patch requires constant audition and Andrew can't audit all drivers for possible problems. That doesn't mean Andrew's work is wasted, since it identifies problems, which preempting can't solve, but it will always be a hunt for the worst cases, where preempting goes for the general case.
Guys,
I've heard this so many times, and it just ain't so. The overwhelming
majority of problem areas are inside locks. All the complexity and maintainability difficulties to which you refer exist in the preempt
patch as well. There just is no difference.
Quoted 2 lines
bye, Roman
Signature · 4 lines
--------------------------------------------------------- Victor Yodaiken Finite State Machine Labs: The RTLinux Company. www.fsmlabs.com www.rtlinux.com
Quoted 2 lines · Alan Cox
Do you want a clean simple solution or complex elegance ? For 2.4 I definitely favour clean and simple. For 2.5 its an open debate
Make no mistake, I do not intend to see preempt-kernel in 2.4. I will, however, continue to maintain the patch for endusers and such that use it. A proper in-kernel solution for 2.4 in my opinion in mini-ll, perhaps extend with any other obviously-completely-utterly sane bits from full-ll.
For 2.5, however, I tout preempt as the answer. This does not mean just preempt. It means a preemptible kernel as a basis for beginning low-latency works in manners other than explicit scheduling statements.
Robert Love
Quoted 2 lines · Roman Zippel
Quoted 2 lines
That is exactly what Andrew Morton disputes. So why do you think he is wrong?
Victor is saying that Andrew contends the hard parts of his low-latency patch are just as hard to maintain with a preemptive kernel. This is true, for the places where spinlocks are held anyway, but it assumes we continue to treat lock breaking and explicit scheduling as our only solution. It isn't under a preemptible kernel.
Robert Love
Quoted 10 lines · Robert Love
Quoted 7 lines · Daniel Phillips
And while I'm enumerating differences, the preemptable kernel (in this incarnation) has a slight per-spinlock cost, while the non-preemptable kernel has the fixed cost of checking for rescheduling, at intervals throughout all 'interesting' kernel code, essentially all long-running loops. But by clever coding it's possible to finesse away almost all the overhead of those loop checks, so in the end, the non-preemptible low-latency patch has a slight efficiency advantage here, with emphasis on 'slight'.
Quoted 5 lines
True (re spinlock weight in preemptible kernel) but how is that not comparable to explicit scheduling points? Worse, the preempt-kernel typically does its preemption on a branch on return to interrupt (similar to user space's preemption). What better time to check and reschedule if needed?
I'm not sure that preempt and low latency really are attacking the same problem. What I am finding is the LL improves overall performance when a process does something which is physically slow, like a find in a directory with 20k files. On the other hand PK makes the response of the system better to changes. In particular I see the DNS servers which have other work running, even backups or reports, are more responsive with PK, as are usenet news servers. I find it hard to measure "feels faster" with either approach, although like the supreme court "I know it when I see it."
I'd like to hope that some of each will get in the main kernel, PK has been stable for me for a while, LL has never been unstable but I've run it less.
Signature · 3 lines
bill davidsen <[email protected]> CTO, TMR Associates, Inc Doing interesting things with little computers since 1979.
Quoted 8 lines · Kent Borg
How does all this fit into doing a tick-less kernel?
There is something appealing about doing stuff only when there is stuff to do, like: respond to input, handle some device that becomes ready, or let another process run for a while. Didn't IBM do some nice work on this for Linux? (*Was* it nice work?) I was under the impression that the current kernel isn't that far from being tickless.
Quoted 6 lines
A tickless kernel would be wonderful for battery powered devices that could literally shut off when there be nothing to do, and it seems it would (trivially?) help performance on high end power hogs too.
Why do we have regular HZ ticks? (Other than I think I remember Linus saying that he likes them.)
Feel free to quantify the savings over the current setup with max power saving enabled in the kernel. I just don't see how "wonderful" it would be, given that an idle system currently uses very little battery if you setup the options to save power.
Signature · 3 lines
bill davidsen <[email protected]> CTO, TMR Associates, Inc Doing interesting things with little computers since 1979.
Quoted 8 lines · Bill Davidsen
Finally, I doubt that any of this will address my biggest problem with Linux, which is that as memory gets cheap a program doing significant disk writing can get buffers VERY full (perhaps a while CD worth) before the kernel decides to do the write, at which point the system becomes non-responsive for seconds at a time while the disk light comes on and stays on. That's another problem, and I did play with some patches this weekend without making myself really happy :-( Another topic, unfortunately.
I think this is a critical problem. I'd like to be able to have some assurance that a task with a buffer of size N doing read-disk->write-disk will maintain data flow at some minimal rate over intervals of 1 or 2 seconds or something like that.
Quoted 4 lines
Feel free to quantify the savings over the current setup with max power saving enabled in the kernel. I just don't see how "wonderful" it would be, given that an idle system currently uses very little battery if you setup the options to save power.
IBM have a tickless kernel patch set for the S/390. Here its not battery at stake but VM overhead sending timer interrupts to hundreds of otherwise idle virtual machines
Quoted 3 lines · Roman Zippel
So far I haven't seen any evidence, that preempt introduces any _new_ serious problems, so I'd rather like to see to get the best out of both.
Are you seriously suggesting you haven't read a single email in this thread yet ?
Rik
Signature · 4 lines
"Linux holds advantages over the single-vendor commercial OS"
-- Microsoft's "Competing with Linux" document
http://www.surriel.com/ http://distro.conectiva.com/Quoted 6 lines · Rik van Riel
Quoted 3 lines
So far I haven't seen any evidence, that preempt introduces any _new_ serious problems, so I'd rather like to see to get the best out of both.
Are you seriously suggesting you haven't read a single email in this thread yet ?
No, I think he is suggesting he doesn't consider any of the problems serious. A lot of it is just smoke. What is "bad" wrt 2.5?
Robert Love
Quoted 9 lines · Bill Davidsen
Finally, I doubt that any of this will address my biggest problem with Linux, which is that as memory gets cheap a program doing significant disk writing can get buffers VERY full (perhaps a while CD worth) before the kernel decides to do the write, at which point the system becomes non-responsive for seconds at a time while the disk light comes on and stays on. That's another problem, and I did play with some patches this weekend without making myself really happy :-( Another topic, unfortunately.
/proc/sys/vm/bdflush: Decreasing the kupdate interval from five seconds, decreasing the nfract and nfract_sync setting in there should smooth this out. The -aa patches add start and stop levels for bdflush as well, which means that bdflush can be the one who blocks on IO rather than your process. And it means that the request queue doesn't get 100% drained as soon as the writer hits nfract_sync.
All very interesting and it will be fun to play with when it *finally* gets merged.
But with the current elevator design, disk read latencies will still be painful.
-
Quoted 29 lines · On January 12, 2002 04:07 pm, [email protected] wrote:
Hello Andrea,
I did my usual compile testings (untar kernel archive, apply patches, make -j<value> ...
Here are some results (Wall time + Percent cpu) for each of the consecutive five runs:
13-pre5aa1 18-pre2aa2 18-pre3 18-pre3s 18-pre3sp j100: 6:59.79 78% 7:07.62 76% * 6:39.55 81% 6:24.79 83% j100: 7:03.39 77% 8:10.04 66% * 8:07.13 66% 6:21.23 83% j100: 6:40.40 81% 7:43.15 70% * 6:37.46 81% 6:03.68 87% j100: 7:45.12 70% 7:11.59 75% * 7:14.46 74% 6:06.98 87% j100: 6:56.71 79% 7:36.12 71% * 6:26.59 83% 6:11.30 86%j75: 6:22.33 85% 6:42.50 81% 6:48.83 80% 6:01.61 89% 5:42.66 93% j75: 6:41.47 81% 7:19.79 74% 6:49.43 79% 5:59.82 89% 6:00.83 88% j75: 6:10.32 88% 6:44.98 80% 7:01.01 77% 6:02.99 88% 5:48.00 91% j75: 6:28.55 84% 6:44.21 80% 9:33.78 57% 6:19.83 85% 5:49.07 91% j75: 6:17.15 86% 6:46.58 80% 7:24.52 73% 6:23.50 84% 5:58.06 88%* build incomplete (OOM killer killed several cc1 ... )
So far 2.4.13-pre5aa1 had been the king of the block in compile times. But this has changed. Now the (by far) fastest kernel is 2.4.18-pre
+ Ingos scheduler patch (s) + preemptive patch (p). I did not test preemptive patch alone so far since I don't know if the one I have applies cleanly against -pre3 without Ingos patch. I used the following patches:
Quoted 4 lines
s: sched-O1-2.4.17-H6.patch
p: preempt-kernel-rml-2.4.18-pre3-ingo-1.patchI hope this info is useful to someone.
I'd like to add my 'me too' to those who have requested a re-run of this test, building the *identical* kernel tree every time, starting from the same initial conditions. Maybe that's what you did, but it's not clear from your post.
Thanks,
Daniel
Quoted 9 lines · Arjan van de Ven
Quoted 4 lines · Roman Zippel
What somehow got lost in this discussion, that both patches don't necessarily conflict with each other, they both attack the same problem with different approaches, which complement each other. I prefer to get the best of both patches.
If you do this (and I've seen the results of doing both at once vs only either of then vs pure) then there's NO benifit for the preemption left.
Sorry, that's incorrect. I stated why earlier in this thread and akpm signed off on it. With preempt you get ASAP (i.e., as soon as the outermost spinlock is done) process scheduling. With hand-coded scheduling points you get 'as soon as it happens to hit a scheduling point'.
That is not the only benefit, just the most obvious one.
--
Daniel
Quoted 9 lines · Daniel Phillips
Quoted 7 lines · Arjan van de Ven
Quoted 4 lines · Roman Zippel
What somehow got lost in this discussion, that both patches don't necessarily conflict with each other, they both attack the same problem with different approaches, which complement each other. I prefer to get the best of both patches.
Quoted 7 lines
Quoted 2 lines
If you do this (and I've seen the results of doing both at once vs only either of then vs pure) then there's NO benifit for the preemption left.
Sorry, that's incorrect. I stated why earlier in this thread and akpm signed off on it. With preempt you get ASAP (i.e., as soon as the outermost spinlock is done) process scheduling. With hand-coded scheduling points you get 'as soon as it happens to hit a scheduling point'.
With preempt it's "as soon as you hit a lock-break point". They're equivalent, for the inside-lock case, which is where most of the problems and complexity lie.
Quoted 1 line
That is not the only benefit, just the most obvious one.
I'd say the most obvious benefit of preempt is that it catches some of the cases which the explicit schedules do not - the stuff which the developer didn't test for, and which is outside locks.
How useful this is, is moot.
But we can *make* it useful. I believe that internal preemption is the foundation to improve 2.5 kernel latency. But first we need consensus that we *want* linux to be a low-latency kernel.
Do we have that?
If we do, then as I've said before, holding a lock for more than N milliseconds becomes a bug to be fixed. We can put tools in the hands of testers to locate those bugs. Easy.
-
Quoted 11 lines · Daniel Phillips
Quoted 9 lines · Arjan van de Ven
Quoted 4 lines · Roman Zippel
What somehow got lost in this discussion, that both patches don't necessarily conflict with each other, they both attack the same problem with different approaches, which complement each other. I prefer to get the best of both patches.
If you do this (and I've seen the results of doing both at once vs only either of then vs pure) then there's NO benifit for the preemption left.
Quoted 6 lines
Sorry, that's incorrect. I stated why earlier in this thread and akpm signed off on it. With preempt you get ASAP (i.e., as soon as the outermost spinlock is done) process scheduling. With hand-coded scheduling points you get 'as soon as it happens to hit a scheduling point'.
That is not the only benefit, just the most obvious one.
My understanding of this situation is as follows:
The pure preempt measurements show some improvement on synthetic latency benchmarks that have not been shown to have any relationship to any real application
The LL measurements show _better_ results on similar benchmarks.
Some people find preempt improves "feel"
Some people find LL improves "feel"
The interactions of these improvements with Ingos scheduler, aa mm, and other recent patches are exceptionally murky
We have one benchmark that shows that kernel compiles run on different untarred trees show a slight advantage for preempt+Ingo via some unknown mechanism. This benchmark, aside from its dubious repeatability tests something that seems to have no relationship to _anything_ at all by running a huge number of compile processes.
Nobody has answered my question about the conflict between SMP per-cpu caching and preempt. Since NUMA is apparently the future of MP in the PC world and the future of Linux servers, it's interesting to consider this tradeoff.
Nobody has answered the question about how to make sure all processes make progress with preempt.
Nobody has offered a single benchmark of actual application code benefits from either preempt or LL.
Nobody has clearly explained how to avoid what I claim to be the inevitable result of preempt -- priority inheritance locks (not just semaphores). What we have is some "we'll figure that out when we get to it".
It's not even clear how preempt is supposed to interact with SCHED_FIFO.
As far as your "most obvious" "benefit". It's neither obvious that it happens or obvious that it is a benefit. According to the measurements I've seen, Andrew reduces latency _more_ than preempt. Andrews argument, as I understand it, is that the longest latencies are within spinlocks anyways so increasing speed of preempt outside those locks misses the problem. If he is correct, then if you are correct, it doesn't matter - preempt is reducing already short latencies.
BTW: there is a detailed explanation of how priority inherit works in Solaris in the UNIX Internals book. It's worth reading and thinking about.
I'm not at all sure that putting preempt into 2.5 is a bad idea. I think that 2.4 has a long lifetime ahead of it and the debacle that will follow putting preempt into 2.5 will eventually discredit the entire idea for at least a year or two.
But
I think that there are some much more important scheduling issues that are being ignored to "improve the feel" of DVD playing. The key one is some idea of being able to assure processes of some rate of progress. This is not classical RT, but it is important to multimedia and databases and also to some applications we are interested in looking at.
---------------------------------------------------------
Victor Yodaiken
Finite State Machine Labs: The RTLinux Company.
www.fsmlabs.com www.rtlinux.com
Quoted 1 line · Alan Cox
Quoted 1 line
Quoted 1 line
I disable a single specific interrupt, I don't disable the timer
interrupt.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Your code doesn't seem to handle that.
It can if we increment the
preempt_countindisable_irq_nosyncand decrement it onenable_irq.A driver that knows about how its irq is handled and that it is sole user (eg ISA) may and some do leave it disabled for hours at a time
Good point. Preemption would be disabled for that thread if we mindlessly shut it off for every irq_disable. For that driver we probably just want to leave preemption enabled, it can't hurt.
--
Daniel
Quoted 10 lines · Daniel Phillips
Quoted 1 line · Alan Cox
Quoted 1 line
Quoted 1 line
I disable a single specific interrupt, I don't disable the timer
interrupt.
Quoted 5 lines
Quoted 4 lines
Quoted 1 line
Your code doesn't seem to handle that.
It can if we increment the
preempt_countindisable_irq_nosyncand decrement it onenable_irq.
Quoted 6 lines
Quoted 2 lines
A driver that knows about how its irq is handled and that it is sole user (eg ISA) may and some do leave it disabled for hours at a time
Good point. Preemption would be disabled for that thread if we mindlessly shut it off for every
irq_disable. For that driver we probably just want to leave preemption enabled, it can't hurt.
Once we return to user space, we can preempt again. If preemption is still disabled upon return from the syscall, I'd say it's okay to switch it back on now. :)
Unless I'm missing something fundamental...?
Rob
Quoted 5 lines · J Sloan
The problem here is that when people report that the low latency patch works better for them than the preempt patch, they aren't talking about bebnchmarking the time to compile a kernel, they are talking about interactive feel and smoothness.
Nobody is claiming the low latency patch works better than -preempt+lock_break, only that low latency can equal -preempt+lock_break, which is a claim I'm skeptical of, but oh well.
Quoted 7 lines
I've no agenda other than wanting to see linux as an attractive option for the multimedia and gaming crowds - and in my experience, the low latency patches simply give a much smoother feel and a more pleasant experience. Kernel compilation time is the farthest thing from my mind when e.g. playing Q3A!
You need to read the thread *way* more closely ;-)
Quoted 4 lines
I'd be happy to check out the preempt patch again and see if anything's changed, if the problem of tux+preempt oopsing has been dealt with -
Right, useful.
--
Daniel
Re: Alans example against preemtive kernel (Was: Re: [2.4.17/18pre] VM and swap - it's really unusable)
In reply to Alan CoxQuoted 14 lines · Alan Cox
Another example is in the network drivers. The 8390 core for one example carefully disables an IRQ on the card so that it can avoid spinlocking on uniprocessor boxes.
So with pre-empt this happens
driver magic disable_irq(dev->irq)PRE-EMPT:
[large periods of time running other code]
PRE-EMPT:
We get back and we've missed 300 packets, the serial port sharing the IRQ has dropped our internet connection completely.
Quoted 4 lines
["Don't do that then" isnt a valid answer here. If I did hold a lock
it would be for several milliseconds at a time anyway and would reliably trash performance this time]
./drivers/net/8390.c
I checked the code ./drivers/net/8390.c - this is how it REALLY looks like...
/* Ugly but a reset can be slow, yet must be protected */ disable_irq_nosync(dev->irq); spin_lock(&ei_local->page_lock); /* Try to restart the card. Perhaps the user has fixed something. */ ei_reset_8390(dev); NS8390_init(dev, 1); spin_unlock(&ei_local->page_lock); enable_irq(dev->irq);
This should be mostly OK for the preemptive kernel. Swapping the irq and spin lock lines should be preferred. But I think that is the case in SMP too...
Suppose two processors does the disable_irq_nosync - unlikely but possible... One gets the spinlock, the other waits
The first runs through the code, exits the spin lock, enables irq The second starts running the code - without irq disabled!!!
This would work in both cases.
/* Ugly but a reset can be slow, yet must be protected */ spin_lock(&ei_local->page_lock); disable_irq_nosync(dev->irq); /* Try to restart the card. Perhaps the user has fixed something. */ ei_reset_8390(dev); NS8390_init(dev, 1); enable_irq(dev->irq); spin_unlock(&ei_local->page_lock);
/RogerL
Signature · 3 lines
Roger Larsson Skellefteå Sweden
Quoted 6 lines · Daniel Phillips
Sorry, that's incorrect. I stated why earlier in this thread and akpm signed off on it. With preempt you get ASAP (i.e., as soon as the outermost spinlock is done) process scheduling. With hand-coded scheduling points you get 'as soon as it happens to hit a scheduling point'.
That is not the only benefit, just the most obvious one.
Big duh. So you get there 1 usec sooner. NOBODY will notice that. NOBODY.
Re: Alans example against preemtive kernel (Was: Re: [2.4.17/18pre] VM and swap - it's really unusable)
In reply to Roger LarssonQuoted 4 lines
This should be mostly OK for the preemptive kernel. Swapping the irq an= d spin=20
lock lines should be preferred. But I think that is the case in SMP too= =2E..
You deadlock if you swap the two lines over. In this case for pre-empt you really have to go in and add non pre-emption places to the driver
Quoted 5 lines · On Mon, 14 Jan 2002 00:50:54 +0000 (GMT) Alan Cox <[email protected]>…
Quoted 2 lines
all of it? You will not be far away in the end from the 'round 4000 I already stated in earlier post.
There are very few places you need to touch to get a massive benefit. Most of the kernel already behaves extremely well.
Just a short question: the last (add-on) patch to mini-ll I saw on the list
patches: drivers/net/3c59x.cdrivers/net/8139too.cdrivers/net/eepro100.c
Unfortunately me have neither of those. This would mean I cannot benefit from _these_ patches, but instead would need _others_ (like tulip or name-one-of-the-rest-of-the-drivers) to see _some_ effect you tell me I _should_ see (I currently see _none_). How do you argue then against the
statement: we need patches for /drivers/net/*.c ?? I do not expect 3c59x.c to be particularly bad in comparison to tulip/*.c or lets say via-rhine.c, do you?
Quoted 4 lines
Quoted 2 lines
So I understand you agree somehow with me in the answer to "what idea is really better?"...
Do you want a clean simple solution or complex elegance ? For 2.4 I
definitely> favour clean and simple. For 2.5 its an open debate
Hm, obviously the ll-patches look simple, but their pure required number makes me think they are as well stupid as simple. This whole story looks like making an old mac do real multitasking, just spread around scheduling points throughout the code ... This is like drilling for water on top of the mountain. I want the water too, but I state there must be a nice valley somewhere around
...
Regards,
Stephan
Quoted 3 lines · On 13 Jan 2002 20:17:11 -0500 Robert Love <[email protected]> wrote:
For 2.5, however, I tout preempt as the answer. This does not mean just preempt. It means a preemptible kernel as a basis for beginning low-latency works in manners other than explicit scheduling statements.
Aha, exactly my thoughts...
Regards,
Stephan
Quoted 4 lines
Just a short question: the last (add-on) patch to mini-ll I saw on the list
patches:drivers/net/3c59x.cdrivers/net/8139too.cdrivers/net/eepro100.c
I've seen multiple quite frankly bizarre patches like that. I've not applied them and don't see the point
Quoted 9 lines · Stephan von Krawczynski
...
Unfortunately me have neither of those. This would mean I cannot benefit from _these_ patches, but instead would need _others_ (like tulip or name-one-of-the-rest-of-the-drivers) to see _some_ effect you tell me I _should_ see (I currently see _none_). How do you argue then against the
statement: we need patches for /drivers/net/*.c ?? I do not expect3c59x.cto be particularly bad in comparison to tulip/*.c or lets sayvia-rhine.c, do you?
In 3c59x.c, probably the biggest problem will be the call to issue_and_wait() in boomerang_start_xmit(). On a LAN which is experiencing heavy collision rates this can take as long as 2,000 PCI cycles (it's quite rare, and possibly an erratum). It is called under at least two spinlocks.
In via-rhine, wait_for_reset() can busywait for up to ten milliseconds. via_rhine_tx_timeout() calls it from under a spinlock.
In eepro100.c, wait_for_cmd_done() can busywait for one millisecond and is called multiple times under spinlock.
Preemption will help _some_ of this, but by no means all, or enough.
-
Hi,
Quoted 2 lines · [email protected] wrote:
I mean, that these conversations are not very useful if you don't read what the other people write.
Oh, I do read everything that's for me, but it happens I'm not answering everything, but thanks for your kind reminder.
Quoted 6 lines
Here's a prior response by Andrew to a post by you.
I've heard this so many times, and it just ain't so. The overwhelming
majority of problem areas are inside locks. All the complexity and maintainability difficulties to which you refer exist in the preempt
patch as well. There just is no difference.
There is a difference. There is of course the maintenance work which have both approaches in common, every kernel has to be tested for new latency problems. What differs is the amount of problems that needs fixing, as preempt can handle the problems outside of locks automatically, but inserting schedule points for these cases is usually quite simple. (I leave it open whether these problem are really only the minority, it doesn't matter much, it only matters that they do exist.)
The remaining problems need to be examined again by either approach. Breaking up the locks and inserting (implicit or explicit) schedule points is often the simpler solution, but analyzing the problem and adjusting the algorithm leads usually to the cleaner solution. Anyway, this is again pretty much common for both approaches.
There is an additional cost for maintaining the explicit schedule points, as they mean additional code all over the kernel, which has to be maintained and to be verified overtime something is changed in that area. This work has to be done by someone, if the ll patch would be included into the standard kernel, the burden would be put onto every maintainer of the systems that were changed. The easy approach by these maintainers could be of course to just drop these schedule points, but then the ll maintainer can start from zero and it adds up to the testing costs above. This additional cost does not exist for all cases that are automatically handled by preempting.
bye, Roman
Hi,
Quoted 6 lines · Rik van Riel
Quoted 3 lines
So far I haven't seen any evidence, that preempt introduces any _new_ serious problems, so I'd rather like to see to get the best out of both.
Are you seriously suggesting you haven't read a single email in this thread yet ?
Could you please be more explicit?
bye, Roman
Hi,
Quoted 3 lines · On Sun, 13 Jan 2002 [email protected] wrote:
Nobody has answered my question about the conflict between SMP per-cpu caching and preempt. Since NUMA is apparently the future of MP in the PC world and the future of Linux servers, it's interesting to consider this tradeoff.
Preempt is a UP feature so far.
Quoted 2 lines
Nobody has answered the question about how to make sure all processes make progress with preempt.
The same way as without preempt.
Quoted 3 lines
Nobody has clearly explained how to avoid what I claim to be the inevitable result of preempt -- priority inheritance locks (not just semaphores). What we have is some "we'll figure that out when we get to it".
So far you haven't given any reason, how preempt should lead to this. (If I missed something, please explain it in a way a mere mortal can understand it.)
Quoted 1 line
It's not even clear how preempt is supposed to interact with
SCHED_FIFO.
The same way as without preempt.
More of other FUD deleted, Victor, could you please stop this?
bye, Roman
Quoted 4 lines · Daniel Phillips
I'd like to add my 'me too' to those who have requested a re-run of this test, building the *identical* kernel tree every time, starting from the same initial conditions. Maybe that's what you did, but it's not clear from your post.
Its obvious its same source code under different kernels. It would have no sense to do othervise and it would require more effort than just boot other image and run same script.
Marian
Quoted 9 lines · Robert Love
Quoted 7 lines · On Sun, 2002-01-13 at 10:18, [email protected] wrote:
No, I use a script which is run in single user mode after a reboot. So there are only a few processes running when I start the script (see attachment) and the jobs should start from the same environment.
Quoted 2 lines
What happens when you do the same test, compiling one kernel under multiple different kernels?
Quoted 6 lines
Quoted 2 lines
That is exactly what I am doing. I even try to my best to have the exact same starting environment ...
So there you go, his testing is accurate. Now we have results that preempt works and is best and it is still refuted. Everyone is running around with these "ll is best" or "preempt sucks throughput" and that is
assuming the report can be trusted this is not the test where we can measure a throughput regression, this is a VM intensive test and nothing else. Swap load.
In short, run top and check you've 100% system load and cpus are never idle or in userspace, and _then_ it will most certainly get an interesting benchmark for -preempt throughput.
Furthmore the whole comparison is flawed, just -O(1) is as broken as mainline w.r.t. the scheduling point, and -aa has the right scheduling point but not the -O(1) scheduler, so there's no way to compare those numbers at all. If you want to make any real comparison you should apply -preempt on top of -aa.
Assuming it is really -preempt that makes the numbers more repetable (not the fact -O(1) alone has the broken rescheduling points), this still doesn't proof anything yet, the lower numbers are most certainly because those tasks getting the page faults get rescheduled faster, -aa didn't do more cpu work, it just had the cpus more idle than -preempt apparently, this may be the indication of an important scheduling point missing somewhere, if somebody could run a lowlatency measurement during a swap intensive load and send me the offending IP that could probably be addressed with a one liner.
Andrea
Quoted 35 lines · J Sloan
Ah - if it stands a chance of going into 2.4,
I'll test the heck out of it!
I'll give it the Q3A test, the RtCW test, the
xine/xmms/dbench tests, and more - glad
to be of service.
jjs
Andrew Morton wrote:Ed Sweetman wrote:
If you want to test the preempt kernel you're going to need something that can find the mean latancy or "time to action" for a particular program or all programs being run at the time and then run multiple programs that you
would find on various peoples' systems. That is the "feel" people talk
about when they praise the preempt patch.Right. And that is precisely why I created the "mini-ll" patch. To give the improved "feel" in a way which is acceptable for merging into the 2.4 kernel.
And guess what? Nobody has tested the damn thing, so it's going
nowhere.
Here it is again:fs/buffer.c Sat Jan 12 12:22:29 2002 renamed from fs/buffer.c Fri Dec 21 11:19:14 2001 +2
-1@@ -249,12 +249,19 @@ static int wait_for_buffers(kdev_t dev, struct buffer_head * next; int nr; - next = lru_list[index]; nr = nr_buffers_type[index]; +repeat: + next = lru_list[index]; while (next && --nr >= 0) { struct buffer_head *bh = next;
fs/buffer.c Sat Jan 12 12:22:29 2002 static int wait_for_buffers(kdev_t dev, · line 266
Quoted 10 lines
fs/buffer.c Sat Jan 12 12:22:29 2002 renamed from fs/buffer.c Fri Dec 21 11:19:14 2001 +6
-0next = bh->b_next_free; + if (dev == NODEV && current->need_resched) { + spin_unlock(&lru_list_lock); + conditional_schedule(); + spin_lock(&lru_list_lock); + goto repeat; + } if (!buffer_locke d(bh)) {
this introduces possibility of looping indefinitely, this is why I rejected it while I merged the mini-ll other points into -aa, if you want to do anything like that at the very least you should roll the head of the list as well or something like that.
Andrea
Quoted 1 line
More of other FUD deleted, Victor, could you please stop this?
Insulting people won't make problems go away Roman.
Quoted 9 lines · Robert Love
Quoted 7 lines · On Sun, 2002-01-13 at 12:42, [email protected] wrote:
13-pre5aa1 18-pre2aa2 18-pre3 18-pre3s 18-pre3sp 18-pre3minill j100: 6:59.79 78% 7:07.62 76% * 6:39.55 81% 6:24.79 83% * j100: 7:03.39 77% 8:10.04 66% * 8:07.13 66% 6:21.23 83% * j100: 6:40.40 81% 7:43.15 70% * 6:37.46 81% 6:03.68 87% * j100: 7:45.12 70% 7:11.59 75% * 7:14.46 74% 6:06.98 87% * j100: 6:56.71 79% 7:36.12 71% * 6:26.59 83% 6:11.30 86% *
Quoted 7 lines
Quoted 5 lines
j75: 6:22.33 85% 6:42.50 81% 6:48.83 80% 6:01.61 89% 5:42.66 93% 7:07.56 77% j75: 6:41.47 81% 7:19.79 74% 6:49.43 79% 5:59.82 89% 6:00.83 88% 7:17.15 74% j75: 6:10.32 88% 6:44.98 80% 7:01.01 77% 6:02.99 88% 5:48.00 91% 6:47.48 80% j75: 6:28.55 84% 6:44.21 80% 9:33.78 57% 6:19.83 85% 5:49.07 91% 6:34.02 83% j75: 6:17.15 86% 6:46.58 80% 7:24.52 73% 6:23.50 84% 5:58.06 88% 7:01.39 77%Again, preempt seems to reign supreme. Where is all the information
those comparison are totally flawed. There's nothing to compare in there.
minill misses the O(1) scheduler, and -aa has faster vm etc... there's absolutely nothing to compare in the above numbers, all variables changes at the same time.
I'm amazed I've to say this, but in short:
1) to compare minill with preempt, apply both patches to 18-pre3, as the only patch applied (no O(1) in the way of preempt!!!!)
2) to compare -aa with preempt, apply -preempt on top of -aa and see what difference it makes
If you don't follow exactly those simple rules you will change an huge amount of variables at the same time, and it will be again impossible to make any comparison or deduction from the numbers.
Andrea
Quoted 5 lines · Alan Cox
Quoted 3 lines
Again, preempt seems to reign supreme. Where is all the information correlating preempt is inferior? To be fair, however, we should bench a mini-ll+s test.
How about some actual latency numbers ?
with an huge rescheduling rate (huge swapout/swapin load) and the scheduler walking over 100 tasks at each schedule it is insane to deduct anything from those numbers (-preempt was using O(1) scheduler!!!!). so please don't make any assumption by just looking at those numbers.
Andrea
Quoted 4 lines · On Mon, 14 Jan 2002 02:04:56 -0800 Andrew Morton <[email protected]> wrote:
Quoted 3 lines · Stephan von Krawczynski
...
Unfortunately me have neither of those. This would mean I cannot benefit
from> > _these_ patches, but instead would need _others_ [...]
Quoted 3 lines
In
3c59x.c, probably the biggest problem will be the call toissue_and_wait()inboomerang_start_xmit(). On a LAN which is experiencing heavy collision
rates> this can take as long as 2,000 PCI cycles (it's quite rare, and possibly an> erratum). It is called under at least two spinlocks.
Quoted 6 lines
In via-rhine,
wait_for_reset()can busywait for up to ten milliseconds.via_rhine_tx_timeout()calls it from under a spinlock.In
eepro100.c,wait_for_cmd_done()can busywait for one millisecond and is called multiple times under spinlock.
Did I get that right, as long as spinlocked no sense in conditional_schedule() ?
Quoted 1 line
Preemption will help _some_ of this, but by no means all, or enough.
Maybe we should really try to shorten the lock-times _first_. You mentioned a way to find the bad guys?
Regards,
Stephan
Quoted 2 lines · Robert Love
user system. But things like (ack!) dbench 16 show a marked improvement.
please try again on top of -aa, and I've to specify this : benchmarked in a way that can be trusted and compared, so we can make some use of this information. This mean with -18pre2aa2 alone and only -preempt on top of -18pre2aa2.
NOTE: I'd be glad to say "preempt rules", "go preempt", "preempt is cool" like you as soon as I have some proof it makes _THE_ difference and that it is worth the mess on SMP (per-cpu, RCU locking, etc...), not to tell about the other architectures, but at the moment there's only a number of people running xmms on mainline with the broken scheduling points and those numbers that cannot be compared in any sane way. I repeat, I'm not against preempt, I just want to get some real world proof and measurement and at the moment I think preempt doesn't worth, but if you give us _any_ real world proof that a that low mean latency of the order of 10/100 usec matters to get most of the cpu cycles out of the cpu during trashing (as it could be possible to speculate from the broken benchmark posted in this thread), and that there's no real regression with the additional branches in the spin_unlock in 100% system load, I may change my mind (an of course, only for anything above 2.5, and still I think there are more interesting optimizations to do rahter than requiring everybody spending lots of time fixing drivers, auditing, fixing smp, rcu locking etc... but ok if it is obviously good thing [aka no real regression and only benefits long term] it would be ok to do it early as well). I'm not particularly worried about the preempt lock around the per-cpu stuff, that's a cacheline local, and it could go into the schedule_data like I did for the rcu per-cpu variables, so they're at zero cacheline cost (RCU_poll patch costs now only 1 instruction per schedule and zero memory overhead [an incl instruction precisely]).
Quoted 7 lines
Quoted 3 lines
Benchmarks are well and good, but until we have a solid explanation for the throughput changes which people are seeing, it's risky to claim that there is a general benefit.
I have an explanation. We can schedule quicker off a woken task. When an event occurs that allows an I/O-blocked task to run, its time-to-run is shorter. Same event/response improvement that helps interactivity.
That's a nice speculation out of a broken comparison, it may be really the case, there's no way to be sure, before that sum of usec you should also sum the seconds spent walking the tasklist in the non O(1) scheduler.
Andrea
Hi,
Quoted 3 lines · Alan Cox
Quoted 1 line
More of other FUD deleted, Victor, could you please stop this?
Insulting people won't make problems go away Roman.
I'm really trying to avoid this, I'm more than happy to discuss theoretical or practical problems _if_ they are backed by arguments, latter are very thin with Victor. Making pointless claims only triggers above reaction. If I did really miss a major argument so far, I will publicly apologize.
bye, Roman
Quoted 12 lines · Rob Landley
Quoted 10 lines · On Friday 11 January 2002 09:50 pm, [email protected] wrote:
Quoted 8 lines · Robert Love
On Fri, 2002-01-11 at 07:37, Alan Cox wrote:
The preemptible kernel plus the spinlock cleanup could really take us far. Having locked at a lot of the long-held locks in the kernel, I am confident at least reasonable progress could be made.Beyond that, yah, we need a better locking construct. Priority inversion could be solved with a priority-inheriting mutex, which we can tackle if and when we want to go that route. Not now.
Quoted 7 lines
Quoted 4 lines
Backing the car up to the edge of the cliff really gives us good results. Beyond that, we could jump off the cliff if we want to go that route.
Preempt leads to inheritance and inheritance leads to disaster.I preempt leads to disaster than Linux can't do SMP. Are you saying that's the case?
There is a difference. Preempt have the same locking requirements as SMP, but there's also _timing_ requirements.
Quoted 4 lines
The preempt patch is really "SMP on UP". If pre-empt shows up a problem, then it's a problem SMP users will see too. If we can't take advantage of the existing SMP locking infrastructure to improve latency and interactive feel on UP machines, than SMP for linux DOES NOT WORK.
One example where preempt may break and SMP does not:
Consider driver code. Critical data structures is protected by spinlocks,
but some of the access to the hardware device itself is outside those locks (I can prove that the other processors can't get there with the driver in that state anyway)
Now, hardware access has timing requirements. That works on SMP because you don't loose the CPU to anything but interrupts, and they are fast. You get it back almost immediately. The device in question times out after a much longer interval.
But preempt may decide to run a time-consuming higher priority task in the
middle of device access, cuasing the hardware to time out and fail. Hardware access isn't necessarily in a interrupt handler. It may be done directly in a read/write/ioctl call if the device happens to be available at the moment.
This is a case where SMP works even though preempt may fail. I don't know if this is an issue for existing drivers, but it is possible.
Helge Hafting
Quoted 46 lines
Quoted 3 lines
All the numbers I've seen show Morton's low latency just works better. Are there other numbers I should look at.
This approach is basically a collection of heuristics. The kernel has been profiled and everywhere a latency spike was found, a band-aid was put on it (an explicit scheduling point). This doesn't say there aren't other latency spikes, just that with the collection of hardware and software being benchmarked, the latency spikes that were found have each had a band-aid individually applied to them.
This isn't a BAD thing. If the benchmarks used to find latency spikes are at all like real-world use, then it helps real-world applications. But of COURSE the benchmarks are going to look good, since tuning the kernel to those benchmarks is the way the patch was developed!
The majority of the original low latency scheduling point work is handled automatically by the SMP on UP kernel. You don't NEED to insert scheduling points anywhere you aren't inside a spinlock. So the SMP on UP patch makes most of the explicit scheduling point patch go away, accomplishing the same thing in a less intrusive manner. (Yes, it makes all kernels act like SMP kernels for debugging purposes. But you can turn it off for debugging if you want to, that's just another toggle in the magic sysreq menu. And this isn't entirely a bad thing: applying the enormous UP userbase to the remaining SMP bugs is bound to squeeze out one or two more obscure ones, but those bugs DO exist already on SMP.)
However, what's left of the explicit scheduling work is still very useful. When you ARE inside a spinlock, you can't just schedule, you have to save state, drop the lock(s), schedule, re-acquire the locks, and reload your state in case somebody else diddled with the structures you were using. This is a lot harder than just scheduling, but breaking up long-held locks like this helps SMP scalability, AND helps latency in the SMP-on-UP case.
So the best approach is a combination of the two patches. SMP-on-UP for everything outside of spinlocks, and then manually yielding locks that cause problems. Both Robert Love and Andrew Morton have come out in favor of each other's patches on lkml just in the past few days. The patches work together quite well, and each wants to see the other's patch applied.
Rob
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Quoted 5 lines
I'm really trying to avoid this, I'm more than happy to discuss theoretical or practical problems _if_ they are backed by arguments, latter are very thin with Victor. Making pointless claims only triggers above reaction. If I did really miss a major argument so far, I will publicly apologize.
You seem to be missing the fact that latency guarantees only work if you can make progress. If a low priority process is pre-empted owning a resource (quite likely) then you won't get your good latency. To handle those cases you get into priority boosting, and all sorts of lock complexity - so that the task that owns the resource temporarily can borrow your priority in order that you can make progress at your needed speed. That gets horrendously complex, and you get huge chains of priority dependancies including hardware level ones.
The low latency patches don't make that problem go away, but they achieve equivalent real world latencies up to at least the point you have to do priority handling of that kind.
Alan
Quoted 5 lines
Quoted 2 lines
In
eepro100.c,wait_for_cmd_done()can busywait for one millisecond and is called multiple times under spinlock.Did I get that right, as long as spinlocked no sense in
conditional_schedule()?
No conditional schedule, no pre-emption. You would need to rewrite that code to do something like try for 100uS then queue a 1 tick timer to retry asynchronously. That makes the code vastly more complex for an error case and for some drivers where irq mask is required during reset waits won't help.
Yet again there are basically 1mS limitations buried in the hardware.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"yodaiken" == yodaiken <[email protected]> writes:
yodaiken> It's not even clear how preempt is supposed to interact with SCHED_FIFO.
How so ? The POSIX specification is not clear enough or it is not to be followed ?
Regards,
-velco
Quoted 7 lines · Momchil Velikov
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"yodaiken" == yodaiken <[email protected]> writes:
yodaiken> It's not even clear how preempt is supposed to interact with
SCHED_FIFO.How so ? The POSIX specification is not clear enough or it is not to be followed ?
You can have an rt task block on a lock held by a normal task that was preempted by a rt task of lower priority. The same problem as with the sched_idle patches.
Regards
Oliver
Quoted 8 lines · Andrea Arcangeli
Quoted 2 lines · Robert Love
user system. But things like (ack!) dbench 16 show a marked improvement.
please try again on top of -aa, and I've to specify this : benchmarked in a way that can be trusted and compared, so we can make some use of this information. This mean with -18pre2aa2 alone and only -preempt on top of -18pre2aa2.
I realize the test isn't directly comparing what we want, so I asked him for ll+O(1) benchmark, which he gave. Another set would be to do preempt and ll alone.
Robert Love
Hi,
Quoted 8 lines · Alan Cox
You seem to be missing the fact that latency guarantees only work if you can make progress. If a low priority process is pre-empted owning a resource (quite likely) then you won't get your good latency. To handle those cases you get into priority boosting, and all sorts of lock complexity - so that the task that owns the resource temporarily can borrow your priority in order that you can make progress at your needed speed. That gets horrendously complex, and you get huge chains of priority dependancies including hardware level ones.
Any ll approach so far only addresses a single type of latency - the time from waking up an important process until it really gets the cpu. What is not handled by any patch are i/o latencies, that means the average time to get access to a specific resource. (To be exact breaking up locks modifies of course i/o latencies, but that's more a side effect.)
I/O latencies are only relevant for this discussion insofar, as to verify they are not overly harmed by improving scheduling latencies. Preempting does not modify the behaviour of the scheduler, all it does is to increase the scheduling frequency. This means it can happen that a low priority task locks a resource for a longer time, because it's interrupted by another task. Nethertheless the current scheduler guarantees every process gets its share of the cpu time(*), so the low priority task will continue and release the resource within a guaranteed amount of time. So the worst behaviour I see is that on a loaded system, a low priority task can hold up another task, if that task should be our interactive task, the interactivity is of course gone. But this problem is not really new, as we have no guarantees regarding i/o latencies. So everyone using any patch should be aware of that it's not a magical tool and for getting better scheduling latencies, one has to trade something else, but so far I haven't seen any evidence that it makes something else much worse.
(*) This of course assumes accurate cpu time accounting, but I mentioned this problem before. On the other hand it's also fixable, the tickless patch looks most interesting in this regard.
bye, Roman
Quoted 9 lines · Roman Zippel
Hi,
Quoted 3 lines · On Sun, 13 Jan 2002 [email protected] wrote:
Nobody has answered my question about the conflict between SMP per-cpu caching and preempt. Since NUMA is apparently the future of MP in the PC world and the future of Linux servers, it's interesting to consider this tradeoff.
Preempt is a UP feature so far.
I think this is a sufficient summary of your engineering approach.
...
Quoted 1 line
More of other FUD deleted, Victor, could you please stop this?
I guess that Andrew, Alan, Andrea and I all are raising objections that you ignore because we have some kind of shared bias.
Signature · 4 lines
--------------------------------------------------------- Victor Yodaiken Finite State Machine Labs: The RTLinux Company. www.fsmlabs.com www.rtlinux.com
Quoted 4 lines · Momchil Velikov
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"yodaiken" == yodaiken <[email protected]> writes:
yodaiken> It's not even clear how preempt is supposed to interact with
SCHED_FIFO.How so ? The POSIX specification is not clear enough or it is not to be followed ?
POSIX makes no specification of how scheduling classes interact - unless something changed in the new version.
But more than that, the problem of preemption is much more complex when you have task that do not share the "goodness fade" with everything else. That is, given a set of SCHED_OTHER processes at time T0, it is reasonable to design the scheduler so that there is some D so that by time T0+D each process has become the highest priority and has received cpu up to either a complete time slice or a I/O block. Linux kind of has this property now, and I believe that making this more robust and easier to analyze is going to be an enormously important issue. However, once you add SCHED_FIFO in the current scheme, this becomes more complex. And with preempt, you cannot even offer the assurance that once a process gets the cpu it will make _any_ advance at all.
Signature · 4 lines
--------------------------------------------------------- Victor Yodaiken Finite State Machine Labs: The RTLinux Company. www.fsmlabs.com www.rtlinux.com
I forgot the line that says: "Oliver pointed out the immediate problem but .."
Quoted 26 lines · On Mon, Jan 14, 2002 at 06:45:48AM -0700, [email protected] wrote:
Quoted 4 lines · Momchil Velikov
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"yodaiken" == yodaiken <[email protected]> writes:
yodaiken> It's not even clear how preempt is supposed to interact with
SCHED_FIFO.How so ? The POSIX specification is not clear enough or it is not to be followed ?
POSIX makes no specification of how scheduling classes interact - unless something changed in the new version.
But more than that, the problem of preemption is much more complex when you have task that do not share the "goodness fade" with everything else. That is, given a set of
SCHED_OTHERprocesses at time T0, it is reasonable to design the scheduler so that there is some D so that by time T0+D each process has become the highest priority and has received cpu up to either a complete time slice or a I/O block. Linux kind of has this property now, and I believe that making this more robust and easier to analyze is going to be an enormously important issue. However, once you addSCHED_FIFOin the current scheme, this becomes more complex. And with preempt, you cannot even offer the assurance that once a process gets the cpu it will make _any_ advance at all.Signature · 4 lines
--------------------------------------------------------- Victor Yodaiken Finite State Machine Labs: The RTLinux Company. www.fsmlabs.com www.rtlinux.com
Signature · 4 lines
--------------------------------------------------------- Victor Yodaiken Finite State Machine Labs: The RTLinux Company. www.fsmlabs.com www.rtlinux.com
Quoted 8 lines · Roman Zippel
Quoted 2 lines · On Sun, 13 Jan 2002 [email protected] wrote:
Nobody has answered the question about how to make sure all processes make progress with preempt.
The same way as without preempt.
More of other FUD deleted, Victor, could you please stop this?
Roman, Victor asks meaningful questions.
Quoted 10 lines · Marian Jancar
Quoted 4 lines · Daniel Phillips
I'd like to add my 'me too' to those who have requested a re-run of this test, building the *identical* kernel tree every time, starting from the same initial conditions. Maybe that's what you did, but it's not clear from your post.
Its obvious its same source code under different kernels. It would have no sense to do othervise and it would require more effort than just boot other image and run same script.
It's a different tree each time. Same contents. Different tree.
Signature · 4 lines
--------------------------------------------------------- Victor Yodaiken Finite State Machine Labs: The RTLinux Company. www.fsmlabs.com www.rtlinux.com
Quoted 7 lines
So the worst behaviour I see is that on a loaded system, a low priority task can hold up another task, if that task should be our interactive task, the interactivity is of course gone. But this problem is not really new, as we have no guarantees regarding i/o latencies. So everyone using any patch should be aware of that it's not a magical tool and for getting better scheduling latencies, one has to trade something else, but so far I haven't seen any evidence that it makes something else much worse.
It doesn't make anything better is the issue. Its more complex than ll but gains nothing
Hi,
Quoted 2 lines · Alan Cox
It doesn't make anything better is the issue. Its more complex than ll but gains nothing
Please see my previous mail about maintenance costs.
bye, Roman
Quoted 4 lines · Roman Zippel
Any ll approach so far only addresses a single type of latency - the time from waking up an important process until it really gets the cpu. What is not handled by any patch are i/o latencies, that means the average time to get access to a specific resource.
OK, suppose you have three tasks.
A is a SCHED_FIFO task
B is a nice 0 SCHED_OTHER task
C is a nice +19 SCHED_OTHER task
Task B is your standard CPU hog, running all the time, task C has grabbed an inode semaphore (no spinlock), task A wakes up, preempts task C, tries to grab the inode semaphore and goes back to sleep.
Now task A has to wait for task B to give up the CPU before task C can run again and release the semaphore.
Without preemption task C would not have been preempted and it would have released the lock much sooner, meaning task A could have gotten the resource earlier.
Using the low latency patch we'd insert some smart code into the algorithm so task A also releases the lock before rescheduling.
Before you say this thing never happens in practice, I ran into this thing in real life with the SCHED_IDLE patch. In fact, this problem was so severe it convinced me to abandon SCHED_IDLE ;))
regards,
Rik
Signature · 4 lines
"Linux holds advantages over the single-vendor commercial OS"
-- Microsoft's "Competing with Linux" document
http://www.surriel.com/ http://distro.conectiva.com/Hi,
Quoted 7 lines · On Mon, 14 Jan 2002 [email protected] wrote:
Quoted 5 lines
Quoted 3 lines
Nobody has answered my question about the conflict between SMP per-cpu caching and preempt. Since NUMA is apparently the future of MP in the PC world and the future of Linux servers, it's interesting to consider this tradeoff.
Preempt is a UP feature so far.
I think this is a sufficient summary of your engineering approach.
Would you please care to explain, what the hell you want? Preempt on SMP has more problems than you mention above, so that the scope of my arguments only included UP. Sorry, if I missed something, but preempt on SMP is an entirely different dicussion.
Quoted 4 lines
Quoted 1 line
More of other FUD deleted, Victor, could you please stop this?
I guess that Andrew, Alan, Andrea and I all are raising objections that you ignore because we have some kind of shared bias.
No, your sparse use of arguments makes the difference.
bye, Roman
Hi,
Quoted 3 lines · On Mon, 14 Jan 2002 [email protected] wrote:
is going to be an enormously important issue. However, once you add
SCHED_FIFOin the current scheme, this becomes more complex. And with preempt, you cannot even offer the assurance that once a process gets the cpu it will make _any_ advance at all.
I'm not sure if I understand you correctly, but how is this related to preempt? A SCHED_FIFO tasks only delays SCHED_OTHER tasks, but it doesn't consume their time slice, so the remaining tasks still get their (previously assigned) time at the cpu, until all tasks have consumed their share.
bye, Roman
Quoted 4 lines · On 20020114 Stephan von Krawczynski wrote:
Hm, obviously the ll-patches look simple, but their pure required number makes me think they are as well stupid as simple. This whole story looks like making an old mac do real multitasking, just spread around scheduling points
Yup. That remind me of...
Would there be any kernel call every driver is doing just to hide there a conditional_schedule() so everyone does it even without knowledge of it ? Just like Apple put the SystemTask() inside GetNextEvent()...
Signature · 4 lines
J.A. Magallon # Let the source be with you... mailto:[email protected] Mandrake Linux release 8.2 (Cooker) for i586 Linux werewolf 2.4.18-pre3-beo #5 SMP Sun Jan 13 02:14:04 CET 2002 i686
Quoted 11 lines · J.A. Magallon
Quoted 4 lines · On 20020114 Stephan von Krawczynski wrote:
Hm, obviously the ll-patches look simple, but their pure required number makes me think they are as well stupid as simple. This whole story looks like making an old mac do real multitasking, just spread around scheduling points
Yup. That remind me of...
Would there be any kernel call every driver is doing just to hide there aconditional_schedule()so everyone does it even without knowledge of it ? Just like Apple put theSystemTask()insideGetNextEvent()...
Well the preempt patch sort of does this in every spin_unlock*() .....
This is getting silly ... feeback like "ll is better than PK", "feels smooth", "is reponsive", "my kernel compile is faster than yours", etc. is not getting us any closer to the "how" of making a better kernel.
What's the goal? How should SMP and NUMA behave? How is success measured?
It would be good to be very clear on the ultimate purpose before making radical changes. All of these changes are dancing around some vague concept of reponsiveness...so define it!
These comments seem to set a better tone for this thread, perhaps we can concentrate on _useful_ debate around some well defined goal.
Quoted 2 lines · [email protected] wrote:
The key one is some idea of being able to assure processes
of some rate of progress. This is not classical RT, but it is important to multimedia and databases and also to some applications we are interested in looking at.
Quoted 10 lines · Andrew Morton
But we can **make** it useful. I believe that internal preemption is the foundation to improve 2.5 kernel latency. But first we need consensus that we **want** linux to be a low-latency kernel.
Do we have that?
If we do, then as I've said before, holding a lock for more than N milliseconds becomes a bug to be fixed. We can put tools in the hands of testers to locate those bugs. Easy.
Quoted 5 lines · Robert Love
Quoted 4 lines · Andrea Arcangeli
Quoted 2 lines · Robert Love
user system. But things like (ack!) dbench 16 show a marked improvement.
Quoted 7 lines
Quoted 4 lines
please try again on top of -aa, and I've to specify this : benchmarked in a way that can be trusted and compared, so we can make some use of this information. This mean with -18pre2aa2 alone and only -preempt on top of -18pre2aa2.
I realize the test isn't directly comparing what we want, so I asked him for ll+O(1) benchmark, which he gave. Another set would be to do
^^ actually mini-ll
right (I was still in the middle of the backlog of my emails, so I didn't know he just produced the mini-ll+O(1)). The mini-ll+O(1) shows that -preempt is still a bit faster (as expected not much faster anymore). The reason it is faster it is probably really the sum of few usec latency of userspace cpu cycles that you save. However given the small difference in numbers in this patological case (-j1 obviously cannot take advantage of the few usec less of reduced latency) still makes me to think it doesn't worth the pain and the complexity, or at least somebody should also proof that it doesn't visibly drop performance in a 100% cpu bound _system_ (not user) time load (ala pagecache_lock collision testcase with sendfile etc..), in general with a single thread in the system.
Andrea
Hi,
Quoted 3 lines · Rik van Riel
Without preemption task C would not have been preempted and it would have released the lock much sooner, meaning task A could have gotten the resource earlier.
Define "much sooner", nobody disputes that low priority tasks can be delayed, that's actually the purpose of both patches.
Quoted 2 lines
Using the low latency patch we'd insert some smart code into the algorithm so task A also releases the lock before rescheduling.
Could you please show me that "smart code"?
Quoted 3 lines
Before you say this thing never happens in practice, I ran into this thing in real life with the
SCHED_IDLEpatch. In fact, this problem was so severe it convinced me to abandonSCHED_IDLE;))
SCHED_IDLE is something completely different than preeempt. Rik, do I really have to explain the difference?
bye, Roman
Quoted 10 lines · Roman Zippel
Hi,
Quoted 3 lines · On Mon, 14 Jan 2002 [email protected] wrote:
is going to be an enormously important issue. However, once you add
SCHED_FIFOin the current scheme, this becomes more complex. And with preempt, you cannot even offer the assurance that once a process gets the cpu it will make _any_ advance at all.I'm not sure if I understand you correctly, but how is this related to preempt?
It's pretty subtle. If there is no preempt, processes don't get preempted. If there is preempt, they can be preempted. Amazing isn't it?
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"yodaiken" == yodaiken <[email protected]> writes:
yodaiken> current scheme, this becomes more complex. And with preempt, you cannot even offer the yodaiken> assurance that once a process gets the cpu it will make _any_ advance at all.
So? It either shouldn't have got the CPU anyway (maybe it CPU is needed for other things) or user's priority setup is seriously borked.
The scheduling policies, algorithms, mechanisms, whatever ... do not guarantee schedulability by themselves.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Oliver" == Oliver Neukum <[email protected]> writes:
Quoted 2 lines · Momchil Velikov
Quoted 2 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"yodaiken" == yodaiken <[email protected]> writes:
yodaiken> It's not even clear how preempt is supposed to interact with
Quoted 4 lines
Quoted 4 lines
SCHED_FIFO.How so ? The POSIX specification is not clear enough or it is not to be followed ?
Oliver> You can have an rt task block on a lock held by a normal task that was Oliver> preempted by a rt task of lower priority. The same problem as with the Oliver> sched_idle patches.
This can happen with a non-preemptible kernel too. And it has nothing to do with scheduling policy.
Quoted 8 lines · Bill Davidsen
Finally, I doubt that any of this will address my biggest problem with Linux, which is that as memory gets cheap a program doing significant disk writing can get buffers VERY full (perhaps a while CD worth) before the kernel decides to do the write, at which point the system becomes non-responsive for seconds at a time while the disk light comes on and stays on. That's another problem, and I did play with some patches this weekend without making myself really happy :-( Another topic, unfortunately.
Patience, the problem is understood and there will be a fix in the 2.5 timeframe.
--
Daniel
Quoted 6 lines · Andrew Morton
Daniel Phillips wrote:
I believe that internal preemption is
the foundation to improve 2.5 kernel latency. But first we need consensus that we *want* linux to be a low-latency kernel.Do we have that?
You have it from me, for what it's worth ;-)
Quoted 3 lines
If we do, then as I've said before, holding a lock for more than N milliseconds becomes a bug to be fixed. We can put tools in the hands of testers to locate those bugs. Easy.
Perhaps not a bug, but bad-acting. Just as putting a huge object on the stack is not necessarily a bug, but deserves a quick larting nonetheless.
--
Daniel
Quoted 6 lines
Oliver> You can have an rt task block on a lock held by a normal task that was Oliver> preempted by a rt task of lower priority. The same problem as with the Oliver>
sched_idlepatches.This can happen with a non-preemptible kernel too. And it has nothing to do with scheduling policy.
So why bother adding pre-emption. As you keep saying - it doesnt gain anything
Alan
Quoted 6 lines
Quoted 3 lines
stays on. That's another problem, and I did play with some patches this weekend without making myself really happy :-( Another topic, unfortunately.
Patience, the problem is understood and there will be a fix in the 2.5 timeframe.
Without a fix in the 2.4 timeframe everyone has to run 2.2. That strikes me as decidedly non optimal. If you are having VM problems try both the Andrea -aa and the Rik rmap-11b patches (*not together*) and report back
Quoted 12 lines · On January 14, 2002 02:45 pm, [email protected] wrote:
POSIX makes no specification of how scheduling classes interact - unless something changed in the new version.
But more than that, the problem of preemption is much more complex when you have task that do not share the "goodness fade" with everything else. That is, given a set of
SCHED_OTHERprocesses at time T0, it is reasonable to design the scheduler so that there is some D so that by time T0+D each process has become the highest priority and has received cpu up to either a complete time slice or a I/O block. Linux kind of has this property now, and I believe that making this more robust and easier to analyze is going to be an enormously important issue. However, once you addSCHED_FIFOin the current scheme, this becomes more complex. And with preempt, you cannot even offer the assurance that once a process gets the cpu it will make _any_ advance at all.
So the prediction here is that SCHED_FIFO + preempt can livelock some set of correctly designed processes, is that it? I don't see exactly how that could happen, though that may simply mean I didn't read closely enough.
--
Daniel
Quoted 9 lines
Quoted 2 lines
Quoted 2 lines
How so ? The POSIX specification is not clear enough or it is not to be followed ?
Oliver> You can have an rt task block on a lock held by a normal task that was Oliver> preempted by a rt task of lower priority. The same problem as with the Oliver>
sched_idlepatches.This can happen with a non-preemptible kernel too. And it has nothing to do with scheduling policy.
It can happen if you sleep with a lock held. It can not happen at random points in the code. Thus there is a relation to preemption in kernel mode.
To cure that problem tasks holding a lock would have to be given the highest priority of all tasks blocking on that lock. The semaphore code would get much more complex, even in the succesful code path, which would hurt a lot.
If on the other hand sleeping in kernel mode is explicit, you can simply give any task being woken up a timeslice and the scheduling requirements are met. If that should be a problem.
Regards
Oliver
Quoted 8 lines · On January 14, 2002 10:09 am, [email protected] wrote:
UNIX generally tries to ensure liveness. So you know that
cat lkarchive | grep feel | wc
will complete and not just that, it will run pretty reasonably because for UNIX _every_ process is important and gets cpu and IO time. When you start trying to add special low latency tasks, you endanger liveness. And preempt is especially corrosive because one of the mechanisms UNIX uses to assure liveness is to make sure that once a process starts it can do a significant chunk of work.
You're claiming that preemption by nature is not Unix-like?
--
Daniel
Quoted 11 lines · Daniel Phillips
Quoted 8 lines · On January 14, 2002 10:09 am, [email protected] wrote:
UNIX generally tries to ensure liveness. So you know that
cat lkarchive | grep feel | wc
will complete and not just that, it will run pretty reasonably because for UNIX _every_ process is important and gets cpu and IO time. When you start trying to add special low latency tasks, you endanger liveness. And preempt is especially corrosive because one of the mechanisms UNIX uses to assure liveness is to make sure that once a process starts it can do a significant chunk of work.You're claiming that preemption by nature is not Unix-like?
Kernel preemption is not traditionally part of UNIX.
Quoted 3 lines
--
Daniel
Signature · 4 lines
--------------------------------------------------------- Victor Yodaiken Finite State Machine Labs: The RTLinux Company. www.fsmlabs.com www.rtlinux.com
Hi,
Quoted 9 lines · [email protected] wrote:
Quoted 6 lines
Quoted 3 lines
is going to be an enormously important issue. However, once you add
SCHED_FIFOin the current scheme, this becomes more complex. And with preempt, you cannot even offer the assurance that once a process gets the cpu it will make _any_ advance at all.I'm not sure if I understand you correctly, but how is this related to preempt?
It's pretty subtle. If there is no preempt, processes don't get preempted. If there is preempt, they can be preempted. Amazing isn't it?
I just can't win against such brilliant argumentation, I'm out.
bye, Roman
Quoted 11 lines · Daniel Phillips
Quoted 7 lines · On January 14, 2002 10:09 am, [email protected] wrote:
UNIX generally tries to ensure liveness. So you know that
cat lkarchive | grep feel | wc
will complete and not just that, it will run pretty reasonably because
for UNIX _every_ process is important and gets cpu and IO time.
When you start trying to add special low latency tasks, you endanger
liveness. And preempt is especially corrosive because one of the mechanisms UNIX uses to assure liveness is to make sure that once a process starts it can do a significant chunk of work.You're claiming that preemption by nature is not Unix-like?
Unix started out life as a _time-sharing_ OS. It never claimed to be preemptive or real time. For those, you waited a while, then got to run MACH.
----------------------------------------------------------------------
- Rick Stevens, SSE, VitalStream, Inc. [email protected] -
- 949-743-2010 (Voice) http://www.vitalstream.com -
- -
- Change is inevitable, except from a vending machine. -
----------------------------------------------------------------------
Quoted 4 lines · J.A. Magallon
Yup. That remind me of...
Would there be any kernel call every driver is doing just to hide there aconditional_schedule()so everyone does it even without knowledge of it ? Just like Apple put theSystemTask()insideGetNextEvent()...
It's not nearly that easy. If it were, we would all certainly switch to the preemptive kernel design, and preempt whenever and wherever we needed.
Instead, we have to worry about reentrancy and thus can not preempt inside critical regions (denoted by spinlocks). So we can't have preempt there, and have more work to do -- thus this discussion.
Robert Love
Quoted 9 lines · Arjan van de Ven
Quoted 7 lines · J.A. Magallon
Quoted 4 lines · On 20020114 Stephan von Krawczynski wrote:
Hm, obviously the ll-patches look simple, but their pure required number makes me think they are as well stupid as simple. This whole story looks like making an old mac do real multitasking, just spread around scheduling points
Quoted 7 lines
Quoted 4 lines
Yup. That remind me of...
Would there be any kernel call every driver is doing just to hide there aconditional_schedule()so everyone does it even without knowledge of it ? Just like Apple put theSystemTask()insideGetNextEvent()...Well the preempt patch sort of does this in every spin_unlock*() ..... -
Gosh, not really. The nature of the preempt patch is to allow preemption on completion of the interrupt that put the contending task back in the run list. This can not be done if a spin lock is held, so yes, there is a test on exit from the spin lock, but the point is that this is only needed when the lock is release, not in unlocked code.
The utility of most of the ll patches is that they address the problem within locked regions. This is why there is a lock-break patch that is designed to augment the preempt patch. It picks up several of the long held spin locks and pops out of them early to allow preemption, and then relocks and continues (after picking up the pieces, of course).
Signature · 3 lines
George [email protected] High-res-timers: http://sourceforge.net/projects/high-res-timers/ Real time sched: http://sourceforge.net/projects/rtsched/
Quoted 22 lines · Stephan von Krawczynski
Quoted 4 lines · On Mon, 14 Jan 2002 02:04:56 -0800 Andrew Morton <[email protected]> wrote:
Quoted 3 lines · Stephan von Krawczynski
...
Unfortunately me have neither of those. This would mean I cannot benefitfrom> > _these_ patches, but instead would need _others_ [...]
Quoted 3 lines
In
3c59x.c, probably the biggest problem will be the call toissue_and_wait()inboomerang_start_xmit(). On a LAN which is experiencing heavy collisionrates> this can take as long as 2,000 PCI cycles (it's quite rare, and possibly an> erratum). It is called under at least two spinlocks.
Quoted 6 lines
In via-rhine,
wait_for_reset()can busywait for up to ten milliseconds.via_rhine_tx_timeout()calls it from under a spinlock.In
eepro100.c,wait_for_cmd_done()can busywait for one millisecond and is called multiple times under spinlock.
Quoted 7 lines
Did I get that right, as long as spinlocked no sense in
conditional_schedule()?Quoted 1 line
Preemption will help _some_ of this, but by no means all, or enough.
Maybe we should really try to shorten the lock-times _first_. You mentioned a way to find the bad guys?
Apply the preempt patch and then the preempt-stats patch. Follow instructions that come with the stats patch. It will report on the longest preempt disable times since the last report. You need to provide a load that will exercise the bad code, but it will tell you which, where, and how bad. Note: it measures preempt off time, NOT how long it took to get to some task, i.e. it does not depend on requesting preemption at the worst possible time.
Signature · 3 lines
George [email protected] High-res-timers: http://sourceforge.net/projects/high-res-timers/ Real time sched: http://sourceforge.net/projects/rtsched/
Quoted 17 lines · Rik van Riel
OK, suppose you have three tasks.
A is a
SCHED_FIFOtask
B is a nice 0SCHED_OTHERtask
C is a nice +19SCHED_OTHERtaskTask B is your standard CPU hog, running all the time, task C has grabbed an inode semaphore (no spinlock), task A wakes up, preempts task C, tries to grab the inode semaphore and goes back to sleep.
Now task A has to wait for task B to give up the CPU before task C can run again and release the semaphore.
Without preemption task C would not have been preempted and it would have released the lock much sooner, meaning task A could have gotten the resource earlier.
Quoted 6 lines
Using the low latency patch we'd insert some smart code into the algorithm so task A also releases the lock before rescheduling.
Before you say this thing never happens in practice, I ran into this thing in real life with the
SCHED_IDLEpatch. In fact, this problem was so severe it convinced me to abandonSCHED_IDLE;))
This isn't related. The problem you described can happen nearly as easily on a non-preemptible system. We have plenty of semaphores held across schedules and there is no reason to single out ones that acquire and release the semaphore in short, non-preemptible, sequences. We always have this "problem."
SCHED_IDLE is much different, as you know, because the SCHED_IDLE task holding the lock can _never_ get scheduled if there is a CPU hog on the system! With the preemptive case, we only worry about an increase in this period, which is at the expense of fairness in running higher priority tasks. But I think you know this ...
Robert Love
Quoted 7 lines · Alan Cox
Quoted 6 lines
I'm really trying to avoid this, I'm more than happy to discuss theoretical or practical problems _if_ they are backed by arguments, latter are very thin with Victor. Making pointless claims only triggers above reaction. If I did really miss a major argument so far, I will publicly apologize.
Quoted 9 lines
You seem to be missing the fact that latency guarantees only work if you can make progress. If a low priority process is pre-empted owning a resource (quite likely) then you won't get your good latency. To handle those cases you get into priority boosting, and all sorts of lock complexity - so that the task that owns the resource temporarily can borrow your priority in order that you can make progress at your needed speed. That gets horrendously complex, and you get huge chains of priority dependancies including hardware level ones.
It would be useful to define the scope and design guidelines of a "real
time task". Obviously, if it tries to perform filesystem or network
I/O it can block for a long time. If it acquires VFS locks it can suffer bad priority inversion.
I have all along assumed that a well-designed RT application would delegate all these operations to SCHED_OTHER worker processes, probably via shared memory/shared mappings. So in the simplest case, you'd have a SCHED_FIFO task which talks to the hardware, and which has a helper task which reads and writes stuff from and to disk. With sufficient buffering and readahead to cover the worst case IO latencies.
If this is generally workable, then it means that the areas of possible priority inversion are quite small - basically device driver read/write functions. The main remaining area where priority inversion can happen is in the page allocator. I'm experimenting/thinking about giving non-SCHED_OTHER tasks a modified form of atomic allocation to defeat this.
-
Quoted 11 lines · Bill Davidsen
Quoted 8 lines · Kent Borg
How does all this fit into doing a tick-less kernel?
There is something appealing about doing stuff only when there is stuff to do, like: respond to input, handle some device that becomes ready, or let another process run for a while. Didn't IBM do some nice work on this for Linux? (*Was* it nice work?) I was under the impression that the current kernel isn't that far from being tickless.
Quoted 7 lines
Quoted 6 lines
A tickless kernel would be wonderful for battery powered devices that could literally shut off when there be nothing to do, and it seems it would (trivially?) help performance on high end power hogs too.
Why do we have regular HZ ticks? (Other than I think I remember Linus saying that he likes them.)
I put a patch on sourceforge as part of the high-res-timers investigation the implemented a tick less kernel with instrumentation. It turns out to be overload prone, mostly do to the need to start and stop a "slice" timer on each schedule() call. I, for one, think this issue is dead and rightly so. The patch is still there for those who want to try it. See signature for URL.
Quoted 10 lines
Feel free to quantify the savings over the current setup with max power saving enabled in the kernel. I just don't see how "wonderful" it would be, given that an idle system currently uses very little battery if you setup the options to save power.
--
bill davidsen <[email protected]>
CTO, TMR Associates, Inc
Doing interesting things with little computers since 1979.
Signature · 3 lines
George [email protected] High-res-timers: http://sourceforge.net/projects/high-res-timers/ Real time sched: http://sourceforge.net/projects/rtsched/
Quoted 8 lines · Oliver Neukum
It can happen if you sleep with a lock held. It can not happen at random points in the code. Thus there is a relation to preemption in kernel mode.
To cure that problem tasks holding a lock would have to be given the highest priority of all tasks blocking on that lock. The semaphore code would get much more complex, even in the succesful code path, which would hurt a lot.
No, this isn't needed. This same problem would occur without preemption. Our semaphores now have locking rules such that we aren't going to have blatant priority inversion like this (1 holds A needs B, 2 holds B needs A).
When priority inversion begins to become a problem is if we intend to start turning existing spinlocks into semaphores. There the locking rules are weaker, and thus we would need to do priority inheriting. But that's not now.
Robert Love
Quoted 3 lines · On Mon, 2002-01-14 at 13:39, [email protected] wrote:
Quoted 1 line
You're claiming that preemption by nature is not Unix-like?
Kernel preemption is not traditionally part of UNIX.
True original AT&T was non-preemptible, but it also didn't originally have paging. Today, Solaris, IRIX, latest BSD (via BSDng), etc. are all preemptible kernels.
Ask Core whether SMPng in FreeBSD 5.0 will include preempt, I think they are still debating.
Robert Love
Quoted 10 lines · Robert Love
Quoted 8 lines · Oliver Neukum
It can happen if you sleep with a lock held. It can not happen at random points in the code. Thus there is a relation to preemption in kernel mode.
To cure that problem tasks holding a lock would have to be given the highest priority of all tasks blocking on that lock. The semaphore code would get much more complex, even in the succesful code path, which would hurt a lot.
Quoted 4 lines
No, this isn't needed. This same problem would occur without preemption. Our semaphores now have locking rules such that we aren't going to have blatant priority inversion like this (1 holds A needs B, 2 holds B needs A).
No this is a good old deadlock.
The problem with preemption and SCHED_FIFO is, that due to SCHED_FIFO you have no guarantee that any task will make any progress at all. Thus a semaphore could basically be held forever.
That can happen without preemption only if you do something that might block.
Regards
Oliver
Quoted 11 lines · Oliver Neukum
Quoted 4 lines
No, this isn't needed. This same problem would occur without preemption. Our semaphores now have locking rules such that we aren't going to have blatant priority inversion like this (1 holds A needs B, 2 holds B needs A).
No this is a good old deadlock.
The problem with preemption andSCHED_FIFOis, that due toSCHED_FIFOyou have no guarantee that any task will make any progress at all. Thus a semaphore could basically be held forever.
That can happen without preemption only if you do something that might block.
Well, semaphores block. And we have these races right now with SCHED_FIFO tasks. I still contend preempt does not change the nature of the problem and it certainly doesn't introduce a new one.
Robert Love
Quoted 15 lines · Andrea Arcangeli
Quoted 15 lines
fs/buffer.c Sat Jan 12 12:22:29 2002 renamed from fs/buffer.c Fri Dec 21 11:19:14 2001 +2
-1@@ -249,12 +249,19 @@ static int wait_for_buffers(kdev_t dev, struct buffer_head * next; int nr; - next = lru_list[index]; nr = nr_buffers_type[index]; +repeat: + next = lru_list[index]; while (next && --nr >= 0) { struct buffer_head *bh = next; next = bh->b_next_free;
Quoted 13 lines
fs/buffer.c Sat Jan 12 12:22:29 2002 static int wait_for_buffers(kdev_t dev, · line 266
Quoted 8 lines
fs/buffer.c Sat Jan 12 12:22:29 2002 renamed from fs/buffer.c Fri Dec 21 11:19:14 2001 +6
-0+ if (dev == NODEV && current->need_resched) { + spin_unlock(&lru_list_lock); + conditional_schedule(); + spin_lock(&lru_list_lock); + goto repeat; + } if (!buffer_locke d(bh)) {this introduces possibility of looping indefinitely, this is why I rejected it while I merged the mini-ll other points into -aa, if you want to do anything like that at the very least you should roll the head of the list as well or something like that.
I ended up deciding that the `NODEV' check here avoids livelocks. Unless, of course, the scheduling pressure is so high that we can't even run a few statements. I which case the interrupt load will be so high that the machine stops anyway. Possibly it needs to check `refile' as well.
A technique I frequently use in the full-ll patch is to only reschedule after we've executed the loop (say) 16 times before dropping out. This assures that forward progress is made. There's a test mode in the full ll patch - in this mode, it *always* assumes that need_resched is true. If the patch runs OK in this mode without livelocking, we know that it can't livelock.
Anyway, I'll revisit this. It is a "must fix". wait_for_buffers() is possibly the worst cause of latency in the kernel. The usual scenario is where kupdate has written 10,000 buffers and then sleeps. Next time it wakes, it has 10,000 clean, unlocked buffers to move from BUF_LOCKED onto BUF_CLEAN. It does this with lru_list_lock held.
-
Quoted 6 lines
I have all along assumed that a well-designed RT application would delegate all these operations to
SCHED_OTHERworker processes, probably via shared memory/shared mappings. So in the simplest case, you'd have aSCHED_FIFOtask which talks to the hardware, and which has a helper task which reads and writes stuff from and to disk. With sufficient buffering and readahead to cover the worst case IO latencies.
A real RT task has hard guarantees and to all intents and purposes you may deem the system failed if it ever misses one (arguably if you cannot verify it will never miss one).
The stuff we care about is things like DVD players which tangle with sockets, pipes, X11, memory allocation, and synchronization between multiple hardware devices all running at slightly incorrect clocks.
Quoted 11 lines · Alan Cox
Quoted 7 lines
I have all along assumed that a well-designed RT application would delegate all these operations to
SCHED_OTHERworker processes, probably via shared memory/shared mappings. So in the simplest case, you'd have aSCHED_FIFOtask which talks to the hardware, and which has a helper task which reads and writes stuff from and to disk. With sufficient buffering and readahead to cover the worst case IO latencies.A real RT task has hard guarantees and to all intents and purposes you may deem the system failed if it ever misses one (arguably if you cannot verify it will never miss one).
We know that :) Here, "RT" means "Linux-RT": something which is non-SCHED_OTHER, and which we'd prefer didn't completely suck.
Quoted 3 lines
The stuff we care about is things like DVD players which tangle with sockets, pipes, X11, memory allocation, and synchronization between multiple hardware devices all running at slightly incorrect clocks.
Well, that's my point. A well-designed DVD player would have two processes. One which tangles with the sockets, pipes, disks, etc, and which feeds data into and out of the SCHED_FIFO task via a shared, mlocked memory region.
What I'm trying to develop here is a set of guidelines which will allow application developers to design these programs with a reasonable degree of success.
-
Quoted 7 lines
Well, that's my point. A well-designed DVD player would have two processes. One which tangles with the sockets, pipes, disks, etc, and which feeds data into and out of the
SCHED_FIFOtask via a shared, mlocked memory region.What I'm trying to develop here is a set of guidelines which will allow application developers to design these programs with a reasonable degree of success.
What about the X server 8)
Given 1mS and vague fairness DVD is more than acceptable
Quoted 11 lines · Alan Cox
Quoted 6 lines
Quoted 4 lines
stays on. That's another problem, and I did play with some patches this weekend without making myself really happy :-( Another topic, unfortunately.
Patience, the problem is understood and there will be a fix in the 2.5 timeframe.
Without a fix in the 2.4 timeframe everyone has to run 2.2. That strikes me as decidedly non optimal. If you are having VM problems try both the Andrea -aa and the Rik rmap-11b patches (*not together*) and report back
Easiest is to grab 2.4.17 and apply 2.4.18pre2 and 2.4.18pre2-aa2 -
pre2-aa2 has all the fixes and tweaks I had been doing by hand.
cu
jjs
Quoted 1 line
Quoted 2 lines · Stephan von Krawczynski
Just a short question: the last (add-on) patch to mini-ll I saw on the
It was for full-ll, not for mini-ll.
Quoted 11 lines
patches:
drivers/net/3c59x.cdrivers/net/8139too.cdrivers/net/eepro100.cUnfortunately me have neither of those. This would mean I cannot benefit from _these_ patches, but instead would need _others_ (like tulip or name-one-of-the-rest-of-the-drivers) to see _some_ effect you tell me I _should_ see (I currently see _none_). How do you argue then against the
statement: we need patches for /drivers/net/*.c ?? I do not expect3c59x.cto be particularly bad in comparison to tulip/*.c or lets sayvia-rhine.c, do you?
I also checked the tulip driver (which is the one I use at home) and didn't find need for "fixing" there. I will definitely take a closer look at that driver in future.
WLAN drivers seem to need some hacking, but I'm not very interested in that area. I think WLAN is one big security hole that noone should be using...
- Jussi Laako
Signature · 2 lines
PGP key fingerprint: 161D 6FED 6A92 39E2 EB5B 39DD A4DE 63EB C216 1E4B Available at PGP keyservers
Quoted 4 lines · Alan Cox
Quoted 4 lines
Quoted 3 lines
In
eepro100.c,wait_for_cmd_done()can busywait for one millisecond and is called multiple times under spinlock.
Quoted 8 lines
Quoted 2 lines
Did I get that right, as long as spinlocked no sense in
conditional_schedule()No conditional schedule, no pre-emption. You would need to rewrite that code to do something like try for 100uS then queue a 1 tick timer to retry asynchronously. That makes the code vastly more complex for an error case and for some drivers where irq mask is required during reset waits won't help.
That wait_for_cmd_done() and similar functions in other drivers are called let's say 3 times in interrupt handler or spinlocked routine and 20 times in non-interrupts disabled nor spinlocked functions.
Spinlocked reqions are usually protected by spin_lock_irqsave().
So the code reads
if (!spin_is_locked(sl)) conditional_schedule();
This doesn't make the whole problem go away, but could make the situation a little bit better for most of the time?
- Jussi Laako
Signature · 2 lines
PGP key fingerprint: 161D 6FED 6A92 39E2 EB5B 39DD A4DE 63EB C216 1E4B Available at PGP keyservers
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Alan" == Alan Cox <[email protected]> writes:
Oliver> You can have an rt task block on a lock held by a normal task that was Oliver> preempted by a rt task of lower priority. The same problem as with the Oliver> sched_idle patches.
Quoted 3 lines
Quoted 3 lines
This can happen with a non-preemptible kernel too. And it has nothing to do with scheduling policy.
Alan> So why bother adding pre-emption. As you keep saying - it doesnt Alan> gain anything
Nope. I don't. I said (at least in the above) it didn't hurt.
One can consider a non-preemptible kernel as a special kind of priority inversion, preemptible kernel will eliminate _that_ case of priority inversion.
Regards,
-velco
Quoted 4 lines
Well, semaphores block. And we have these races right now with
SCHED_FIFOtasks. I still contend preempt does not change the nature of the problem and it certainly doesn't introduce a new one.
But it does:
down(&sem);do_something_that_cannot_block();up(&sem);
Will stop a SCHED_FIFO task for a definite amount of time. Only until it returns from the kernel to user space at worst.
If do_something_that_cannot_block() can be preempted, a SCHED_FIFO task can block indefinitely long on the semaphore, because you have no guarantee that the scheduler will ever again select the the preempted task. In fact it must never again select the preempted task as long as there's another runnable SCHED_FIFO task.
Regards
Oliver
Quoted 3 lines · Momchil Velikov
One can consider a non-preemptible kernel as a special kind of priority inversion, preemptible kernel will eliminate _that_ case of priority inversion.
The problem here is that priority means something very different in a time-shared system than in a hard real-time system. And even in real-time systems, as Walpole and colleagues have pointed out, priority doesn't really capture much of what is needed for good scheduling.
In a general purpose system, priorities are dynamic and "fair". The priority of even the lowliest process increases while it waits for time. In a raw real-time system, the low priority process can sit forever and should wait until no higher priority thread needs the processor. So it's absurd to talk of priority inversion in a non RT system. When a low priority process is delaying a higher priority task for reasons of fairness, increased throughput, or any other valid objective, that is not a scheduling error.
Quoted 3 lines
Regards,
-velco
Signature · 4 lines
--------------------------------------------------------- Victor Yodaiken Finite State Machine Labs: The RTLinux Company. www.fsmlabs.com www.rtlinux.com
Quoted 32 lines · [email protected] wrote:
Quoted 20 lines · Ed Sweetman
Quoted 9 lines · On Sat, Jan 12, 2002 at 09:52:09AM -0700, [email protected] wrote:
Quoted 6 lines · On Sat, Jan 12, 2002 at 04:07:14PM +0100, [email protected] wrote:
Quoted 2 lines
I did my usual compile testings (untar kernel archive, apply patches, make -j<value> ...
If I understand your test,
you are testing different loads - you are compiling kernels that maydiffer
Quoted 1 line
Quoted 1 line
in size and makefile organization, not to mention different layout on
the
Quoted 1 line
Quoted 1 line
file system and disk.
Can someone tell me why we're "testing" the preempt kernel by running make -j on a build? What exactly is this going to show us? The only thing i can think of is showing us that throughput is not damaged when you want to run single apps by using preempt. You dont get to see the effects of the kernel preemption because all the damn thing is doing is preempting itself.
Quoted 9 lines
If you want to test the preempt kernel you're going to need something that can find the mean latancy or "time to action" for a particular program or all programs being run at the time and then run multiple programs that you
would find on various peoples' systems. That is the "feel" people talk
about when they praise the preempt patch. make -j'ing something and not testing anything else but that will show you nothing important except "does
throughput get screwed by the preempt patch." Perhaps checking the
latencies on a common program on people's systems like mozilla or konqueror while doing a 'make -j N bzImage' would be a better idea.
Quoted 4 lines
That's the second test I am normally running. Just running xmms while doing the kernel compile. I just wanted to check if the system slows down because of preemption but instead it compiled the kernel even faster :-)
This sort of thing is nice to hear, but, it does show up a problem in the non-preempt kernel. That preemption improves compile performance implies that the kernel is not doing the right thing during a normal compile and that preemption, to some extent, corrects the problem. But preemption adds the overhead of additional context switches. It would be nice to know where the time is coming from. I.e. lets assume that the actual compile takes about the same amount of execution time with or without preemption. Then for the preemptable kernel to do the job faster something else must go up, idle time perhaps. If this is the case, then there is some place in the kernel that is wasting cpu time and that is preemptable and the preemptable patch is moving this idle time to the idle process.
What ever the reason, while I do want to promote preemption, I think we should look at this issue and, at the very least, explain it.
Quoted 24 lines
But so far I was not able to test the latency and furthermore
it is very difficult to "measure" skipping of xmms ...Quoted 1 line
Quoted 1 line
Ouch, I assumed this wasn't the case indeed.
Sorry for not answering immedeatly but I am compiling the same kernel source with the same .config and everything I could think of being the same! I even do a 'rm -rf linux' after every run and untar the same sources *every* time.
Regards,
Jogi
--
Well, yeah ... I suppose there's no point in getting greedy, is there?
<< Calvin & Hobbes >>
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Signature · 3 lines
George [email protected] High-res-timers: http://sourceforge.net/projects/high-res-timers/ Real time sched: http://sourceforge.net/projects/rtsched/
Quoted 58 lines · [email protected] wrote:
Quoted 11 lines · Roman Zippel
Hi,
Quoted 7 lines · [email protected] wrote:
Quoted 6 lines
Quoted 4 lines
SCHED_FIFOleads to
niced app 1 in K mode gets Sem ASCHED_FIFOapp prempts and blocks on Sem A whoops! app 2 in K more preempts niced app 1Please explain what's different without the preempt patch.
Quoted 8 lines
Quoted 5 lines
See that "preempt" in line 2 . Linux does not
preempt kernel mode processes otherwise. The beauty of the non-preemptive kernel is that "in K mode every process makes progress" and even the "niced app" will complete its use of SemA and release it in one run.The point of using semaphores is that one can sleep while holding them, whether this is forced by preemption or voluntary makes no difference.
No. The point of using semaphores is that one can sleep while _waiting_ for the resource. Sleeping while holding semaphores is a different kettle of lampreys entirely.
And it makes a very big difference
A:
get sem on memory pool
do something horrible to pool
release sem on memory poolIn a preemptive kernel this can cause a deadlock. In a non preemptive it cannot. You are correct in that
B:
get sem on memory pool
do potentially blocking operations
release sem
is also dangerous - but I don't think that helps your case. To fix B, we can enforce a coding rule - one of the reasons why we have all those atomic ops in the kernel is to be able to avoid this problem.
To fix A in a preemptive kernel we need to start messing about with priorities and that's a major error.
"The current kernel has too many places where processes can sleep while holding semaphores so we should always have the potential of blocking with held semaphores" is, to me, a backwards argument.Quoted 10 lines
Quoted 9 lines
If you have a reasonably fair scheduler you
can make very useful analysis with Linux now of the formUnder 50 active proceses in the system means that in every 2 second interval every process
will get at least 10ms of time to run.That's a very valuable property and it goes away in a preemptive kernel to get you something vague.
Quoted 6 lines
Quoted 3 lines
How is that changed? AFAIK inserting more schedule points does not change the behaviour of the scheduler. The niced app will still get its time.
How many times can an app be preempted? In a non preempt kernel is can be preempted during user mode at timer frequency and no more
Uh, it can be and is preempted in user mode by ANY interrupt, be it keyboard, serial, lan, disc, etc. The kernel looks for need_resched at the end of ALL interrupts, not just the timer interrupt.
Quoted 87 lines
and it cannot be preempted during kernel mode. So
while(1){ read mpeg data process write bitmap }Assuming Andrew does not get too ambitious about read/write granularity, once this process is scheduled on a non-preempt system it will always make progress. The non preempt kernel says, "your kernel request will complete - if we have resources". A preempt kernel says: "well, if nobody more important activates you get some time" Now you do the analysis based on the computation of "goodness" to show that there is a bound on preemption count during an execution of this process. I don't want to have to think that hard.
Let's suppose the Gnome desktop constantly creates and
destroys new fresh i/o bound tasks to do something. So with the old fashioned non preempt (ignoring Andrew) we get
wait no more than 1 second
I'm scheduled and start a read
wait no more than one second
I'm scheduled and in user mode for at least 10milliseconds wait no more than 1 second
I'm scheduled and do my write
...
with preempt we get
wait no more than 1 second
I'm scheduled and start a read
I'm preempted
read not done
come back for 2 microseconds
preempted again
haven't issued the damn read request yet
ok a miracle happens, I finish the read request go to usermode and an interrupt happens
well it would be stupid to have a goodness function in a preempt kernel that lets a low priority task finish its time slice so preempt
...Quoted 10 lines
Quoted 4 lines
So your argument is that I'm advocating Andrew Morton's patch which reduces latencies more than the preempt patch because I have a financial interest in not reducing latencies? Subtle.
Andrew's patch requires constant audition and Andrew can't audit all drivers for possible problems. That doesn't mean Andrew's work is wasted, since it identifies problems, which preempting can't solve, but it will always be a hunt for the worst cases, where preempting goes for the general case.
the preempt requires constant auditing too - and more complex auditing. After all, a missed audit in Andrew will simply increase worst case timing. A missed audit in preempt will hang the system.
Quoted 7 lines
Quoted 4 lines
In any case, motive has no bearing on a technical argument. Your motive could be to make the 68K look better by reducing performance on other processors for all I know.
I am more than busy to keep it running (together with a few others, who are left) and more important I make no money of it.
Come on! First of all, you are causing me a great deal of pain by making me struggle not to make some bad joke about the economics of Linux companies. More important, not making money has nothing to do with purity of motivation - don't you read this list?
And how do I know that you haven't got a stockpile of 68K boards that may be worth big money once it's known that 68K linux is at the top of the heap? Much less plausible money making schemes have been tried.Seriously: for our business, a Linux kernel that can reliably run at millisecond level latencies is only good. If you could get a Linux kernel to run at latencies of 100 microseconds worst case on a 486, I'd be a little more worried but even then ...
On a 800Mhz Athlon, RTLinux scheduling jitter is 17microseconds worst case right now.--
---------------------------------------------------------
Victor Yodaiken
Finite State Machine Labs: The RTLinux Company.
www.fsmlabs.com www.rtlinux.com-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Signature · 3 lines
George [email protected] High-res-timers: http://sourceforge.net/projects/high-res-timers/ Real time sched: http://sourceforge.net/projects/rtsched/
Quoted 10 lines · Robert Love
Quoted 4 lines · J.A. Magallon
Yup. That remind me of...
Would there be any kernel call every driver is doing just to hide there aconditional_schedule()so everyone does it even without knowledge of it ? Just like Apple put theSystemTask()insideGetNextEvent()...It's not nearly that easy. If it were, we would all certainly switch to the preemptive kernel design, and preempt whenever and wherever we needed.
Quoted 5 lines
Instead, we have to worry about reentrancy and thus can not preempt inside critical regions (denoted by spinlocks). So we can't have preempt there, and have more work to do -- thus this discussion.
Robert Love
The real question is: what can get in.
Variants of the explicit scheduling points have been around for over a year, since Ingo's original version. Just a few days ago Marcello once again said that if all the patch does is add scheduling points, he had no intention of integrating it. Linus's opinion on the matter has pretty much been about the same since Ingo's version.
If explicit scheduling points ARE a better first step than preempt (which doesn't necessarily elminate preempt, it just lets us move forward while arguing), when the heck might they possibly appear in a mainline kernel we don't have to manually patch each new release of?
Rob
Quoted 10 lines · george anzinger
Quoted 6 lines
Quoted 3 lines
How is that changed? AFAIK inserting more schedule points does not change the behaviour of the scheduler. The niced app will still get its time.
How many times can an app be preempted? In a non preempt kernel is can be preempted during user mode at timer frequency and no more
Uh, it can be and is preempted in user mode by ANY interrupt, be it keyboard, serial, lan, disc, etc. The kernel looks for
need_reschedat the end of ALL interrupts, not just the timer interrupt.
Ouch.
Quoted 9 lines · Daniel Phillips
Quoted 6 lines · J Sloan
The problem here is that when people report that the low latency patch works better for them than the preempt patch, they aren't talking about bebnchmarking the time to compile a kernel, they are talking about interactive feel and smoothness.
Quoted 4 lines
Nobody is claiming the low latency patch works better than -preempt+lock_break, only that low latency can equal -preempt+lock_break, which is a claim I'm skeptical of, but oh well.
AFAICT Alan Cox et al are saying that low-latency gives better latency than -preempt, but that if lock-break is added to -preempt, the results are basically the same.
IOW lock-break + preempt =~ low-latency as far as the latency question is concerned.
Quoted 11 lines
Quoted 8 lines
I've no agenda other than wanting to see linux as an attractive option for the multimedia and gaming crowds - and in my experience, the low latency patches simply give a much smoother feel and a more pleasant experience. Kernel compilation time is the farthest thing from my mind when e.g. playing Q3A!
You need to read the thread *way* more closely ;-)
Admittedly my observations have been more from an "end-user" point of view, because at the end of the day, what I experience while using Linux as a multimedia/gaming platform is worth more than a barrel of benchmarks - and while kernel compilation time is of interest, it is just _one_ benchmark in the greater scheme of things. (not to mention that that benchmark result could probably be matched in a non -preempt kernel via /proc tuning)
Quoted 8 lines
Quoted 5 lines
I'd be happy to check out the preempt patch again and see if anything's changed, if the problem of tux+preempt oopsing has been dealt with -
Right, useful.
See my previous reply, or the archives -
Regards,
jjs
Quoted 3 lines
Stephan von Krawczynski wrote:
I also checked the tulip driver (which is the one I use at home) and
didn't
Quoted 1 line
find need for "fixing" there. I will definitely take a closer look
at that
Quoted 1 line
driver in future.
Aha, I see, everything as expected...
Quoted 1 line
WLAN drivers seem to need some hacking, but I'm not very interested
in that
Quoted 1 line
area. I think WLAN is one big security hole that noone should be
using...
Uhm, I got hot news: internet is insecure.
Come on, this is really silly, every network is a security problem, not speaking of the guys sitting in front of the screens...
Regards,
Stephan
Quoted 3 lines
Quoted 2 lines · Alan Cox
Quoted 2 lines
Quoted 2 lines
In
eepro100.c,wait_for_cmd_done()can busywait for one
millisecond
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
and is called multiple times under spinlock.
Did I get that right, as long as spinlocked no sense in
conditional_schedule()No conditional schedule, no pre-emption. You would need to rewrite
that
Quoted 1 line
Quoted 1 line
code to do something like try for 100uS then queue a 1 tick timer
to
Quoted 1 line
Quoted 1 line
retry asynchronously. That makes the code vastly more complex for
an
Quoted 1 line
Quoted 1 line
error case and for some drivers where irq mask is required during
reset
Quoted 3 lines
Quoted 1 line
waits won't help.
That
wait_for_cmd_done()and similar functions in other drivers are
called
Quoted 1 line
let's say 3 times in interrupt handler or spinlocked routine and 20
times in
Quoted 3 lines
non-interrupts disabled nor spinlocked functions.
Spinlocked reqions are usually protected by
spin_lock_irqsave().
Now I have really waited for this one: _usually_.
My servers work usually, except for the days they hit that other rather unusual part of the code...
Quoted 6 lines
So the code reads
if (!spin_is_locked(sl)) conditional_schedule();This doesn't make the whole problem go away, but could make the
situation a
Quoted 1 line
little bit better for most of the time?
Time to take out these big hats and rename ourself to Gandalf or the like. What do you expect your server to do, having no problem "most of the time"? Please read Albert E. Time can be pretty relative to your personal point of view...
Regards,
Stephan
Quoted 11 lines · Oliver Neukum
Quoted 4 lines
Well, semaphores block. And we have these races right now with
SCHED_FIFOtasks. I still contend preempt does not change the nature of the problem and it certainly doesn't introduce a new one.But it does:
down(&sem);do_something_that_cannot_block();up(&sem);
Quoted 9 lines
Will stop a
SCHED_FIFOtask for a definite amount of time. Only until it returns from the kernel to user space at worst.If
do_something_that_cannot_block()can be preempted, aSCHED_FIFOtask can block indefinitely long on the semaphore, because you have no guarantee that the scheduler will ever again select the the preempted task. In fact it must never again select the preempted task as long as there's another runnableSCHED_FIFOtask.
This is not true, and if it is is a scheduler bug. When a task (any task) gets preempted it is not moved from the front of its queue, thus, in this case, the FIFO task will still be the fitst task at its prioity to run. Also, it can only be preempted by another real time task of higher priority. Now it is possible that that task may block on the same sem, but this is simple priority inversion and has nothing to do with the sem holder being FIFO, RR or any thing else. In other words preemption does NOT change a FIFO (or any other) task's position in the dispatch queue.
Signature · 3 lines
George [email protected] High-res-timers: http://sourceforge.net/projects/high-res-timers/ Real time sched: http://sourceforge.net/projects/rtsched/
Quoted 11 lines · Daniel Phillips
Quoted 8 lines · On January 14, 2002 10:09 am, [email protected] wrote:
UNIX generally tries to ensure liveness. So you know that
cat lkarchive | grep feel | wc
will complete and not just that, it will run pretty reasonably because for UNIX _every_ process is important and gets cpu and IO time. When you start trying to add special low latency tasks, you endanger liveness. And preempt is especially corrosive because one of the mechanisms UNIX uses to assure liveness is to make sure that once a process starts it can do a significant chunk of work.
If I read this right, your complaint is not with preemption but with scheduler policy. Clearly both are needed to "assure liveness". Another way of looking at preemption is that is enables a more responsive and nimble scheduler policy (afterall it is the scheduler that decided that task A should give way to task B. All preemption does is to allow that to happen with greater dispatch.) Given that, we can then discuss what scheduler policy should be.
Signature · 3 lines
George [email protected] High-res-timers: http://sourceforge.net/projects/high-res-timers/ Real time sched: http://sourceforge.net/projects/rtsched/
Quoted 12 lines · george anzinger
Quoted 10 lines · Daniel Phillips
Quoted 8 lines · On January 14, 2002 10:09 am, [email protected] wrote:
UNIX generally tries to ensure liveness. So you know that
cat lkarchive | grep feel | wc
will complete and not just that, it will run pretty reasonably because for UNIX _every_ process is important and gets cpu and IO time. When you start trying to add special low latency tasks, you endanger liveness. And preempt is especially corrosive because one of the mechanisms UNIX uses to assure liveness is to make sure that once a process starts it can do a significant chunk of work.
Quoted 7 lines
If I read this right, your complaint is not with preemption but with scheduler policy. Clearly both are needed to "assure liveness". Another way of looking at preemption is that is enables a more responsive and nimble scheduler policy (afterall it is the scheduler that decided that task A should give way to task B. All preemption does is to allow that to happen with greater dispatch.) Given that, we can then discuss what scheduler policy should be.
You responded to the wrong person, however I'll take this opportunity to agree with you, on the basis of my years of experience with critical path scheduling. For project schedules 'earlist completion' is the name of the game, within bounds of available resources. When you delay an indvidual 'task' (I'm using the project management term here) past the earliest time it can be scheduled, you are using up its 'float', and if the delay is longer than the task's float, the completion time of the schedule as a whole will be delayed. This is no different for a computer than it is for a group of people, it is still a scheduling problem. Delaying any random task risks delaying the schedule as a whole, and that risk approaches certainty as the number of delays approaches infinity.
N.B.: the above observation is aimed at project managers, who will know exactly what I'm talking about. Otherwise, don't worry if it sounds like so much BS, it actually isn't ;-)
--
Daniel
Quoted 6 lines · [email protected] wrote:
Quoted 4 lines · george anzinger
Quoted 4 lines
Quoted 3 lines
How is that changed? AFAIK inserting more schedule points does not change the behaviour of the scheduler. The niced app will still get its time.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
How many times can an app be preempted? In a non preempt kernel is can be preempted during user mode at timer frequency and no more
Uh, it can be and is preempted in user mode by ANY interrupt, be it keyboard, serial, lan, disc, etc. The kernel looks for
need_reschedat the end of ALL interrupts, not just the timer interrupt.Ouch.
Ouch? It is supposed to be that way. Consider:
A high-priority task issues a disk read - and blocks. Some lower-priority process gets the cpu. But then the disk io finishes way before the low-priority process used up its timeslice. The kernel gets an interrupt from the disk controller because of that. Perhaps the block device issues some more requests, then time comes to return to user space. The higher priority task is now ready to run because its IO completed. So of course it is preferred over that low-priority thing. In other words, the low-priority task got preempted, this time by a disk interrupt.
The same thing happens whan high-priority tasks waits for other kinds of io, such as network, serial, and so on. I am sure you wouldn't want it any other way. Not using the opportunity to switch task immediately after an io completion interrupt would kill latency completely.
Helge Hafting
Quoted 3 lines · george anzinger
Yes, this is classic priority inversion. It is here now, today with semaphors which are held by code that blocks. If the code doesn't block, why not use a spin lock? If it does, well the problem is here
Because eg. other code that holds the semaphore needs to sleep
Quoted 2 lines
now. I suppose we could set a preempt disable around a semaphore if it makes you feel better. It doesn't fix the problem if the task blocks
It would make me feel better, but it would defeat the purpose. There's a lot of code holding semaphores.
Quoted 1 line
AND it is legal to block while holding a preemption lock.
But it's easier to fix. If you can preempt only by explicitely sleeping, you can beat priority invasion by changing basically only wake_up. If you can be preempted at random, you need to know who holds a semaphore.
Regards
Oliver
Quoted 7 lines · Momchil Velikov
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"yodaiken" == yodaiken <[email protected]> writes:
Quoted 3 lines · Momchil Velikov
Quoted 3 lines
One can consider a non-preemptible kernel as a special kind of priority inversion, preemptible kernel will eliminate _that_ case of priority inversion.
Quoted 8 lines
yodaiken> The problem here is that priority means something very different in yodaiken> a time-shared system than in a hard real-time system. And even in real-time yodaiken> systems, as Walpole and colleagues have pointed out, priority doesn't yodaiken> really capture much of what is needed for good scheduling.
Well, maybe there are other policies (notably static scheduling ;), which may be preferrable in one or other case, anyway, I personally tend to think rate-monotonic scheduling is quite adequate in practice.
That's not what we see in real RT applications.
Quoted 2 lines
Of course, anyone is free to prove me wrong by implementing earliest deadline or slack time scheduler in the kernel.
My impression is that these are of limited use in applications.
Quoted 14 lines
yodaiken> In a general purpose system, priorities are dynamic and "fair". yodaiken> The priority of even the lowliest process increases while it waits yodaiken> for time. In a raw real-time system, the low priority process can sit yodaiken> forever and should wait until no higher priority thread needs the yodaiken> processor.
*nod*
yodaiken> So it's absurd to talk of priority inversion in a non RT
yodaiken> system. When a low priority process is delaying a higher priority task yodaiken> for reasons of fairness, increased throughput, or any other valid yodaiken> objective, that is not a scheduling error.
Quoted 4 lines
What is a non real-time system? E.g. are a desktop playing ogg or a server serving multimedia content over ATM, real-time systems? The point is that one can view the system as real-time or not depending on the dominant _current_ load. A system may have real-time load now and
I don't think so, and certainly the straightforward priority based model of traditional RT seems grossly wrong. What's the highest priority process - is it the CD player or is it the niced sendmail that is running in the background? The fact is we require that _both_ make progress. Therefore at some time the sendmail process must have effectively higher priority than the CD player. If we then factor in the many kernel threads that may be running at any time, the calculation becomes even more problematic. In RTLinux we have a much simpler environment and we can use the rule:
The highest priority runnable task should be the running task within some T and the OS gets better as T goes to 0.
If something starves, that's the user problem - our users are programmers who we want to provide with as much control as possible. We certainly do not want to have a situation where the stop command to the robot arm is delayed because the OS needs to run bdflush ...
For Linux, even Linux doing the critical work of playing DVDs, this is not so simple. The target users are not programmers, liveness and responsiveness remain important criteria ...
It's clear that much of the problem when people discuss this issue is lack of clear goals. "Preemption" is a controversial implementation technique, not a goal in itself - I hope. Even "low latency" doesn't really capture the intended goal - "low latency" to do what? If it's simply "low latency" switch to highest priority process, that's not necesarily anything that is going to be useful in itself. The "resource reservation" work at CMU seems to me to be way off the point too. The OGI people have some interesting thoughts about this stuff, but I don't think they've come close to working out a comprehensive model.
What I think we need is a kind of interval real-time scheduling. Something like:
The system has a basic timing period of N milliseconds where N is at lease 500 and probably more.
Over a N millisecond period each process gets a full scheduling quantum and, if it requests, a full I/O quantum.
For a niced process there is some calculated interval greater than N. An I/O quantum should correspond somehow to a rate of I/0.
RTLIMIT is used to set the max number of processes allowed to start and this determines the computation length of "one quantum"
There is this cliche about RT that RT is about deadlines, not speed, but I think that's only partially true. To say that every task will run during a 1 second period with today's PC/Server technology is fundamentally different than to say that every task will run during a 10 millisecond period.
Quoted 4 lines
a non real-time one an hour later, both occasionally intermixed with tasks of the other class. It is unreasonable to say "This system is non-realtime so use that kernel and when you want to play vidoes, please reboot to something else, for example XX-Linux".
Yes, but it's not unreasonable to pop up a window and ask the user if he/she wants to have the scheduling rates of other applications stepped down to run the DVD player.
The Oracle logging server is designed to run at 1 second periods increasing the responsiveness of your current process will reduce that to a 2 second period.
Email delivery will be delayed up to 1 minute
...
YES NO
and so we can follow the most important OS design technique of all time:
push complexity to user space.
---------------------------------------------------------
Victor Yodaiken
Finite State Machine Labs: The RTLinux Company.
www.fsmlabs.com www.rtlinux.com
Quoted 12 lines · george anzinger
Quoted 11 lines · Daniel Phillips
Quoted 8 lines · On January 14, 2002 10:09 am, [email protected] wrote:
UNIX generally tries to ensure liveness. So you know that
cat lkarchive | grep feel | wc
will complete and not just that, it will run pretty reasonably because for UNIX _every_ process is important and gets cpu and IO time. When you start trying to add special low latency tasks, you endanger liveness. And preempt is especially corrosive because one of the mechanisms UNIX uses to assure liveness is to make sure that once a process starts it can do a significant chunk of work.
Quoted 2 lines
If I read this right, your complaint is not with preemption but with scheduler policy. Clearly both are needed to "assure liveness".
You are right: I think however "preemption" is part of a package of ideas about how the system should work. So it would probably be better to separate these issues out
Quoted 5 lines
Another way of looking at preemption is that is enables a more responsive and nimble scheduler policy (afterall it is the scheduler that decided that task A should give way to task B. All preemption does is to allow that to happen with greater dispatch.) Given that, we can then discuss what scheduler policy should be.
If you would write this as
Another way of looking at preemption is that it is intended to enable a more responsive ...
then we would be off to a good start in narrowing the discussion. My reservation about preemption as an implementation technique is that it has costs, which seem to be not easily boundable, but not very clear benefits.
Quoted 4 lines
Signature · 3 lines
George [email protected] High-res-timers: http://sourceforge.net/projects/high-res-timers/ Real time sched: http://sourceforge.net/projects/rtsched/
Signature · 4 lines
--------------------------------------------------------- Victor Yodaiken Finite State Machine Labs: The RTLinux Company. www.fsmlabs.com www.rtlinux.com
Quoted 5 lines · Stephan von Krawczynski
Time to take out these big hats and rename ourself to Gandalf or the like. What do you expect your server to do, having no problem "most of the time"? Please read Albert E. Time can be pretty relative to your personal point of view...
Is this flaming really necessary?
So we don't have care about how long some driver spends in it internal loops? So we could as well start writing drivers like
while (!frame_received()) udelay(1000000);
Because one day we will have powershortage anyway and that will anyway cause few hours latencypeak? And if the user pulls the ethernet plug we don't have to do anything else?
- Jussi Laako
Signature · 2 lines
PGP key fingerprint: 161D 6FED 6A92 39E2 EB5B 39DD A4DE 63EB C216 1E4B Available at PGP keyservers
Quoted 9 lines · Andrew Morton
Quoted 7 lines · Bill Davidsen
Finally, I doubt that any of this will address my biggest problem with Linux, which is that as memory gets cheap a program doing significant disk writing can get buffers VERY full (perhaps a while CD worth) before the kernel decides to do the write, at which point the system becomes non-responsive for seconds at a time while the disk light comes on and stays on.
Quoted 7 lines
/proc/sys/vm/bdflush: Decreasing the kupdate interval from five seconds, decreasing the nfract andnfract_syncsetting in there should smooth this out. The -aa patches add start and stop levels for bdflush as well, which means that bdflush can be the one who blocks on IO rather than your process. And it means that the request queue doesn't get 100% drained as soon as the writer hitsnfract_sync.
Been there, done that. Makes it "less bad" if the right settings are chosen. I will try -aa on 2.4.18-pre3 (or 4 if the patch is out), I've been trying -ac this morning. Looking at the code, it doesn't look as if the logic is what I want to see, no matter how tuned. last night I tried a patch, and several of the "unued" elements in the bdflush were reused, but I froze w/o any io for seconds, so I don't have it right.
What I want is a smooth increase in how mush is written as the dirty buffers increase. Percentage of {anything} may be the wrong thing to use, the problem is dirty buffers vs. disk write bandwidth, on a 2GB machine it's a smaller percentage than 128M machine, but the absolute numbers seem to be similar.
Quoted 5 lines
All very interesting and it will be fun to play with when it *finally* gets merged.
But with the current elevator design, disk read latencies will still be painful.
There are a few patches around to change that. Note I didn't say "fix" just change.
Finally, one of my goals is to be able to keep a large free page pool. I have two apps which will suddenly need another 8MB or so, and if they have to wait for disk they become unpleasant. With current memory prices I don't mind "wasting" 256MB or so, if it means I get better response when I want it. This is all part of tuning the system to application, I certainly wouldn't use it on other machines.
Better doc of bdflush wouldn't be amiss, either. When/if it stops changing I will clean up my notes from a stack of 3x5 cards to something useful and make them available. If there's a doc giving what the bdflush values do (in current kernels) and what happens when you change them, and what to tune first if you have this problem, I haven't found it.
Signature · 3 lines
bill davidsen <[email protected]> CTO, TMR Associates, Inc Doing interesting things with little computers since 1979.
Quoted 8 lines · Bill Davidsen
Finally, I doubt that any of this will address my biggest problem with Linux, which is that as memory gets cheap a program doing significant disk writing can get buffers VERY full (perhaps a while CD worth) before the kernel decides to do the write, at which point the system becomes non-responsive for seconds at a time while the disk light comes on and stays on. That's another problem, and I did play with some patches this weekend without making myself really happy :-( Another topic, unfortunately.
Patience, this is understood, a solution is known and a fix is in the pipeline.
--
Daniel
Quoted 8 lines · Bill Davidsen
Finally, I doubt that any of this will address my biggest problem with Linux, which is that as memory gets cheap a program doing significant disk writing can get buffers VERY full (perhaps a while CD worth) before the kernel decides to do the write, at which point the system becomes non-responsive for seconds at a time while the disk light comes on and stays on. That's another problem, and I did play with some patches this weekend without making myself really happy :-( Another topic, unfortunately.
Patience, this is understood, a solution is known and a fix is in the pipeline.
--
Daniel
Quoted 8 lines · Bill Davidsen
Finally, I doubt that any of this will address my biggest problem with Linux, which is that as memory gets cheap a program doing significant disk writing can get buffers VERY full (perhaps a while CD worth) before the kernel decides to do the write, at which point the system becomes non-responsive for seconds at a time while the disk light comes on and stays on. That's another problem, and I did play with some patches this weekend without making myself really happy :-( Another topic, unfortunately.
Patience, this is understood, a solution is known and a fix is in the pipeline.
--
Daniel
Hi!
Quoted 8 lines
Quoted 4 lines
exhausted...) What sound output device DOESN'T have this much cache? (You mentioned USB speakers in your diary at one point, which seemed to be like those old "paralell port cable plus a few resistors equals sound output" hacks...)
Umm no USB audio is rather good. USB sends isosynchronous, time guaranteed sample streams down the USB bus, to the speakers where the A to D is clear of the machine proper.
Actually usb speakers are *very* sensitive to latency, and when they drop out,they drop out for half a second...
Pavel
Signature · 2 lines
Philips Velo 1: 1"x4"x8", 300gram, 60, 12MB, 40bogomips, linux, mutt, details at http://atrey.karlin.mff.cuni.cz/~pavel/velo/index.html.
Quoted 77 lines · [email protected] wrote:
Quoted 7 lines · Momchil Velikov
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"yodaiken" == yodaiken <[email protected]> writes:
Quoted 3 lines · Momchil Velikov
Quoted 3 lines
One can consider a non-preemptible kernel as a special kind of priority inversion, preemptible kernel will eliminate _that_ case of priority inversion.
Quoted 8 lines
yodaiken> The problem here is that priority means something very different in yodaiken> a time-shared system than in a hard real-time system. And even in real-time yodaiken> systems, as Walpole and colleagues have pointed out, priority doesn't yodaiken> really capture much of what is needed for good scheduling.
Well, maybe there are other policies (notably static scheduling ;), which may be preferrable in one or other case, anyway, I personally tend to think rate-monotonic scheduling is quite adequate in practice.
That's not what we see in real RT applications.
Quoted 2 lines
Of course, anyone is free to prove me wrong by implementing earliest deadline or slack time scheduler in the kernel.
My impression is that these are of limited use in applications.
Quoted 14 lines
yodaiken> In a general purpose system, priorities are dynamic and "fair". yodaiken> The priority of even the lowliest process increases while it waits yodaiken> for time. In a raw real-time system, the low priority process can sit yodaiken> forever and should wait until no higher priority thread needs the yodaiken> processor.
*nod*
yodaiken> So it's absurd to talk of priority inversion in a non RT
yodaiken> system. When a low priority process is delaying a higher priority task yodaiken> for reasons of fairness, increased throughput, or any other valid yodaiken> objective, that is not a scheduling error.Quoted 4 lines
What is a non real-time system? E.g. are a desktop playing ogg or a server serving multimedia content over ATM, real-time systems? The point is that one can view the system as real-time or not depending on the dominant _current_ load. A system may have real-time load now and
I don't think so, and certainly the straightforward priority based model of traditional RT seems grossly wrong. What's the highest priority process - is it the CD player or is it the niced sendmail that is running in the background? The fact is we require that _both_ make progress. Therefore at some time the sendmail process must have effectively higher priority than the CD player. If we then factor in the many kernel threads that may be running at any time, the calculation becomes even more problematic. In RTLinux we have a much simpler environment and we can use the rule:
The highest priority runnable task should be the running task within some T and the OS gets better as T goes to 0.
If something starves, that's the user problem - our users are programmers who we want to provide with as much control as possible. We certainly do not want to have a situation where the stop command to the robot arm is delayed because the OS needs to run bdflush ...For Linux, even Linux doing the critical work of playing DVDs, this is not so simple. The target users are not programmers, liveness and responsiveness remain important criteria ...
It's clear that much of the problem when people discuss this issue is lack of clear goals. "Preemption" is a controversial implementation technique, not a goal in itself - I hope. Even "low latency" doesn't really capture the intended goal - "low latency" to do what? If it's simply "low latency" switch to highest priority process, that's not necesarily anything that is going to be useful in itself. The "resource reservation" work at CMU seems to me to be way off the point too. The OGI people have some interesting thoughts about this stuff, but I don't think they've come close to working out a comprehensive model.What I think we need is a kind of interval real-time scheduling. Something like:
The system has a basic timing period of N milliseconds where N is at lease 500 and probably more.
Quoted 7 lines
Over a N millisecond period each process gets a full scheduling quantum and, if it requests, a full I/O quantum.
For a niced process there is some calculated interval greater than N. An I/O quantum should correspond somehow to a rate of I/0.RTLIMIT is used to set the max number of processes allowed to start and this determines the computation length of "one quantum"
Have you looked at SCHED_SPORADIC (see 1003.1d-1999)?
Quoted 35 lines
There is this cliche about RT that RT is about deadlines, not speed, but I think that's only partially true. To say that every task will run during a 1 second period with today's PC/Server technology is fundamentally different than to say that every task will run during a 10 millisecond period.
Quoted 4 lines
a non real-time one an hour later, both occasionally intermixed with tasks of the other class. It is unreasonable to say "This system is non-realtime so use that kernel and when you want to play vidoes, please reboot to something else, for example XX-Linux".
Yes, but it's not unreasonable to pop up a window and ask the user if he/she wants to have the scheduling rates of other applications stepped down to run the DVD player.
The Oracle logging server is designed to run at 1 second periods increasing the responsiveness of your current process will reduce that to a 2 second period.
Email delivery will be delayed up to 1 minute
...
YES NOand so we can follow the most important OS design technique of all time:
push complexity to user space.---------------------------------------------------------
Victor Yodaiken
Finite State Machine Labs: The RTLinux Company.
www.fsmlabs.com www.rtlinux.com-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Signature · 3 lines
George [email protected] High-res-timers: http://sourceforge.net/projects/high-res-timers/ Real time sched: http://sourceforge.net/projects/rtsched/
Quoted 11 lines · george anzinger
Quoted 10 lines · [email protected] wrote:
What I think we need is a kind of interval real-time scheduling. Something like:
The system has a basic timing period of N milliseconds where N is at lease 500 and probably more.Over a N millisecond period each process gets a full scheduling quantum and, if it requests, a full I/O quantum.
For a niced process there is some calculated interval greater than N. An I/O quantum should correspond somehow to a rate of I/0.
Quoted 4 lines
Quoted 2 lines
RTLIMIT is used to set the max number of processes allowed to start and this determines the computation length of "one quantum"
Have you looked at
SCHED_SPORADIC(see 1003.1d-1999)?
Yes, but I don't think it does much - although its description is quite long and complex.
Preempt & how long it takes to interrupt (was Re: [2.4.17/18pre] VM and swap - it's really unusable)
In reply to Alan CoxHi!
Quoted 5 lines
Quoted 2 lines
I preempt leads to disaster than Linux can't do SMP. Are you saying that's the case?
There is a difference. Preempt have the same locking requirements as SMP, but there's also _timing_ requirements.
...
Quoted 13 lines
Quoted 4 lines
The preempt patch is really "SMP on UP". If pre-empt shows up a problem, then it's a problem SMP users will see too. If we can't take advantage of the existing SMP locking infrastructure to improve latency and interactive feel on UP machines, than SMP for linux DOES NOT WORK.
One example where preempt may break and SMP does not:
Consider driver code. Critical data structures is protected by spinlocks,
but some of the access to the hardware device itself is outside those locks (I can prove that the other processors can't get there with the driver in that state anyway)
Quoted 4 lines
Now, hardware access has timing requirements. That works on SMP because you don't loose the CPU to anything but interrupts, and they are fast. You get it back almost immediately. The device in question times out after a much longer interval.
So... how long do you have to stay in interrupt for it to be a bug?
There's *no* requirement that says "it may not take second to handle an interrupt". Actually I guess that some nasty conditions (UHCI needs reset?) may take that long in interrupt. Oh and actually few releases ago, console switching was done from interrupt and it *did* take 2 seconds for me.
If someone assumes interrupts are "short", he has broken code already.
Pavel
Signature · 2 lines
(about SSSCA) "I don't say this lightly. However, I really think that the U.S. no longer is classifiable as a democracy, but rather as a plutocracy." --hpa
Hi!
Quoted 6 lines
Quoted 3 lines
hardware to hardware could have a higher priority than normal programs being
run. That way they're not preempted by simple programs, it would have to
be purposely preempted by the user.How do you know they are there. How do you detect the situation, or do you plan to audit every driver ?
Any driver which depends on timing is broken. 2.4.9 was happy to spend two seconds in interrupt (console switch). So I doubt too much drivers are broken like that.
And... The drivers were broken already. That is not reason against the patch!
Pavel
Signature · 2 lines
(about SSSCA) "I don't say this lightly. However, I really think that the U.S. no longer is classifiable as a democracy, but rather as a plutocracy." --hpa
Re: Preempt & how long it takes to interrupt (was Re: [2.4.17/18pre] VM and swap - it's really unusable)
In reply to Alan CoxQuoted 9 lines · Pavel Machek
So... how long do you have to stay in interrupt for it to be a bug?
There's *no* requirement that says "it may not take second to handle an interrupt". Actually I guess that some nasty conditions (UHCI needs reset?) may take that long in interrupt. Oh and actually few releases ago, console switching was done from interrupt and it *did* take 2 seconds for me.
If someone assumes interrupts are "short", he has broken code already.
That kinda defeats the entire purpose of low-latency patches, doesn't it?
I'm not entirely certain what Alan's smoking if he's raising the straw man argument of a two second delay dropping 300 packets and causing connections to abort (my sister's on DSL, 5 second dropouts every time the phone rings, but connections continue just fine. Wouldn't want to play quake under those circumstances, but would I really have the ~200 CPU-hog background threads while playing quake as per Alan's example, and even then the argument is just that either the network driver or the network card is bad...)
Still not as bad an example as Aunt Tillie, I'll grant you...
Rob
Re: Preempt & how long it takes to interrupt (was Re: [2.4.17/18pre] VM and swap - it's really unusable)
In reply to Pavel MachekQuoted 9 lines · Pavel Machek
So... how long do you have to stay in interrupt for it to be a bug?
There's *no* requirement that says "it may not take second to handle an interrupt". Actually I guess that some nasty conditions (UHCI needs reset?) may take that long in interrupt. Oh and actually few releases ago, console switching was done from interrupt and it *did* take 2 seconds for me.
If someone assumes interrupts are "short", he has broken code already.
Agreed. Conversely, however, writing code that introduces long interrupt-off periods should be considered a BUG.
In other words, relying on short interrupt-off periods is bad form, but so is writing gross code that rudely keeps them off.
I think we all considered the long off periods in VT switching and fbdev a bug.
Robert Love
Quoted 3 lines · On January 15, 2002 01:39 pm, [email protected] wrote:
My reservation about preemption as an implementation technique is that it has costs, which seem to be not easily boundable, but not very clear benefits.
To me the benefit is clear enough: ASAP scheduling of IO threads, a simple heuristic that improves both throughput and latency.
--
Daniel
Quoted 7 lines · Daniel Phillips
Quoted 3 lines · On January 15, 2002 01:39 pm, [email protected] wrote:
My reservation about preemption as an implementation technique is that it has costs, which seem to be not easily boundable, but not very clear benefits.
To me the benefit is clear enough: ASAP scheduling of IO threads, a simple heuristic that improves both throughput and latency.
I think of "benefit", perhaps naiively, in terms of something that can be measured or demonstrated rather than just announced.
Signature · 4 lines
--------------------------------------------------------- Victor Yodaiken Finite State Machine Labs: The RTLinux Company. www.fsmlabs.com www.rtlinux.com
Quoted 11 lines · On January 21, 2002 04:43 pm, [email protected] wrote:
Quoted 7 lines · Daniel Phillips
Quoted 3 lines · On January 15, 2002 01:39 pm, [email protected] wrote:
My reservation about preemption as an implementation technique is that it has costs, which seem to be not easily boundable, but not very clear benefits.
To me the benefit is clear enough: ASAP scheduling of IO threads, a simple heuristic that improves both throughput and latency.
I think of "benefit", perhaps naiively, in terms of something that can be measured or demonstrated rather than just announced.
But you see why asap scheduling improves latency/throughput *in theory*, don't you? As for the measured benefit, there have been a steady stream of postive reports on lkml. My own experience is that the usability of my laptop with its small memory is much improved under heavy IO load.
--
Daniel
Quoted 4 lines · Daniel Phillips
Quoted 2 lines
I think of "benefit", perhaps naiively, in terms of something that can be measured or demonstrated rather than just announced.
But you see why asap scheduling improves latency/throughput *in theory*,
Nope. And I don't even see a relationship between preemption and asap I/O schedulding. What make you think that I/O threads won't be preempted by other threads?
Quoted 2 lines
don't you? As for the measured benefit, there have been a steady stream of postive reports on lkml.
I have not seen a single well structured benchmark that shows a significant difference. I've seen lots of benchmarks with odd mixes of different patches showing something unknown. How about a simple clear dbench?
Quoted 2 lines
My own experience is that the usability of my
laptop with its small memory is much improved under heavy IO load.
No comment.
Signature · 4 lines
--------------------------------------------------------- Victor Yodaiken Finite State Machine Labs: The RTLinux Company. www.fsmlabs.com www.rtlinux.com
Quoted 11 lines · [email protected] schrieb:
Quoted 4 lines · Daniel Phillips
Quoted 2 lines
I think of "benefit", perhaps naiively, in terms of something that can be measured or demonstrated rather than just announced.
But you see why asap scheduling improves latency/throughput *in theory*,
Nope. And I don't even see a relationship between preemption and asap I/O schedulding. What make you think that I/O threads won't be preempted by other threads?
I/O intensive threads block early voluntarily - while CPU hogs don't. Statistically there is a higher chance, that a CPU hog gets preempted instead of an IO bound (that gives up the CPU in some useconds anyway)
The next IO request is hitting the device "earlier" - instead of waiting for the next schedule() - that makes sense to me.
With this scenario the system CPU utilization gets "bigger" for the benefit of "faster" IO. OTOH, seti@home needs longer to run.
Quoted 9 lines · On January 21, 2002 05:06 pm, [email protected] wrote:
Quoted 4 lines · Daniel Phillips
Quoted 2 lines
I think of "benefit", perhaps naiively, in terms of something that can be measured or demonstrated rather than just announced.
But you see why asap scheduling improves latency/throughput *in theory*,
Nope. And I don't even see a relationship between preemption and asap I/O schedulding. What make you think that I/O threads won't be preempted by other threads?
Consider a thread reading from disk in such a way that readahead is no help, i.e., perhaps the disk is fragmented. At each step the IO thread schedules a read and sleeps until the read completes, then schedules the next one. At the same time there is a hog in the kernel, or perhaps there is competition from other tasks using the kernel. In any event, it will frequently transpire that at the time the disk IO completes there is somebody in the kernel. Without preemption the IO thread has to wait until the kernel hog blocks, hits a scheduling point or exits the kernel.
The result, without preemption, is:
IO thread Kernel hog Disk
| .
|--------------.-----------> .
. | |
. | |
. | |
. | |
. |<------------|
. | .
. | .
. | .
.<-------------| .
|--------------.-----------> .
. . |
. . |
. | |
. | |
. | |
. |<------------|
. | .
. | .
. | .
.<-------------| .
|--------------.-----------> .
. . |
. . |
. | |
. | |
. | |
. |<------------|
. | .
. | .
. | .
.<-------------| .
.
Whereas with preemption, we have:
IO thread Kernel hog Disk
| .
|--------------.-----------> .
. | |
. | |
. | |
. | |
.<-------------|-------------|
|--------------.-----------> .
. | |
. | |
. | |
. | |
.<-------------|-------------|
|--------------.-----------> .
. | |
. | |
. | |
. | |
.<-------------|-------------|
|
The disk and the IO thread are active a higher portion of the time, while the kernel hog gets the same amount of time. So in this case we have improved both latency and throughput.
Naturally I constructed this case to show the effect most clearly. There are many possible variations on the above scenario. It does seem to explain the latency/throughput improvements that have been reported in practice.
--
Daniel