[Fwd: lost need_resched flag re-introduced?]
I did not get reply from Linus. Now try my luck with the kernel mailing list. Please cc your reply to my email account. I stopped watching the mailing list anymore.
Thanks.
Jun
Quoted 32 lines · Jun Sun
Linus,
A while back I reported the lost
need_reschedflag bug ( it happens ifneed_reschedis set right beforeswitch_to()is called). Later on a one-line fix is added to__schedule_tail().current->need_resched |= prev->need_resched;I looked at the latest kernel and found this one is gone. Is the lost
need_reschedproblem taken care of in some other way? Or is it re-introduced?In any case, I was going to propose a minor fix over the original one-line fix. See the patch below.
On RISC machines, the original fix leaves a small window for setting the wrong flag. A pseudo assembly code for the original fix is shown as follows:
1. load
current->need_reschedto R1
2. loadprev->need_reschedto R2
3. R1 = R1 | R2
4. store R1 tocurrent->need_reschedIf at 1) both
need_reschedflags are 0, and an interrupt happens between 1) and 4), which setscurrent->reschedto 1, we will have wrong result forcurrent->need_reschedafter step 4).Jun
inux/kernel/sched.c: 1.1 1.2 jsun 00/10/31 10:22:44 (modified, needs delta)
Review line 463
Quoted 10 lines
(quoted diff) +3
-1@@ -455,7 +455,9 @@ */ static inline void __schedule_tail(struct task_struct *prev) { - current->need_resched |= prev->need_resched; + if (prev->need_resched) { + current->need_resched = 1; + } #ifdef CONFIG_SMP if ((prev->state == TASK_RUNNING) && (prev != idle_task(smp_processor_id()))) {
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
Hello!
Quoted 8 lines
Quoted 8 lines
A while back I reported the lost
need_reschedflag bug ( it happens ifneed_reschedis set right beforeswitch_to()is called). Later on a one-line fix is added to__schedule_tail().current->need_resched |= prev->need_resched;I looked at the latest kernel and found this one is gone. Is the lost
need_reschedproblem taken care of in some other way? Or is it re-introduced?
It is removed not only because it was wrong (which you have found too), but because it was useless even if copied correctly.
current->need_resched is not changed in interrupt context outside runqueue lock except for scheduler timer, where copying results in nothing but spurious reschedule.
Alexey
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
Quoted 12 lines · [email protected] wrote:
Hello!
Quoted 8 lines
Quoted 8 lines
A while back I reported the lost
need_reschedflag bug ( it happens ifneed_reschedis set right beforeswitch_to()is called). Later on a one-line fix is added to__schedule_tail().current->need_resched |= prev->need_resched;I looked at the latest kernel and found this one is gone. Is the lost
need_reschedproblem taken care of in some other way? Or is it re-introduced?
Quoted 8 lines
It is removed not only because it was wrong (which you have found too), but because it was useless even if copied correctly.
current->need_reschedis not changed in interrupt context outside runqueue lock except for scheduler timer, where copying results in nothing but spurious reschedule.Alexey
Alexey,
I think wake_up_process() is called in interrupt routine quite often and it will set need_resched flag (through reschedule_idle()). ???
I did several run time tests and confirmed the missing need_resched flag was happening. Ether some new code takes care of it. Or it is still there.
Jun
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
Hello!
Quoted 2 lines
I think
wake_up_process()is called in interrupt routine quite often and it will setneed_reschedflag (throughreschedule_idle()). ???
It sets _right_ flag cpu_curr(this_cpu)->need_resched, rather than current->need_resched.
Quoted 1 line
happening. Ether some new code takes care of it. Or it is still there.
? 8)
Alexey
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/