V_ prefixes on variable names?v or VOP prefixes from vnode(9) oder VFS(9) with these.V_ prefix is/was needed to distinguish the the (former) globals from their virtualized counterparts so that a macro could be used to switch between variants. Moreover, while the majority (but not all) of the former globals could have been in fact directly converted to macros without the V_ prefix prepended, the V_ prefix helps to instantly differentiate between true globals and virtualized variables when reading the code.V_ macros do exactly?V_ macros will resolve the variable to either a global, a member of a global container struct or a member of a container struct hanging off of a virtual image.INET, INET6, IPSEC, gif(4), … .V_ macros, etc., like: sys/net/vnet.hsys/netinet/vinet.hsys/netinet6/vinet6.hsys/net/if_gif.hsys/netgraph/netgraph.hsys/netipsec/ipsec.hsys/netinet/ip_fw.h#ifdef VIMAGE_GLOBALS) will be removed from the source tree and only the container structs will be kept. We will try to get rid of the globals as soon as possible as for now it means that developers need to mainain all virtualized variables in two places.vimage like:struct vimage *vimage /* The vimage */
struct vnet *v_net /* The virtualize network stack. */
void *mod_data[n] /* The different subsystem types like INET, INET6, GIF, ... */
Obviously lower levels might be cached somewhere else to not always need the full indirections from *vimage.
In case virtualization is compiled out, there will always be only a single instance of a container struct for each subsystem type. Those are globals then, like:
#ifndef VIMAGE struct vnet_inet vnet_inet_0; struct vnet_ipfw vnet_ipfw_0; struct vnet_netgraph vnet_netgraph_0; struct vnet_gif vnet_gif_0; ... #endif
(obviously not under a single #ifndef but each of the globals in the file close(st) to the subsystem they represent).
#include spamming on unrelated parts of the network stack and modules.#ifdef VIMAGE_GLOBALS block eventually get completely removed.vnet_ipfw_0 for example, just being a pointer *vnet_ipfw from one of the running virtualized instances. The base pointers are usually taken from a cached copy of the struct vnet *v_net pointer. Else we would possibly have to go through various stages of indirection for each variable access.INET, INET6 and IPSEC for example. Adding too many types will mean lots of local base variables and it might no longer be able to have them all in registers, etc. which would hurt performance. That said we may want to rethink some of the distribution of variables into different types in the future.V_CPU or V_PROCG for now. There is experimental code in Perforce but it will not be comitted to SVN (for now).