tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kthread with kpause or callout



On Mon, Feb 08, 2010 at 03:04:07PM +0100, Frank Wille wrote:
> I'm just unsure about using mutexes during the callout. I have an
> IPL_NONE-kmutex which locks register access (my chip supports several
> register banks, so I need to make sure they are not switched). May I
> acquire this mutex during a callout (which is a softint, as I understand)?
> Will the softint sleep or busy-wait?

Depends on the mutex type, from mutex(9):

           IPL_NONE, or one of the IPL_SOFT* constants

                 An adaptive mutex will be returned.  Adaptive mutexes provide
                 mutual exclusion between LWPs, and between LWPs and soft
                 interrupt handlers.

                 Adaptive mutexes cannot be acquired from a hardware interrupt
                 handler.  An LWP may either sleep or busy-wait when attempt-
                 ing to acquire an adaptive mutex that is already held.

           IPL_VM, IPL_SCHED, IPL_HIGH

                 A spin mutex will be returned.  Spin mutexes provide mutual
                 exclusion between LWPs, and between LWPs and interrupt han-
                 dlers.


The wording is not explicit, but a softint is not allowed to block on
an adaptive mutex, you need a spin mutex for that (usually such mutexes
are used by interrupt handlers, so you have a "natural" IPL to use
here).

A caller will always busy wait trying to aquire a spin mutex, but it might
fall back to sleep on an adaptive mutex.

Martin


Home | Main Index | Thread Index | Old Index