git: d7e1bdfebacc - main - uipc: avoid circular pr_{slow,fast}timos
Kyle Evans
kevans at FreeBSD.org
Wed Aug 18 17:54:01 UTC 2021
The branch main has been updated by kevans:
URL: https://cgit.FreeBSD.org/src/commit/?id=d7e1bdfebacc4de25dc51e14a91d66bb429677c9
commit d7e1bdfebacc4de25dc51e14a91d66bb429677c9
Author: Kyle Evans <kevans at FreeBSD.org>
AuthorDate: 2021-08-18 17:31:45 +0000
Commit: Kyle Evans <kevans at FreeBSD.org>
CommitDate: 2021-08-18 17:46:54 +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
---
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 0946a2a75326..d572e0ec19db 100644
--- a/sys/kern/uipc_domain.c
+++ b/sys/kern/uipc_domain.c
@@ -194,12 +194,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);
+ }
}
/*
More information about the dev-commits-src-all
mailing list