From owner-dev-commits-src-all@freebsd.org Mon Aug 23 12:34:33 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 B9B63669FE7; Mon, 23 Aug 2021 12:34:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (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 "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GtWs54rBDz3JyM; Mon, 23 Aug 2021 12:34:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8E39F143DF; Mon, 23 Aug 2021 12:34:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17NCYXAN023195; Mon, 23 Aug 2021 12:34:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17NCYXgJ023194; Mon, 23 Aug 2021 12:34:33 GMT (envelope-from git) Date: Mon, 23 Aug 2021 12:34:33 GMT Message-Id: <202108231234.17NCYXgJ023194@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: 9134711fb5b7 - stable/13 - uipc: avoid circular pr_{slow, fast}timos MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 9134711fb5b70effb53bbdc21c79fe3b0c8a67cc Auto-Submitted: auto-generated 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: Mon, 23 Aug 2021 12:34:33 -0000 The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=9134711fb5b70effb53bbdc21c79fe3b0c8a67cc commit 9134711fb5b70effb53bbdc21c79fe3b0c8a67cc Author: Kyle Evans AuthorDate: 2021-08-18 17:31:45 +0000 Commit: Mateusz Guzik CommitDate: 2021-08-23 12:33:32 +0000 uipc: avoid circular pr_{slow,fast}timos domain_init() gets reinvoked for each vnet on a system, so we must not alter global state. Practically speaking, we were creating circular lists and tying up a softclock thread into an infinite loop. The breakage here was most easily observed by simply creating a jail in a new vnet and watching the system suddenly become erratic. Reported by: markj Fixes: e0a17c3f063f ("uipc: create dedicated lists for fast ...") Pointy hat: kevans (cherry picked from commit d7e1bdfebacc4de25dc51e14a91d66bb429677c9) --- sys/kern/uipc_domain.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/sys/kern/uipc_domain.c b/sys/kern/uipc_domain.c index 76c0364f6824..4342f1026783 100644 --- a/sys/kern/uipc_domain.c +++ b/sys/kern/uipc_domain.c @@ -186,12 +186,23 @@ domain_init(void *arg) (*dp->dom_init)(); 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); + + /* + * Note that with VIMAGE enabled, domain_init() will be + * re-invoked for each new vnet that's created. The below lists + * are intended to be system-wide, so avoid altering global + * state for non-default vnets. + */ + if (IS_DEFAULT_VNET(curvnet)) { + 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); + } } /*