Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 Aug 2021 12:21:13 -0500
From:      Kyle Evans <kevans@freebsd.org>
To:        Mark Johnston <markj@freebsd.org>
Cc:        Mateusz Guzik <mjg@freebsd.org>, src-committers <src-committers@freebsd.org>,  "<dev-commits-src-all@freebsd.org>" <dev-commits-src-all@freebsd.org>, dev-commits-src-main@freebsd.org
Subject:   Re: git: e0a17c3f063f - main - uipc: create dedicated lists for fast and slow timeout callbacks
Message-ID:  <CACNAnaE24xEZFF6EkUs8%2Bd-_BsxJ5JYE-nj4bGibTgie_JR5Qg@mail.gmail.com>
In-Reply-To: <YR0%2BRbxtskHV0uu6@nuc>
References:  <202108171959.17HJx16Z069832@gitrepo.freebsd.org> <YR0%2BRbxtskHV0uu6@nuc>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Aug 18, 2021 at 12:07 PM Mark Johnston <markj@freebsd.org> wrote:
>
> On Tue, Aug 17, 2021 at 07:59:01PM +0000, Mateusz Guzik wrote:
> > The branch main has been updated by mjg:
> >
> > URL: https://cgit.FreeBSD.org/src/commit/?id=e0a17c3f063fd51430fb2b4f5bc667f79d2967c2
> >
> > commit e0a17c3f063fd51430fb2b4f5bc667f79d2967c2
> > Author:     Mateusz Guzik <mjg@FreeBSD.org>
> > AuthorDate: 2021-08-15 21:41:47 +0000
> > Commit:     Mateusz Guzik <mjg@FreeBSD.org>
> > CommitDate: 2021-08-17 19:56:05 +0000
> >
> >     uipc: create dedicated lists for fast and slow timeout callbacks
> >
> >     This avoids having to walk all possible protocols only to check if they
> >     have one (vast majority does not).
> >
> >     Original patch by kevans@.
> >
> >     Reviewed by:    kevans
> >     Sponsored by:   Rubicon Communications, LLC ("Netgate")
> > ---
> >  sys/kern/uipc_domain.c | 59 +++++++++++++++++++++++++++++++++++---------------
> >  sys/sys/protosw.h      |  4 ++++
> >  2 files changed, 46 insertions(+), 17 deletions(-)
> >
> > diff --git a/sys/kern/uipc_domain.c b/sys/kern/uipc_domain.c
> > index b6aefec9556a..0946a2a75326 100644
> > --- a/sys/kern/uipc_domain.c
> > +++ b/sys/kern/uipc_domain.c
> > @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$");
> >  #include <sys/kernel.h>
> >  #include <sys/lock.h>
> >  #include <sys/mutex.h>
> > +#include <sys/rmlock.h>
> >  #include <sys/socketvar.h>
> >  #include <sys/systm.h>
> >
> > @@ -76,6 +77,14 @@ static struct callout pfslow_callout;
> >  static void  pffasttimo(void *);
> >  static void  pfslowtimo(void *);
> >
> > +static struct rmlock pftimo_lock;
> > +RM_SYSINIT(pftimo_lock, &pftimo_lock, "pftimo");
> > +
> > +static LIST_HEAD(, protosw) pffast_list =
> > +    LIST_HEAD_INITIALIZER(pffast_list);
> > +static LIST_HEAD(, protosw) pfslow_list =
> > +    LIST_HEAD_INITIALIZER(pfslow_list);
> > +
> >  struct domain *domains;              /* registered protocol domains */
> >  int domain_init_status = 0;
> >  static struct mtx dom_mtx;           /* domain list lock */
> > @@ -183,8 +192,16 @@ domain_init(void *arg)
> >           ("Premature initialization of domain in non-default vnet"));
> >       if (dp->dom_init)
> >               (*dp->dom_init)();
> > -     for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
> > +     for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) {
> >               protosw_init(pr);
> > +             rm_wlock(&pftimo_lock);
> > +             if (pr->pr_fasttimo != NULL)
> > +                     LIST_INSERT_HEAD(&pffast_list, pr, pr_fasttimos);
> > +             if (pr->pr_slowtimo != NULL)
> > +                     LIST_INSERT_HEAD(&pfslow_list, pr, pr_slowtimos);
> > +             rm_wunlock(&pftimo_lock);
>
> I think this is wrong for VNETs: each time a VNET is created,
> vnet_domain_init() calls domain_init() and re-inserts the callbacks into
> the global list.  This results in a circular list, so a softclock thread
> just invokes callbacks in an infinite loop.
>

The latest version I have locally gated this segment behind
IS_DEFAULT_VNET(curvnet), but it appears that I hadn't updated the
previous review and forgot about it... I'll fix it?



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CACNAnaE24xEZFF6EkUs8%2Bd-_BsxJ5JYE-nj4bGibTgie_JR5Qg>