Re: Use of sti in entry.S question

From: Andi Kleen (ak@suse.de)
Date: Thu May 22 2003 - 03:28:33 EST


Duncan Sands <baldrick@wanadoo.fr> writes:

> 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
> # setting need_resched or sigpending
> # between sampling and the iret
> movl TI_FLAGS(%ebp), %ecx
> andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
> # than syscall tracing?
> jz restore_all
> testb $_TIF_NEED_RESCHED, %cl
> jnz work_resched <====== schedule with interrupts disabled
>
> 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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri May 23 2003 - 22:00:48 EST