From owner-svn-src-head@freebsd.org Mon Oct 9 11:47:47 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A1DB4E2DCB1; Mon, 9 Oct 2017 11:47:47 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-qt0-x229.google.com (mail-qt0-x229.google.com [IPv6:2607:f8b0:400d:c0d::229]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 13732678F9; Mon, 9 Oct 2017 11:47:47 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-qt0-x229.google.com with SMTP id p1so5119778qtg.2; Mon, 09 Oct 2017 04:47:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=sizWMiZ/5L81S5G2VMX94ofubsQDK9tZVGi5DFVlNOE=; b=S6sNnrVGljANA56DFP53QPrtfncNAnx06XX6RMa66YuC8r5jF6DJymClJyViBVlVYU Ha3lY6uJ3u/e69/zxOisMV3btImqLnU4F9C1N1wtxI55eTK2s0QO7EGWCd81HSZCMruF nhoLRK+vimiKj0VvAvhDWrFevbii9bkarPnT8zMgO89lQp8n1ymK5ny0jJJ07PUMrmVI PCa2DOM3AvKcng4QkDaYI46h2X9Un0pmqgAz4dKHrfc296hP844jp4L7OFaMVERZTPRw Jk3tOxyzazxA108fTNdQgPHtdPzCqTVgA3zKmt6wuv1DXrH19qOm9D4MwmyePvYizg2/ FE0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=sizWMiZ/5L81S5G2VMX94ofubsQDK9tZVGi5DFVlNOE=; b=uhEL/YZYRajEM3WWNRTvOwTdTEKf3Ldg07dUmsmE2v9QuY97KY2nw/kwk1qms8daBa Yker+YWNSzxmIHh+pkTs4P/Ha7WvYuPwKizCelgw2u2KrHKv+WmrWISKcWTNiK8ko5nw awwNzwFoyWZoSsr5NXrxZaA6mo6KpOxVDVeokqGlmY7fXAN0EI3h7WrvleSy4aKI7127 /1G3Dk0wlWrd+AI1Oy/9ptw6pa8tDxu1ahd+yA4uhfqTm+Cuc9ZRJyeGR2V39wmtgSoc ZVnNMxOgHyF2rPoJ7dymKIJ8LF1ZRwz+/azH0On9M7axj2fMzYVsSwnTIbxXmnOboWqs oIpw== X-Gm-Message-State: AMCzsaUp6T7tSrX5YPLdAXB8fxeKVYFV8v8Jw4FT0ME5BYM6jyOwOvji wOlSSpw/B+LieNXCUm2xUaCtqko+er82KTXOZF/Jrw== X-Google-Smtp-Source: AOwi7QCzPt3+Is44XGV4sob9/S5oCHM8NKFNJnm7Zkwmv4MXJIvblzVFHzhuJLY535eUnW5HSWM9Z5DuJte9uy0pnIM= X-Received: by 10.200.27.221 with SMTP id m29mr2457294qtk.152.1507549665824; Mon, 09 Oct 2017 04:47:45 -0700 (PDT) MIME-Version: 1.0 Received: by 10.237.46.33 with HTTP; Mon, 9 Oct 2017 04:47:45 -0700 (PDT) In-Reply-To: <1507485390.86205.323.camel@freebsd.org> References: <201710081733.v98HXnu1094645@repo.freebsd.org> <1507485390.86205.323.camel@freebsd.org> From: Mateusz Guzik Date: Mon, 9 Oct 2017 13:47:45 +0200 Message-ID: Subject: Re: svn commit: r324415 - in head/sys: kern sys To: Ian Lepore Cc: "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Oct 2017 11:47:47 -0000 On Sun, Oct 08, 2017 at 11:56:30AM -0600, Ian Lepore wrote: > On Sun, 2017-10-08 at 17:33 +0000, Ian Lepore wrote: > > Author: ian > > Date: Sun Oct 8 17:33:49 2017 > > New Revision: 324415 > > URL: https://svnweb.freebsd.org/changeset/base/324415 > > > > Log: > > Add eventhandler notifications for newbus device attach/detach. > > > > [...] > > > > A couple salient comments from the review, they amount to some helpful > > documentation about these events, but there's currently no good place for > > such documentation... > > About this last point... sys/eventhandler.h is now an ever-growing list > of EVENTHANDLER_DECLARE() statements for events that are unrelated to > each other. I think we are at the point where it's no longer a few > well-known "standard system event queues", it's turning into a mess. > > My first thought was to add these to bus.h because they're bus events. > But you have to include eventhandler.h to use EVENTHANDLER_DECLARE, > and I didn't want to pull it (and its dependencies) into bus.h. > The current implementation has to be retired and significant tinkering with it is imho a waste of time. It is weirdly inefficient both single and multithreaded. Vast majority (if not all) lists are statically defined. And yet invocing the handlers starts with following a linked list and strcmping to find the instance. All this under a global eventhanadler lock which starts showing up. Most registered handlers for any paritcular event are never going to get unregistered. The current code locks the list do the traversal, which again is slow and starts showing up in lock profiles. So the proposal is to partially unscrew the current code so that it largely gets out of the way and then implement something new and migrate evertyhing on head to use it. A new set of eventhnadler declarations can be added (_STATIC?) which provides a known at compilation time symbol. Then a paired invocation macro to just lock the handler list without the need to look it up. As for the new mechanism, I don't have anything fleshed out, but in general it would do away with excessive macro use. handlers which once registered never get removed get a lockless treatment for traveral. say they also get implemented as a linked list. Invocations would do a lockless traversal of the list. If there is an entry, it is fully installed and never goes away. Registrations would lock the list and add an entry in traversal-friendly manner updating the '->next' pointer at the lsat step. Later this can be made even nicer with a table, but that will require a little bit of trickery to make it freeable. With this in place there will be no central "here are the handlers" header. That said, I have no immediate plans working on this, but I'll eventually get around to it unless someone beats me or has a better idea. -- Mateusz Guzik