Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 8 May 2009 20:36:10 GMT
From:      Marko Zec <zec@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 161790 for review
Message-ID:  <200905082036.n48KaAgb005790@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=161790

Change 161790 by zec@zec_tpx32 on 2009/05/08 20:36:01

	Allocate memory for vimage structs in vi_alloc() which can
	be called via the mgmt API on multiple instances, instead of
	directly in vi_init(), which is called only once by SYSINIT
	framework.

Affected files ...

.. //depot/projects/vimage-commit2/src/sys/kern/kern_vimage.c#33 edit

Differences ...

==== //depot/projects/vimage-commit2/src/sys/kern/kern_vimage.c#33 (text+ko) ====

@@ -589,7 +589,7 @@
 		void *mem = malloc(vmi->vmi_size, M_VNET,
 		    M_NOWAIT | M_ZERO);
 		if (mem == NULL) /* XXX should return error, not panic. */
-			panic("vi_alloc: malloc for %s\n", vmi->vmi_name);
+			panic("malloc for %s\n", vmi->vmi_name);
 		curvnet->mod_data[vmi->vmi_id] = mem;
 	}
 #endif
@@ -736,11 +736,6 @@
 static void
 vi_init(void *unused)
 {
-#ifdef VIMAGE
-	struct vimage *vip;
-	struct vprocg *vprocg;
-	struct vnet *vnet;
-#endif
 
 	TAILQ_INIT(&vnet_modlink_head);
 	TAILQ_INIT(&vnet_modpending_head);
@@ -750,26 +745,14 @@
 	LIST_INIT(&vprocg_head);
 	LIST_INIT(&vnet_head);
 
-	vip = malloc(sizeof(struct vimage), M_VIMAGE, M_NOWAIT | M_ZERO);
-	if (vip == NULL)
-		panic("malloc failed for struct vimage");
-	LIST_INSERT_HEAD(&vimage_head, vip, vi_le);
+	mtx_init(&vnet_list_refc_mtx, "vnet_list_refc_mtx", NULL, MTX_DEF);
+	cv_init(&vnet_list_condvar, "vnet_list_condvar");
 
-	vprocg = malloc(sizeof(struct vprocg), M_VPROCG, M_NOWAIT | M_ZERO);
-	if (vprocg == NULL)
-		panic("malloc failed for struct vprocg");
-	vip->v_procg = vprocg;
-	LIST_INSERT_HEAD(&vprocg_head, vprocg, vprocg_le);
-
-	vnet = malloc(sizeof(struct vnet), M_VNET, M_NOWAIT | M_ZERO);
-	if (vnet == NULL)
-		panic("vi_alloc: malloc failed");
-	LIST_INSERT_HEAD(&vnet_head, vnet, vnet_le);
-	vnet->vnet_magic_n = VNET_MAGIC_N;
-	vip->v_net = vnet;
+	/* Default image has no parent and no name. */
+	vi_alloc(NULL, "");
 
 	/*
-	 * We MUST clear curvnet in vi_init_done before going SMP,
+	 * We MUST clear curvnet in vi_init_done() before going SMP,
 	 * otherwise CURVNET_SET() macros would scream about unnecessary
 	 * curvnet recursions.
 	 */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200905082036.n48KaAgb005790>