I don't know if this acceptable but definitely can be done,
> I prefer to rely on fact than on API.
Yes, of course anything CAN be done, but then they would be SOL with the
movement of the flag location (as was done on the way from 2.3 to
2.4.0). If we encounter such problems, we just fix them.
> Regarding local_irq_enabled(). How do you handle the code that
> call local_irq_disable(), then spin_lock(), spin_unlock() and only
> re-enable the interruptions ?
Good question, as this is exactly what spin_lock_irq()/spin_unlock_irq()
do. In this case it is not a problem as the intent was the same anyway,
but we can fix the code to handle this. If you read the patch, you will
find that we call preempt_schedule() which calls schedule(). We could
easily put a test of the interrupt off state here and reject the
preemption. The real issue here is how to catch the preemption when
local_irq_enable() is called. If the system has an interrupt dedicated
to scheduling we could use this, however, while this is available in SMP
systems it is usually not available in UP systems.
On the other hand I have not seen any code do this. I have, however,
seen code that:
spin_lock_irq()
:
local_irq_enable()
:
spin_unlock()
We would rather not mess with the preemption count while irq is disabled
but this sort of code messes up the pairing we need to make this work.
> In this case, you preempt code that
> is supposed to run interruptions disabled.
> Finally, regarding the test on the task state, there may be a cache issue
> but calling schedule() has also some overhead.
>
I am not sure what you are getting at here. The task state will be
looked at by schedule() in short order in any case so a cache miss is
not the issue. We don't look at the state but on the way to schedule()
(in preempt_schedule()) we add a flag to the state to indicate that it
is a preemption call. schedule() is then changed to treat this task as
running, regardless of the state.
George
> Ludo.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/