Re: cli() / sti()

Linus Torvalds (torvalds@transmeta.com)
19 Jun 1997 21:45:01 GMT


In article <m0wenxS-0005FeC@lightning.swansea.linux.org.uk>,
Alan Cox <alan@lxorguk.ukuu.org.uk> wrote:
>> In ioctl part start_bh_atomic/end_bh_atomic is good replacement.
>> In transmitter just delete them. hard_start_xmit's are serialized
>> by top layer at the moment.
>
>Are you sure. As it stands at the moment a hard_start_xmit from a user
>context can be interrupted by a timer_bh hard_start_xmit

No Alan, Alexey is right. The "hard_start_xmit()" itself is protected
by a "start_bh_atomic()"/"end_bh_atomic()" pair, so it cannot be
interrupted by any other bh (timer or network). This guarantees the
non-re-entrancy of the network drivers (although lots of drivers still
have the cruft from back when this wasn't true).

Of course, the actual device driver often has to protect itself from its
own hardware interrupts (to serialize access to the device registers),
so deep down in the driver it may often need a cli/sti pair. But it
doesn't need to protect itself from being called by the rest of the kernel.

Linus