Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern threadpool(9): Make threadpool_percpu_ref_remote no...
details: https://anonhg.NetBSD.org/src/rev/0b0178087d19
branches: trunk
changeset: 958598:0b0178087d19
user: riastradh <riastradh%NetBSD.org@localhost>
date: Wed Jan 13 02:19:08 2021 +0000
description:
threadpool(9): Make threadpool_percpu_ref_remote non-sleepable.
Needed for threadpool-based workqueue_enqueue to run in interrupt
context.
diffstat:
sys/kern/kern_threadpool.c | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
diffs (37 lines):
diff -r f77903a24565 -r 0b0178087d19 sys/kern/kern_threadpool.c
--- a/sys/kern/kern_threadpool.c Tue Jan 12 21:48:10 2021 +0000
+++ b/sys/kern/kern_threadpool.c Wed Jan 13 02:19:08 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_threadpool.c,v 1.19 2020/09/07 01:08:27 riastradh Exp $ */
+/* $NetBSD: kern_threadpool.c,v 1.20 2021/01/13 02:19:08 riastradh Exp $ */
/*-
* Copyright (c) 2014, 2018 The NetBSD Foundation, Inc.
@@ -81,7 +81,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_threadpool.c,v 1.19 2020/09/07 01:08:27 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_threadpool.c,v 1.20 2021/01/13 02:19:08 riastradh Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -644,10 +644,16 @@
{
struct threadpool **poolp, *pool;
- percpu_traverse_enter();
+ /*
+ * As long as xcalls are blocked -- e.g., by kpreempt_disable
+ * -- the percpu object will not be swapped and destroyed. We
+ * can't write to it, because the data may have already been
+ * moved to a new buffer, but we can safely read from it.
+ */
+ kpreempt_disable();
poolp = percpu_getptr_remote(pool_percpu->tpp_percpu, ci);
pool = *poolp;
- percpu_traverse_exit();
+ kpreempt_enable();
return pool;
}
Home |
Main Index |
Thread Index |
Old Index