preemptible kernel
Andi, thank you for the background! More comments interspersed...
Quoted 17 lines · Paul McKenney
Quoted 3 lines
1. On a busy system, isn't it possible for a preempted task
to stay preempted for a -long- time, especially if there are lots of real-time tasks in the mix?The problem you're describing is probably considered too hard to solve properly (bad answer, but that is how it is currently)
Yes there is. You can also force a normal (non preemptive) kernel into complete livelock by just giving it enough network traffic to do, so that it always works in the high priority network softirq or doing the same with some other interrupt.
Just when this happens a lot of basic things will stop working (like page cleaning, IO flushing etc.), so your callbacks or module unloads not running are probably the least of your worries.
Quoted 7 lines
The same problem applies to a smaller scale to real time processes; kernel services normally do not run real-time, so they can be starved.
Priority inversion is not handled in Linux kernel ATM BTW, there are already situations where a realtime task can cause a deadlock with some lower priority system thread (I believe there is at least one case of this known with realtime ntpd on 2.4)
I see your point here, but need to think about it. One question:
isn't it the case that the alternative to using synchronize_kernel() is to protect the read side with explicit locks, which will themselves suppress preemption? If so, why not just suppress preemption on the read side in preemptible kernels, and thus gain the simpler implementation of synchronize_kernel()? You are not losing any preemption latency compared to a kernel that uses traditional locks, in fact, you should improve latency a bit since the lock operations are more expensive than are simple increments and decrements. As usual, what am I missing here? ;-)
Quoted 6 lines
Quoted 3 lines
2. Isn't it possible to get in trouble even on a UP if a task
is preempted in a critical region? For example, suppose the preempting task does asynchronize_kernel()?Ugly. I guess one way to solve it would be to readd the 2.2 scheduler taskqueue, and just queue a scheduler callback in this case.
Another approach would be to define a "really low" priority that noone other than synchronize_kernel() was allowed to use. Then the UP implementation of synchronize_kernel() could drop its priority to this level, yield the CPU, and know that all preempted tasks must have obtained and voluntarily yielded the CPU before synchronize_kernel() gets it back again.
I still prefer suppressing preemption on the read side, though I suppose one could claim that this is only because I am -really- used to it. ;-)
Thanx, Paul
In message <OF37B0793C.6B15F182-ON88256A27.0007C3EF@LocalDomain> you write:
Quoted 5 lines
Quoted 4 lines
Priority inversion is not handled in Linux kernel ATM BTW, there are already situations where a realtime task can cause a deadlock with some lower priority system thread (I believe there is at least one case of this known with realtime ntpd on 2.4)
Quoted 10 lines
I see your point here, but need to think about it. One question:
isn't it the case that the alternative to usingsynchronize_kernel()is to protect the read side with explicit locks, which will themselves suppress preemption? If so, why not just suppress preemption on the read side in preemptible kernels, and thus gain the simpler implementation ofsynchronize_kernel()? You are not losing any preemption latency compared to a kernel that uses traditional locks, in fact, you should improve latency a bit since the lock operations are more expensive than are simple increments and decrements. As usual, what am I missing here? ;-)
Already preempted tasks.
Quoted 6 lines
Another approach would be to define a "really low" priority that noone other than
synchronize_kernel()was allowed to use. Then the UP implementation ofsynchronize_kernel()could drop its priority to this level, yield the CPU, and know that all preempted tasks must have obtained and voluntarily yielded the CPU beforesynchronize_kernel()gets it back again.
Or "never", because I'm running RC5 etc. 8(.
Rusty.
--
Premature optmztion is rt of all evl. --DK
Quoted 10 lines · Paul McKenney
I see your point here, but need to think about it. One question:
isn't it the case that the alternative to usingsynchronize_kernel()is to protect the read side with explicit locks, which will themselves suppress preemption? If so, why not just suppress preemption on the read side in preemptible kernels, and thus gain the simpler implementation ofsynchronize_kernel()? You are not losing any preemption latency compared to a kernel that uses traditional locks, in fact, you should improve latency a bit since the lock operations are more expensive than are simple increments and decrements. As usual, what am I missing here? ;-)
You miss nothing I think. In fact it's already used (see below)
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
2. Isn't it possible to get in trouble even on a UP if a task
is preempted in a critical region? For example, suppose the preempting task does asynchronize_kernel()?Ugly. I guess one way to solve it would be to readd the 2.2 scheduler taskqueue, and just queue a scheduler callback in this case.
Quoted 6 lines
Another approach would be to define a "really low" priority that noone other than
synchronize_kernel()was allowed to use. Then the UP implementation ofsynchronize_kernel()could drop its priority to this level, yield the CPU, and know that all preempted tasks must have obtained and voluntarily yielded the CPU beforesynchronize_kernel()gets it back again.
That just would allow nasty starvation, e.g. when someone runs a cpu intensive screensaver or a seti-at-home.
Quoted 4 lines
I still prefer suppressing preemption on the read side, though I suppose one could claim that this is only because I am -really- used to it. ;-)
For a lot of reader cases non-preemption by threads is guaranteed anyways -- e.g. anything that runs in interrupts, timers, tasklets and network softirq. I think that already covers a lot of interesting cases.
-Andi