Source-Changes-HG archive

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

[src/trunk]: src/sys/rump/net/lib/libshmif Fix that rump.ifconfig shmifN dest...



details:   https://anonhg.NetBSD.org/src/rev/d1ae676bd04e
branches:  trunk
changeset: 819902:d1ae676bd04e
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Thu Dec 22 12:55:28 2016 +0000

description:
Fix that rump.ifconfig shmifN destroy hangs up

rump.ifconfig shmifN destroy sometimes hangs up on closing a file
descriptor of kqueue under heavy load. It seems it happens because of
a race condition between closing a fd and kevent to the same fd on
another kthread for packet Rx. Fix it by executing the close operation
after the kthread left.

diffstat:

 sys/rump/net/lib/libshmif/if_shmem.c |  12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diffs (40 lines):

diff -r b61693e108f0 -r d1ae676bd04e sys/rump/net/lib/libshmif/if_shmem.c
--- a/sys/rump/net/lib/libshmif/if_shmem.c      Thu Dec 22 12:55:21 2016 +0000
+++ b/sys/rump/net/lib/libshmif/if_shmem.c      Thu Dec 22 12:55:28 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_shmem.c,v 1.71 2016/12/22 10:13:09 ozaki-r Exp $    */
+/*     $NetBSD: if_shmem.c,v 1.72 2016/12/22 12:55:28 ozaki-r Exp $    */
 
 /*
  * Copyright (c) 2009, 2010 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_shmem.c,v 1.71 2016/12/22 10:13:09 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_shmem.c,v 1.72 2016/12/22 12:55:28 ozaki-r Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -374,7 +374,6 @@
 
        shmif_stop(ifp, 1);
        if_down(ifp);
-       finibackend(sc);
 
        mutex_enter(&sc->sc_mtx);
        sc->sc_dying = true;
@@ -385,6 +384,13 @@
                kthread_join(sc->sc_rcvl);
        sc->sc_rcvl = NULL;
 
+       /*
+        * Need to be called after the kthread left, otherwise closing kqueue
+        * (sc_kq) hangs sometimes perhaps because of a race condition between
+        * close and kevent in the kthread on the kqueue.
+        */
+       finibackend(sc);
+
        vmem_xfree(shmif_units, sc->sc_unit+1, 1);
 
        ether_ifdetach(ifp);



Home | Main Index | Thread Index | Old Index