Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Rather than calling xc_barrier() in lwp_dtor(), set...
details: https://anonhg.NetBSD.org/src/rev/f2a523effa0b
branches: trunk
changeset: 1029105:f2a523effa0b
user: thorpej <thorpej%NetBSD.org@localhost>
date: Tue Dec 21 19:00:37 2021 +0000
description:
Rather than calling xc_barrier() in lwp_dtor(), set a pre-destruct hook
on the lwp_cache and invoke the barrier there.
diffstat:
sys/kern/kern_lwp.c | 32 ++++++++++++++++++++------------
1 files changed, 20 insertions(+), 12 deletions(-)
diffs (74 lines):
diff -r 8282ce8b184f -r f2a523effa0b sys/kern/kern_lwp.c
--- a/sys/kern/kern_lwp.c Tue Dec 21 18:59:22 2021 +0000
+++ b/sys/kern/kern_lwp.c Tue Dec 21 19:00:37 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_lwp.c,v 1.244 2021/09/28 15:05:42 thorpej Exp $ */
+/* $NetBSD: kern_lwp.c,v 1.245 2021/12/21 19:00:37 thorpej Exp $ */
/*-
* Copyright (c) 2001, 2006, 2007, 2008, 2009, 2019, 2020
@@ -217,7 +217,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.244 2021/09/28 15:05:42 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.245 2021/12/21 19:00:37 thorpej Exp $");
#include "opt_ddb.h"
#include "opt_lockdebug.h"
@@ -262,6 +262,7 @@
static int lwp_ctor(void *, void *, int);
static void lwp_dtor(void *, void *);
+static void lwp_pre_dtor(void *);
/* DTrace proc provider probes */
SDT_PROVIDER_DEFINE(proc);
@@ -341,6 +342,7 @@
lwpinit_specificdata();
lwp_cache = pool_cache_init(sizeof(lwp_t), MIN_LWP_ALIGNMENT, 0, 0,
"lwppl", NULL, IPL_NONE, lwp_ctor, lwp_dtor, NULL);
+ pool_cache_setpredestruct(lwp_cache, lwp_pre_dtor);
maxlwp = cpu_maxlwp();
sysctl_kern_lwp_setup();
@@ -391,23 +393,29 @@
}
static void
+lwp_pre_dtor(void *arg __unused)
+{
+ /*
+ * Provide a barrier to ensure that all mutex_oncpu() and rw_oncpu()
+ * calls will exit before memory of LWPs is returned to the pool, where
+ * KVA of LWP structure might be freed and re-used for other purposes.
+ * Kernel preemption is disabled around mutex_oncpu() and rw_oncpu()
+ * callers, therefore cross-call to all CPUs will do the job.
+ *
+ * XXX should use epoch based reclamation.
+ */
+ xc_barrier(0);
+}
+
+static void
lwp_dtor(void *arg, void *obj)
{
lwp_t *l = obj;
- (void)l;
/*
- * Provide a barrier to ensure that all mutex_oncpu() and rw_oncpu()
- * calls will exit before memory of LWP is returned to the pool, where
- * KVA of LWP structure might be freed and re-used for other purposes.
- * Kernel preemption is disabled around mutex_oncpu() and rw_oncpu()
- * callers, therefore cross-call to all CPUs will do the job. Also,
- * the value of l->l_cpu must be still valid at this point.
- *
- * XXX should use epoch based reclamation.
+ * The value of l->l_cpu must still be valid at this point.
*/
KASSERT(l->l_cpu != NULL);
- xc_barrier(0);
/*
* We can't return turnstile0 to the pool (it didn't come from it),
Home |
Main Index |
Thread Index |
Old Index