This is in the spirit of the long-dead _FAST eventhandlers that were
removed in r126466. The existing eventhandler code is entirely dynamic
in that it is safe to, for example, register a handler for a
non-existent eventhandler lists. In order to achieve this eventhandler
lists are added to a global list which is synchronized by a global
mutex. When handlers are triggered via EVENTHANDLER_INVOKE a locked
search of this list is done to find the appropriate list. Most, if not
all,ntroduces a facility to EVENTHANDLER(9) for explicitly defining a reference to an event handler list. of the eventhandler lists do not require being dynamic in this
fashion,This is useful since previously all invokers of events had to do a locked traversal of the global list of event handler lists in order to find the appropriate event handler list. as it is possibleBy keeping a pointer to statically define the list with the
invokersthe appropriate list an invoker can avoid this traversal completely. This allows the _INVOKE path to avoid a locked search of a
global linked list,The pointer is initialized with SYSINIT(9) during the eventhandler stage. and instead execute the handlers onUsers registering interest in events do not need to know if the specific
list directly.event is backed by such a list, Tsince the list must simply be available (i.eis added to the global list of lists as normal. linkable) from
As with lists that are not pre-defined it is safe to register for the events before the invokerlist has been created.
To convert a list to being static it must be declared with
EVENTHANDLER_STATIC_DECLARE, it must be defined in the appropriate
compilation unit with EVENTHANDLER_STATIC_DEFINE, and the invoker must
be changed to EVENTHANDLER_STATIC_INVOKE. EVENTHANDLER_STATIC_DEFINE has
the additional duty of using SYSINIT(9) to add the statically-defined
list to the global eventhandler list. This is done for simplicity, and
it allows all eventhandlers to be registered with EVENTHANDLER_REGISTER
regardless of whether the list is defined statically or not. There is
no need to optimize this call as it is relatively infrequent.
This commit also converts the various proc_* and thread_* eventhandler
lists to being static. These eventhandler lists cause a lot of
unnecessary cycles spent waiting on the global eventhandler lock in
certain process and thread-heavy workloads (e.g.his converts the process_* and thread_* events to using the new facility, bulk ports builds).
Adding reviewers I think might be interested,as these are events whose traversals end up showing up significantly in ports build workflows. feel freeIt may be advantageous to convert other events to suggest
othersusing the new facility as well.