Module Name:    src
Committed By:   knakahara
Date:           Thu Sep 21 11:42:17 UTC 2017

Modified Files:
        src/sys/net: if_loop.c

Log Message:
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


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/sys/net/if_loop.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/net/if_loop.c
diff -u src/sys/net/if_loop.c:1.94 src/sys/net/if_loop.c:1.95
--- src/sys/net/if_loop.c:1.94	Tue Mar 28 08:47:19 2017
+++ src/sys/net/if_loop.c	Thu Sep 21 11:42:17 2017
@@ -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 @@ void
 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 @@ loopinit(void)
 	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);
 }
 

Reply via email to