tech-kern archive

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

Re: mutexes, IPL, tty locking

On Thu, Oct 22, 2009 at 12:32:12PM +0100, Mindaugas Rasiukevicius wrote:
> David Laight <> wrote:
> > >      9  mutex_exit(&alldevs_mtx);
> > >     10  /* I expect for IPL to be max(x, IPL_VM) */
> > >     11  ttysleep(...);  /* panic: cpu_switchto: switching above IPL_SCHED
> > > (8) */ 12  mutex_exit(&tty_lock);
> > >     13  /* I expect for IPL to be x */
> > 
> > Hmmm.... I wonder where the old IPL is saved ?
> > (I've not looked to see!)
> > 
> > But the locking scheme ought to support releasing locks in other
> > that strict reverse order of acquisition. Which rather makes
> > saving the old IPL anywhere other than in the callers stack frame
> > rather difficult.
> IPL is only being raised and that works in reference counting principle.
> Therefore IPL is lowered (and only to IPL_NONE) after the last release,
> see ci_mtx_oldspl and ci_mtx_count.  Which means that order of releases
> does not matter.  Gradual IPL lowering would unnecessary complicate the
> implementation or interface.
> Forcing lower IPL with explicit splx() call should work, but that would
> be a hack.  While our tty locking should be revamped, the question here
> is probably - why alldevs_mtx needs IPL_HIGH?

alldevs_mtx will synchronize access to alldevs by both threads and
interrupts, especially interrupts indicating device disconnection
(unplugging FireWire/CardBus/PCMCIA/USB) or bus exceptions (PCI aborts),
which I want to handle at a high priority.

What I really want to know is:

> Is it more reasonable for the kernel to expect the driver output      
> routine to restore the IPL, or to expect the tty routines such as     
> ttywait() to save and restore the IPL across calls to the output      
> routine?                                                              

Yesterday, I thought that it was more reasonable for the tty routines to
save & restore the IPL.  Today, I think that the driver should save &
restore the IPL.  What do you think?


David Young             OJC Technologies      Urbana, IL * (217) 278-3933

Home | Main Index | Thread Index | Old Index