Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 11 Mar 2003 15:20:55 -0500 (EST)
From:      John Baldwin <jhb@FreeBSD.org>
To:        John Baldwin <jhb@FreeBSD.org>
Cc:        cvs-all@FreeBSD.org, cvs-src@FreeBSD.org, src-committers@FreeBSD.org
Subject:   RE: cvs commit: src/sys/kern subr_eventhandler.c src/sys/sys eve
Message-ID:  <XFMail.20030311152055.jhb@FreeBSD.org>
In-Reply-To: <200303112017.h2BKH0NB073797@repoman.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

On 11-Mar-2003 John Baldwin wrote:
> jhb         2003/03/11 12:17:00 PST
> 
>   FreeBSD src repository
> 
>   Modified files:
>     sys/kern             subr_eventhandler.c 
>     sys/sys              eventhandler.h 
>   Log:
>   Rework the eventhandler locking for hopefully the last time.  The scheme
>   used popped into my head during my morning commute a few weeks ago, but
>   it is also very similar (though a bit simpler) to a patch that mini@
>   developed a while ago.  Basically, each eventhandler list has a mutex and
>   a run count.  During an eventhandler invocation, the mutex is held while
>   we traverse the list but is dropped while we execute actual handlers.  Also,
>   a runcount counter is incremented at the start of an invocation and
>   decremented at the end of an invocation.  Adding to the list is not a big
>   deal since the reference of a thread currently executing the handlers
>   remains valid across an add operation.  Whether or not new handlers are
>   executed by threads currently executing the handlers for a given list is
>   indeterminate however.  The harder case is when a handler is removed from
>   the list.  If the runcount is zero, the handler is simply removed from the
>   list directly.  If the runcount is not zero, then another thread is
>   currently executing the handlers of this list, so the priority of this
>   handler is set to a magic value (currently -1) to mark it as dead.  Dead
>   handlers are not executed during an invocation.  If the runcount is zero
>   after it is decremented at the end of an invocation, then a new
>   eventhandler_prune_list() function is called to remove dead handlers from
>   the list.
>   
>   Additional minor notes:
>   - All the common parts of EVENTHANDLER_INVOKE() and
>     EVENTHANDLER_FAST_INVOKE() have been merged into a common
>     _EVENTHANDLER_INVOKE() macro to reduce duplication and ease maintenance.
>   - KTR logging for eventhandlers is now available via the KTR_EVH mask.
>   - The global eventhander_mutex is no longer recursive.
>   
>   Tested by:      scottl (SMP i386)

I also tested this extensively using a hacked up kernel module that lives
in the smpng p4 tree under modules/evtest.  Unfortunately it's not real
pretty at the moment.  Eventually I plan to generalize it and merge it and
the crash module (another testing module for lock things).  Even then, you
can't script all the tests since the correct behavior for some of them is
to panic. :)

-- 

John Baldwin <jhb@FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve!"  -  http://www.FreeBSD.org/

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-src" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.20030311152055.jhb>