From owner-freebsd-virtualization@FreeBSD.ORG Fri Sep 19 18:44:18 2008 Return-Path: Delivered-To: freebsd-virtualization@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7364C106564A for ; Fri, 19 Sep 2008 18:44:18 +0000 (UTC) (envelope-from zec@freebsd.org) Received: from xaqua.tel.fer.hr (xaqua.tel.fer.hr [161.53.19.25]) by mx1.freebsd.org (Postfix) with ESMTP id 04DDE8FC0C for ; Fri, 19 Sep 2008 18:44:12 +0000 (UTC) (envelope-from zec@freebsd.org) Received: by xaqua.tel.fer.hr (Postfix, from userid 20006) id 27F5C9B645; Fri, 19 Sep 2008 20:23:55 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on xaqua.tel.fer.hr X-Spam-Level: X-Spam-Status: No, score=-4.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.7 Received: from [192.168.200.110] (zec2.tel.fer.hr [161.53.19.79]) by xaqua.tel.fer.hr (Postfix) with ESMTP id D5B659B644; Fri, 19 Sep 2008 20:23:53 +0200 (CEST) From: Marko Zec To: Julian Elischer Date: Fri, 19 Sep 2008 20:23:42 +0200 User-Agent: KMail/1.9.7 References: <200809191743.m8JHhZj8009388@repoman.freebsd.org> <48D3E778.3020305@elischer.org> In-Reply-To: <48D3E778.3020305@elischer.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200809192023.42904.zec@freebsd.org> Cc: Perforce Change Reviews , FreeBSD virtualization mailing list Subject: Re: vimage and curvnet. X-BeenThere: freebsd-virtualization@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion of various virtualization techniques FreeBSD supports." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Sep 2008 18:44:18 -0000 On Friday 19 September 2008 19:55:04 Julian Elischer wrote: > Marko Zec wrote: > > http://perforce.freebsd.org/chv.cgi?CH=150125 > > > > Change 150125 by zec@zec_tpx32 on 2008/09/19 17:43:14 > > > > curvnet is never set on entry to sysctl handlers, thus > > set the vnet context via TD_TO_VNET(curthread), because > > all threads must have a cred->vimage->vnet context set. > > it seems to me that vnet is an important enough variable that we ^^^^ I guess you meant curvnet? > could put it in the pcpu structure and have the scheduler set it up > on context switches when vimage is compiled in. Right now curvnet is defined in vimage.h as #define curvnet curthread->td_vnet Note that there's also a helper field in struct thread called td_vnet_lpush aimed at tracing CURVNET_SET() stacking as well as finding places when CURVNET_RESTORE() is not called after CURVNET_SET(). Both td_vnet and td_vnet_lpush _must_ be stored with each thread anyhow, given that threads can migrate practically at any time. So, if pcpu shadowing of curthread->td_vnet could yield performace improvements than this would make sense, but we would still need to keep td_vnet as a field in struct thread, and have CURVNET_SET() and CURVNET_RESTORE() macros atomically update both the td_ field and its pcpu shadow, which would require each CURVNET_XXX() macro to include critical_enter() / _exit() invocations... > thus it would always be directly available. > i.e. %gs:CURVNET_OFFSET or whatever the syntax is on x86 > and the equivalent on other architectures. > > > Affected files ... > > > > .. //depot/projects/vimage-commit2/src/sys/netinet/tcp_subr.c#14 > > edit > > > > Differences ... > > > > ==== //depot/projects/vimage-commit2/src/sys/netinet/tcp_subr.c#14 > > (text+ko) ==== > > > > @@ -119,7 +119,7 @@ > > static int > > sysctl_net_inet_tcp_mss_check(SYSCTL_HANDLER_ARGS) > > { > > - INIT_VNET_INET(curvnet); > > + INIT_VNET_INET(TD_TO_VNET(curthread)); > > int error, new; > > > > new = V_tcp_mssdflt; > > @@ -141,7 +141,7 @@ > > static int > > sysctl_net_inet_tcp_mss_v6_check(SYSCTL_HANDLER_ARGS) > > { > > - INIT_VNET_INET6(curvnet); > > + INIT_VNET_INET6(TD_TO_VNET(curthread)); > > int error, new; > > > > new = V_tcp_v6mssdflt;