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
This commit is contained in:
knakahara 2017-09-21 11:42:17 +00:00
parent 9cd884509f
commit 5d0cdef5b4
1 changed files with 8 additions and 7 deletions

View File

@ -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);
}