From owner-p4-projects@FreeBSD.ORG Tue Jul 17 11:23:14 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 1B27D16A405; Tue, 17 Jul 2007 11:23:14 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C0BB716A403 for ; Tue, 17 Jul 2007 11:23:13 +0000 (UTC) (envelope-from zec@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id B16BC13C48D for ; Tue, 17 Jul 2007 11:23:13 +0000 (UTC) (envelope-from zec@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id l6HBNDes093105 for ; Tue, 17 Jul 2007 11:23:13 GMT (envelope-from zec@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id l6HBNDhT093102 for perforce@freebsd.org; Tue, 17 Jul 2007 11:23:13 GMT (envelope-from zec@FreeBSD.org) Date: Tue, 17 Jul 2007 11:23:13 GMT Message-Id: <200707171123.l6HBNDhT093102@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to zec@FreeBSD.org using -f From: Marko Zec To: Perforce Change Reviews Cc: Subject: PERFORCE change 123637 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Jul 2007 11:23:14 -0000 http://perforce.freebsd.org/chv.cgi?CH=123637 Change 123637 by zec@zec_tca51 on 2007/07/17 11:22:50 When destroying a vnet instance, walk through per-domain protosw instances and call pr_destroy() methods if provided. I should have implemented this already in change 123300... Unlink a vnet instance from the list of all vnets before beginning to detach / free its components. Move the mod_data[] field of struct vnet to its very top, in hope that this would reduce the overhead of dereferencing it. Affected files ... .. //depot/projects/vimage/src/sys/kern/kern_vimage.c#25 edit .. //depot/projects/vimage/src/sys/kern/uipc_domain.c#4 edit .. //depot/projects/vimage/src/sys/sys/vimage.h#22 edit Differences ... ==== //depot/projects/vimage/src/sys/kern/kern_vimage.c#25 (text+ko) ==== @@ -520,6 +520,9 @@ struct ifnet *ifp, *nifp; struct vnet_modlink *vml; + /* XXX should have the vnet list locked here!!! */ + LIST_REMOVE(vnet, vnet_le); + CURVNET_SET_QUIET(vnet); INIT_VNET_NET(vnet); @@ -549,7 +552,8 @@ /* * Detach / free per-module state instances. */ - TAILQ_FOREACH_REVERSE(vml, &vnet_modlink_head, vnet_modlink_head, mod_le) + TAILQ_FOREACH_REVERSE(vml, &vnet_modlink_head, + vnet_modlink_head, mod_le) if (vml->modinfo->i_detach) vml->modinfo->i_detach(vml->iarg); @@ -561,7 +565,6 @@ CURVNET_RESTORE(); /* hopefully, we are finally OK to free the vnet container itself! */ - LIST_REMOVE(vnet, vnet_le); vnet->vnet_magic_n = -1; free(vnet, M_VNET); ==== //depot/projects/vimage/src/sys/kern/uipc_domain.c#4 (text+ko) ==== @@ -68,6 +68,7 @@ NULL) static int net_init_domain(void *); +static int net_detach_domain(void *); static struct callout pffast_callout; static struct callout pfslow_callout; @@ -109,7 +110,8 @@ static struct vnet_modinfo vnet_domain_modinfo = { .id = VNET_MOD_DOMAIN, .name = "domain", - .i_attach = net_init_domain + .i_attach = net_init_domain, + .i_detach = net_detach_domain }; #endif @@ -141,9 +143,7 @@ } /* - * Add a new protocol domain to the list of supported domains - * Note: you cant unload it again because a socket may be using it. - * XXX can't fail at this time. + * Initialize a domain instance. */ static int net_init_domain(void *arg) @@ -166,6 +166,26 @@ } /* + * Detach / free a domain instance. + */ +static int +net_detach_domain(void *arg) +{ + struct domain *dp = arg; + struct protosw *pr; + +#ifdef NOTYET + if (dp->dom_detach) + (*dp->dom_detach)(); +#endif + for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) + if (pr->pr_destroy) + (*pr->pr_destroy)(); + + return 0; +} + +/* * Add a new protocol domain to the list of supported domains * Note: you cant unload it again because a socket may be using it. * XXX can't fail at this time. ==== //depot/projects/vimage/src/sys/sys/vimage.h#22 (text+ko) ==== @@ -101,10 +101,10 @@ #define V_MOD_vprocg 0 struct vnet { + void *mod_data[VNET_MOD_MAX]; + LIST_ENTRY(vnet) vnet_le; - void *mod_data[VNET_MOD_MAX]; - int ifccnt; int sockcnt;