On 29/10/21(Fri) 13:12, Alexandre Ratchov wrote: > On Sat, Oct 23, 2021 at 10:40:56AM +0100, Martin Pieuchot wrote: > > Diff below switches both poll(2) and select(2) to the kqueue-based > > implementation. > > > > In addition it switches libevent(3) to use poll(2) by default for > > testing purposes. > > > > I don't have any open bug left with this diff and I'm happily running > > GNOME with it. So I'd be happy if you could try to break it and report > > back. > > > > Without the below diff (copied from audio(4) driver), kernel panics > upon the first MIDI input byte.
What is the panic? The mutex is taken recursively, right? > ok? suggestion for a better fix? Without seeing the panic, I'm guessing this is correct. That suggest kevent(2) wasn't safe to use with midi(4). > Index: midi.c > =================================================================== > RCS file: /cvs/src/sys/dev/midi.c,v > retrieving revision 1.48 > diff -u -p -r1.48 midi.c > --- midi.c 25 Dec 2020 12:59:52 -0000 1.48 > +++ midi.c 29 Oct 2021 11:09:47 -0000 > @@ -386,9 +386,11 @@ filt_midiread(struct knote *kn, long hin > struct midi_softc *sc = (struct midi_softc *)kn->kn_hook; > int retval; > > - mtx_enter(&audio_lock); > + if ((hint & NOTE_SUBMIT) == 0) > + mtx_enter(&audio_lock); > retval = !MIDIBUF_ISEMPTY(&sc->inbuf); > - mtx_leave(&audio_lock); > + if ((hint & NOTE_SUBMIT) == 0) > + mtx_leave(&audio_lock); > > return (retval); > } > @@ -409,9 +411,11 @@ filt_midiwrite(struct knote *kn, long hi > struct midi_softc *sc = (struct midi_softc *)kn->kn_hook; > int retval; > > - mtx_enter(&audio_lock); > + if ((hint & NOTE_SUBMIT) == 0) > + mtx_enter(&audio_lock); > retval = !MIDIBUF_ISFULL(&sc->outbuf); > - mtx_leave(&audio_lock); > + if ((hint & NOTE_SUBMIT) == 0) > + mtx_leave(&audio_lock); > > return (retval); > } > >