Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/xen/xen Release mutexes earlier in xenevt_free(), t...



details:   https://anonhg.NetBSD.org/src/rev/8e217b7385f2
branches:  trunk
changeset: 369854:8e217b7385f2
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Sun Sep 04 11:20:33 2022 +0000

description:
Release mutexes earlier in xenevt_free(), to call *destroy and kmem_free
without holding spin locks. Fixes an occasional deadlock seen when the qemu
backing a HVM domU exits.

diffstat:

 sys/arch/xen/xen/xenevt.c |  13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diffs (58 lines):

diff -r fecd1ecd0500 -r 8e217b7385f2 sys/arch/xen/xen/xenevt.c
--- a/sys/arch/xen/xen/xenevt.c Sun Sep 04 10:20:33 2022 +0000
+++ b/sys/arch/xen/xen/xenevt.c Sun Sep 04 11:20:33 2022 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: xenevt.c,v 1.65 2022/05/27 18:35:38 bouyer Exp $      */
+/*      $NetBSD: xenevt.c,v 1.66 2022/09/04 11:20:33 bouyer Exp $      */
 
 /*
  * Copyright (c) 2005 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xenevt.c,v 1.65 2022/05/27 18:35:38 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xenevt.c,v 1.66 2022/09/04 11:20:33 bouyer Exp $");
 
 #include "opt_xen.h"
 #include <sys/param.h>
@@ -278,8 +278,7 @@
                d->pending = false;
                mutex_enter(&d->lock);
                if (d->flags & XENEVT_F_FREE) {
-                       xenevt_free(d);
-                       mutex_exit(&devevent_lock);
+                       xenevt_free(d); /* releases devevent_lock */
                } else {
                        mutex_exit(&devevent_lock);
                        selnotify(&d->sel, 0, 1);
@@ -402,7 +401,6 @@
                        hypervisor_mask_event(i);
                        xen_atomic_clear_bit(&d->ci->ci_evtmask[0], i);
                        devevent[i] = NULL;
-
                        op.cmd = EVTCHNOP_close;
                        op.u.close.port = i;
                        if ((error = HYPERVISOR_event_channel_op(&op))) {
@@ -412,6 +410,7 @@
                }
        }
        mutex_exit(&d->lock);
+       mutex_exit(&devevent_lock);
        seldestroy(&d->sel);
        cv_destroy(&d->cv);
        mutex_destroy(&d->lock);
@@ -428,11 +427,11 @@
        if (d->pending) {
                d->flags |= XENEVT_F_FREE;
                mutex_exit(&d->lock);
+               mutex_exit(&devevent_lock);
        } else {
-               xenevt_free(d);
+               xenevt_free(d); /* releases devevent_lock */
        }
 
-       mutex_exit(&devevent_lock);
        fp->f_data = NULL;
        return (0);
 }



Home | Main Index | Thread Index | Old Index