From 067e33842f18e9fccc4f4bc4469f2799376d4e1d Mon Sep 17 00:00:00 2001 From: trasz Date: Mon, 14 Sep 2020 10:14:03 +0000 Subject: [PATCH] Move TDP_GEOM check from userret() to ast(); this code path is quite infrequent. Reviewed by: kib No objections: mav Tested by: pho MFC after: 2 weeks Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D26374 --- sys/geom/geom_event.c | 3 +++ sys/kern/subr_trap.c | 14 +++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/sys/geom/geom_event.c b/sys/geom/geom_event.c index e7cef722a32..b829d2ef637 100644 --- a/sys/geom/geom_event.c +++ b/sys/geom/geom_event.c @@ -374,6 +374,9 @@ g_post_event_x(g_event_t *func, void *arg, int flag, int wuflag, struct g_event if (epp != NULL) *epp = ep; curthread->td_pflags |= TDP_GEOM; + thread_lock(curthread); + curthread->td_flags |= TDF_ASTPENDING; + thread_unlock(curthread); return (0); } diff --git a/sys/kern/subr_trap.c b/sys/kern/subr_trap.c index 6b58dd9fc64..a2ebf992a89 100644 --- a/sys/kern/subr_trap.c +++ b/sys/kern/subr_trap.c @@ -137,13 +137,6 @@ userret(struct thread *td, struct trapframe *frame) td_softdep_cleanup(td); MPASS(td->td_su == NULL); - /* - * If this thread tickled GEOM, we need to wait for the giggling to - * stop before we return to userland - */ - if (__predict_false(td->td_pflags & TDP_GEOM)) - g_waitidle(); - /* * Charge system time if profiling. */ @@ -286,6 +279,13 @@ ast(struct trapframe *framep) #endif } + /* + * If this thread tickled GEOM, we need to wait for the giggling to + * stop before we return to userland + */ + if (__predict_false(td->td_pflags & TDP_GEOM)) + g_waitidle(); + #ifdef DIAGNOSTIC if (p->p_numthreads == 1 && (flags & TDF_NEEDSIGCHK) == 0) { PROC_LOCK(p); -- 2.45.0