From owner-dev-commits-src-all@freebsd.org Wed Aug 18 17:21:27 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7A783653227; Wed, 18 Aug 2021 17:21:27 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GqZSR31Vqz4pDp; Wed, 18 Aug 2021 17:21:27 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from mail-qv1-f43.google.com (mail-qv1-f43.google.com [209.85.219.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) (Authenticated sender: kevans) by smtp.freebsd.org (Postfix) with ESMTPSA id 491572CA18; Wed, 18 Aug 2021 17:21:27 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: by mail-qv1-f43.google.com with SMTP id dt3so2061643qvb.6; Wed, 18 Aug 2021 10:21:27 -0700 (PDT) X-Gm-Message-State: AOAM533+NsppPVUSHhKmXKPWh/rRpgUHEt6KwG8zCOcIcrGgJ/e5erSg xDm8W4pCIq0Q+FJH8t9V+mSjICmJm/i7Ka2LkwU= X-Google-Smtp-Source: ABdhPJy9yfAQgfZCgWKqDNr4G6kPGOGRduzYLpWVpRJw6Bd3uUJ2HJvQCoRojlXeFaVBIpyrBO88MV7YkASvTKyFNLY= X-Received: by 2002:a05:6214:892:: with SMTP id cz18mr10023416qvb.60.1629307286791; Wed, 18 Aug 2021 10:21:26 -0700 (PDT) MIME-Version: 1.0 References: <202108171959.17HJx16Z069832@gitrepo.freebsd.org> In-Reply-To: From: Kyle Evans Date: Wed, 18 Aug 2021 12:21:13 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: git: e0a17c3f063f - main - uipc: create dedicated lists for fast and slow timeout callbacks To: Mark Johnston Cc: Mateusz Guzik , src-committers , "" , dev-commits-src-main@freebsd.org Content-Type: text/plain; charset="UTF-8" X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Aug 2021 17:21:27 -0000 On Wed, Aug 18, 2021 at 12:07 PM Mark Johnston 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 > > AuthorDate: 2021-08-15 21:41:47 +0000 > > Commit: Mateusz Guzik > > 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 > > #include > > #include > > +#include > > #include > > #include > > > > @@ -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?