Use of sti in entry.S question
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 17 lines · Duncan Sands
2.5/arch/i386/kernel/entry.S:In
work_resched, schedule may be called with
interrupts off:
work_resched:
call schedule
cli # make sure we don't miss an interrupt
# settingneed_reschedor sigpending # between sampling and the iret
movlTI_FLAGS(%ebp), %ecx
andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
# than syscall tracing?
jzrestore_all
testb $_TIF_NEED_RESCHED, %cl
jnzwork_resched<====== schedule with interrupts disabled
Quoted 2 lines
Is this a mistake or an optimization? Elsewhere in
entry.S, interrupts are turned on before calling schedule:
It's a mistake, but a harmless one. The scheduler turns off interrupts soon itself and the instructions it executes before that don't care. The only reason it's not recommended to call schedule with interrupts off is that the scheduler will turn them on again, usually breaking your critical section. In this case it's ok because the next instrution is a cli again.
-Andi
...
Quoted 9 lines
Quoted 2 lines
Is this a mistake or an optimization? Elsewhere in
entry.S, interrupts are turned on before calling schedule:It's a mistake, but a harmless one. The scheduler turns off interrupts soon itself and the instructions it executes before that don't care. The only reason it's not recommended to call schedule with interrupts off is that the scheduler will turn them on again, usually breaking your critical section. In this case it's ok because the next instrution is a cli again.
Do you think it's worth pushing this fix?
arch/i386/kernel/entry.S +1 -0
@@ -306,6 +306,7 @@ testb $_TIF_NEED_RESCHED, %cl jz work_notifysig work_resched: + sti call schedule cli # make sure we don't miss an interrupt # setting need_resched or sigpending