Source-Changes-HG archive

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

[src/trunk]: src/sys/net loop_clone_create() must be called after ncpu is cou...



details:   https://anonhg.NetBSD.org/src/rev/db292cc16543
branches:  trunk
changeset: 826666:db292cc16543
user:      knakahara <knakahara%NetBSD.org@localhost>
date:      Thu Sep 21 11:42:17 2017 +0000

description:
loop_clone_create() must be called after ncpu is counted up for all CPUs.

loop_clone_create() uses ncpu in the following call-path.
    - loop_clone_create()
      - if_attach()
        - if_percpuq_create()
          - softint_establish() // use ncpu
          - percpu_foreach() // use ncpu

However, loopinit() of built-in module is called from
module_init_class(MODULE_CLASS_DRIVER) which is called before ncpu is counted
up in some architectures. So, It is too fast.
On the other hand, it is too late for rump netinet component to call
loop_clone_create() in config_finalize().

As the result, loop_clone_create() shuld be called in loopattach() for built-in
module, and in loopinit() for dynamic module.

XXX need pullup -8 branch

diffstat:

 sys/net/if_loop.c |  15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diffs (43 lines):

diff -r 8d723402ee9e -r db292cc16543 sys/net/if_loop.c
--- a/sys/net/if_loop.c Thu Sep 21 09:48:15 2017 +0000
+++ b/sys/net/if_loop.c Thu Sep 21 11:42:17 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_loop.c,v 1.94 2017/03/28 08:47:19 ozaki-r Exp $     */
+/*     $NetBSD: if_loop.c,v 1.95 2017/09/21 11:42:17 knakahara Exp $   */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -65,7 +65,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_loop.c,v 1.94 2017/03/28 08:47:19 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_loop.c,v 1.95 2017/09/21 11:42:17 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -146,10 +146,9 @@
 loopattach(int n)
 {
 
-       /*
-        * Nothing to do here, initialization is handled by the
-        * module initialization code in loopnit() below).
-        */
+#ifndef _MODULE
+       loop_clone_create(&loop_cloner, 0);     /* lo0 always exists */
+#endif
 }
 
 void
@@ -159,7 +158,9 @@
        if (lo0ifp != NULL)     /* can happen in rump kernel */
                return;
 
-       (void)loop_clone_create(&loop_cloner, 0);       /* lo0 always exists */
+#ifdef _MODULE
+       loop_clone_create(&loop_cloner, 0);     /* lo0 always exists */
+#endif
        if_clone_attach(&loop_cloner);
 }
 



Home | Main Index | Thread Index | Old Index