Source-Changes-HG archive

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

[src/trunk]: src/sys/net Add curlwp_bind



details:   https://anonhg.NetBSD.org/src/rev/da364a5e34d5
branches:  trunk
changeset: 821069:da364a5e34d5
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Mon Jan 23 02:30:47 2017 +0000

description:
Add curlwp_bind

It is necessary for example when we use tun(4). Without it the following
panic occurs:

  panic: kernel diagnostic assertion "(kpreempt_disabled() || cpu_softintr_p() || ISSET(curlwp->l_pflag, LP_BOUND))" failed: file "/usr/src/sys/kern/subr_psref.c", line 291 passive references are 
CPU-local, but preemption is enabled and the caller is not in a softint or CPU-bound LWP
  Backtrace:
  vpanic()
  ch_voltag_convert_in()
  psref_release()
  pfil_run_arg.isra.0()
  if_initialize()
  if_attach()
  tun_clone_create()
  tunopen()
  cdev_open()
  spec_open()
  VOP_OPEN()
  vn_open()
  do_open()
  do_sys_openat()
  sys_open()
  syscall()

diffstat:

 sys/net/pfil.c |  12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diffs (62 lines):

diff -r bd920bd44641 -r da364a5e34d5 sys/net/pfil.c
--- a/sys/net/pfil.c    Mon Jan 23 00:30:51 2017 +0000
+++ b/sys/net/pfil.c    Mon Jan 23 02:30:47 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pfil.c,v 1.32 2017/01/16 09:28:40 ryo Exp $    */
+/*     $NetBSD: pfil.c,v 1.33 2017/01/23 02:30:47 ozaki-r Exp $        */
 
 /*
  * Copyright (c) 2013 Mindaugas Rasiukevicius <rmind at NetBSD org>
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pfil.c,v 1.32 2017/01/16 09:28:40 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pfil.c,v 1.33 2017/01/23 02:30:47 ozaki-r Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -384,7 +384,7 @@
        pfil_listset_t *phlistset;
        pfil_list_t *phlist;
        struct psref psref;
-       int s;
+       int s, bound;
        int ret = 0;
 
        KASSERT(dir == PFIL_IN || dir == PFIL_OUT);
@@ -392,6 +392,7 @@
                return ret;
        }
 
+       bound = curlwp_bind();
        s = pserialize_read_enter();
        phlist = phlistset->active;
        membar_datadep_consumer();
@@ -406,6 +407,7 @@
                        break;
        }
        psref_release(&psref, &phlist->psref, pfil_psref_class);
+       curlwp_bindx(bound);
 
        if (mp) {
                *mp = m;
@@ -418,8 +420,9 @@
 {
        pfil_list_t *phlist;
        struct psref psref;
-       int s;
+       int s, bound;
 
+       bound = curlwp_bind();
        s = pserialize_read_enter();
        phlist = phlistset->active;
        membar_datadep_consumer();
@@ -431,6 +434,7 @@
                (*func)(pfh->pfil_arg, cmd, arg);
        }
        psref_release(&psref, &phlist->psref, pfil_psref_class);
+       curlwp_bindx(bound);
 }
 
 void



Home | Main Index | Thread Index | Old Index