From 5d0cdef5b472b746d1064ac123e45c1ec7145ec8 Mon Sep 17 00:00:00 2001 From: knakahara Date: Thu, 21 Sep 2017 11:42:17 +0000 Subject: [PATCH] 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 --- sys/net/if_loop.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c index 70a69e71a764..b3805ddf42de 100644 --- a/sys/net/if_loop.c +++ b/sys/net/if_loop.c @@ -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 -__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); }