git: e0a17c3f063f - main - uipc: create dedicated lists for fast and slow timeout callbacks

Kyle Evans kevans at freebsd.org
Wed Aug 18 17:21:27 UTC 2021


On Wed, Aug 18, 2021 at 12:07 PM Mark Johnston <markj at 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 at FreeBSD.org>
> > AuthorDate: 2021-08-15 21:41:47 +0000
> > Commit:     Mateusz Guzik <mjg at 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 at .
> >
> >     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?


More information about the dev-commits-src-all mailing list