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
This commit is contained in:
Alexander Motin 2022-01-28 14:12:29 -05:00
parent 964b8f8b99
commit ffc1cc95e7
3 changed files with 6 additions and 4 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;