aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Motin <mav@FreeBSD.org>2022-01-28 19:12:29 +0000
committerAlexander Motin <mav@FreeBSD.org>2022-01-28 19:21:21 +0000
commitffc1cc95e78ec05a3e1a0aed869e33a44d9f6641 (patch)
tree4af7b04e719c42eb3a74197180c484ab15f50c5f
parent964b8f8b993d48f66a3d3b46a4cd67c1f6d1e326 (diff)
downloadsrc-ffc1cc95e78ec05a3e1a0aed869e33a44d9f6641.tar.gz
src-ffc1cc95e78ec05a3e1a0aed869e33a44d9f6641.zip
GEOM: Relax direct dispatch for GEOM threads.
The only cases when direct dispatch does not make sense is for I/O submission from down thread and for completion from up thread. In all other cases, if both consumer and producer are OK about it, we can save on context switches. MFC after: 2 weeks
-rw-r--r--sys/geom/geom_int.h2
-rw-r--r--sys/geom/geom_io.c4
-rw-r--r--sys/geom/geom_kern.c4
3 files changed, 6 insertions, 4 deletions
diff --git a/sys/geom/geom_int.h b/sys/geom/geom_int.h
index 9f2a011b23f0..67c46d715885 100644
--- a/sys/geom/geom_int.h
+++ b/sys/geom/geom_int.h
@@ -69,6 +69,8 @@ void g_io_schedule_up(struct thread *tp);
/* geom_kern.c / geom_kernsim.c */
void g_init(void);
+extern struct thread *g_up_td;
+extern struct thread *g_down_td;
extern int g_shutdown;
extern int g_notaste;
diff --git a/sys/geom/geom_io.c b/sys/geom/geom_io.c
index a5cb8c7279e4..e893793ec385 100644
--- a/sys/geom/geom_io.c
+++ b/sys/geom/geom_io.c
@@ -561,7 +561,7 @@ g_io_request(struct bio *bp, struct g_consumer *cp)
direct = (cp->flags & G_CF_DIRECT_SEND) != 0 &&
(pp->flags & G_PF_DIRECT_RECEIVE) != 0 &&
- !g_is_geom_thread(curthread) &&
+ curthread != g_down_td &&
((pp->flags & G_PF_ACCEPT_UNMAPPED) != 0 ||
(bp->bio_flags & BIO_UNMAPPED) == 0 || THREAD_CAN_SLEEP()) &&
pace == 0;
@@ -653,7 +653,7 @@ g_io_deliver(struct bio *bp, int error)
direct = (pp->flags & G_PF_DIRECT_SEND) &&
(cp->flags & G_CF_DIRECT_RECEIVE) &&
- !g_is_geom_thread(curthread);
+ curthread != g_up_td;
if (direct) {
/* Block direct execution if less then half of stack left. */
size_t st, su;
diff --git a/sys/geom/geom_kern.c b/sys/geom/geom_kern.c
index 4b7219591dce..429bd7a05a4b 100644
--- a/sys/geom/geom_kern.c
+++ b/sys/geom/geom_kern.c
@@ -61,8 +61,8 @@ MALLOC_DEFINE(M_GEOM, "GEOM", "Geom data structures");
struct sx topology_lock;
static struct proc *g_proc;
-static struct thread __read_mostly *g_up_td;
-static struct thread __read_mostly *g_down_td;
+struct thread __read_mostly *g_up_td;
+struct thread __read_mostly *g_down_td;
static struct thread __read_mostly *g_event_td;
int __read_mostly g_debugflags;