Re: down_trylock doesn't preserve irqstate

From: David S. Miller (davem@redhat.com)
Date: Sat Feb 26 2000 - 17:16:45 EST


   Date: Sat, 26 Feb 2000 23:09:30 +0100
   From: almesber@lrc.di.epfl.ch

   Hmm, so sleep_on() no longer preserves cli/sti ? I knew sleep_on()
   was deprecated, but not that it was broken ... (the ATM code still
   has quite a few of them)

If it sleeps, no it does not preserve global cli/sti on SMP. It
preserves local cpu interrupt state only.

When you need to have global IRQs disabled while testing a sleep
state, you should use the wait queues properly, ala:

    add_wait_queue(...);
    save_flags(flags);
    cli();
    while(1) {
            if (condition_met())
                break;
        if (signal_pending(...))
                break;
        ... etc. ...
        restore_flags(flags);
        schedule();
        cli();
    }
    restore_flags(flags);
    remove_wait_queue(...);

This gives you precisely what you want, and guarentees that you
won't miss any wake events.

Even better, change your global cli to be real spin lock protection.

I really would like to see global cli removed from all spots where it
is not absolutely necessary (ATM is networking, so you have no excuse
here :-).

The only one subsystem which has an excuse to use global cli() is the
tty layer and drivers, but once that is threaded those cases can go
too. If we keep to this, soon enough global CLI can just die a
painless death.

Later,
David S. Miller
davem@redhat.com

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Feb 29 2000 - 21:00:15 EST