Date: Wed, 6 May 2009 16:41:31 GMT From: Marko Zec <zec@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 161658 for review Message-ID: <200905061641.n46GfVVr087629@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=161658 Change 161658 by zec@zec_tpx32 on 2009/05/06 16:40:30 Unbreak options VIMAGE build. Affected files ... .. //depot/projects/vimage/src/sys/kern/kern_sysctl.c#22 edit .. //depot/projects/vimage/src/sys/kern/kern_vimage.c#88 edit .. //depot/projects/vimage/src/sys/netinet/in_rmx.c#34 edit .. //depot/projects/vimage/src/sys/sys/sysctl.h#35 edit .. //depot/projects/vimage/src/sys/sys/vimage.h#92 edit Differences ... ==== //depot/projects/vimage/src/sys/kern/kern_sysctl.c#22 (text+ko) ==== ==== //depot/projects/vimage/src/sys/kern/kern_vimage.c#88 (text+ko) ==== @@ -60,7 +60,6 @@ MALLOC_DEFINE(M_VIMAGE, "vimage", "vimage resource container"); MALLOC_DEFINE(M_VNET, "vnet", "network stack control block"); MALLOC_DEFINE(M_VPROCG, "vprocg", "process group control block"); -MALLOC_DEFINE(M_VCPU, "vcpu", "cpu resource control block"); #ifdef VIMAGE static struct vimage *vi_alloc(struct vimage *, char *); @@ -80,10 +79,6 @@ static int vnet_mod_constructor(struct vnet_modlink *); static int vnet_mod_destructor(struct vnet_modlink *); -#ifdef VIMAGE -struct vnet_list_head vnet_head; -#endif - void vnet_mod_register(const struct vnet_modinfo *vmi) { @@ -319,14 +314,11 @@ struct vimage_list_head vimage_head; struct vnet_list_head vnet_head; struct vprocg_list_head vprocg_head; -struct vcpu_list_head vcpu_head; struct cv vnet_list_condvar; struct mtx vnet_list_refc_mtx; int vnet_list_refc = 0; -struct mtx vcpu_list_mtx; - #define VNET_LIST_LOCK() \ mtx_lock(&vnet_list_refc_mtx); \ while (vnet_list_refc != 0) \ @@ -338,7 +330,6 @@ static u_int last_vi_id = 0; static u_int last_vnet_id = 0; static u_int last_vprocg_id = 0; -static u_int last_vcpu_id = 0; struct vimage * vnet2vimage(struct vnet *vnet) @@ -628,7 +619,6 @@ vi_req->vi_proc_count = vip_r->v_procg->nprocs; vi_req->vi_if_count = vip_r->v_net->ifccnt; vi_req->vi_sock_count = vip_r->v_net->sockcnt; - vi_req->cp_time_avg = vip_r->v_cpu->_avg2_fixp; break; case SIOCSPVIMAGE: @@ -700,7 +690,6 @@ struct vimage *vip; struct vnet *vnet; struct vprocg *vprocg; - struct vcpu *vcpu; struct vnet_modlink *vml; /* @@ -740,12 +729,6 @@ vip->v_procg = vprocg; vprocg->vprocg_id = last_vprocg_id++; - vcpu = malloc(sizeof(struct vcpu), M_VCPU, M_NOWAIT | M_ZERO); - if (vcpu == NULL) - panic ("vi_alloc: malloc failed for vcpu \"%s\"\n", name); - vip->v_cpu = vcpu; - vcpu->vcpu_id = last_vcpu_id++; - /* Initialize / attach vnet module instances. */ CURVNET_SET_QUIET(vnet); TAILQ_FOREACH(vml, &vnet_modlink_head, vml_mod_le) @@ -759,10 +742,6 @@ /* XXX locking */ LIST_INSERT_HEAD(&vprocg_head, vprocg, vprocg_le); - mtx_lock_spin(&vcpu_list_mtx); - LIST_INSERT_HEAD(&vcpu_head, vcpu, vcpu_le); - mtx_unlock_spin(&vcpu_list_mtx); - vi_alloc_done: return (vip); } @@ -778,7 +757,6 @@ { struct vnet *vnet = vip->v_net; struct vprocg *vprocg = vip->v_procg; - struct vcpu *vcpu = vip->v_cpu; struct ifnet *ifp, *nifp; struct vnet_modlink *vml; @@ -804,10 +782,6 @@ /* XXX locking */ LIST_REMOVE(vprocg, vprocg_le); - mtx_lock_spin(&vcpu_list_mtx); - LIST_REMOVE(vcpu, vcpu_le); - mtx_unlock_spin(&vcpu_list_mtx); - VNET_LIST_LOCK(); LIST_REMOVE(vnet, vnet_le); VNET_LIST_UNLOCK(); @@ -842,7 +816,6 @@ vnet->vnet_magic_n = 0xdeadbeef; free(vnet, M_VNET); free(vprocg, M_VPROCG); - free(vcpu, M_VCPU); free(vip, M_VIMAGE); return (0); @@ -853,9 +826,6 @@ static void vi_init(void *unused) { -#ifdef VIMAGE - struct vnet *vnet; -#endif TAILQ_INIT(&vnet_modlink_head); TAILQ_INIT(&vnet_modpending_head); @@ -864,13 +834,10 @@ LIST_INIT(&vimage_head); LIST_INIT(&vnet_head); LIST_INIT(&vprocg_head); - LIST_INIT(&vcpu_head); mtx_init(&vnet_list_refc_mtx, "vnet_list_refc_mtx", NULL, MTX_DEF); cv_init(&vnet_list_condvar, "vnet_list_condvar"); - mtx_init(&vcpu_list_mtx, "vcpu_list_mtx", NULL, MTX_SPIN); - vi_alloc(NULL, ""); /* Default vimage has no name */ /* We MUST clear curvnet in vi_init_done before going SMP. */ ==== //depot/projects/vimage/src/sys/netinet/in_rmx.c#34 (text+ko) ==== @@ -251,8 +251,7 @@ static void in_rtqtimo_one(struct radix_node_head *rnh) { - CURVNET_SET((struct vnet *) rock); - INIT_VNET_NET(curvnet); + INIT_VNET_INET(curvnet); struct rtqk_arg arg; static time_t last_adjusted_timeout = 0; ==== //depot/projects/vimage/src/sys/sys/sysctl.h#35 (text+ko) ==== @@ -463,10 +463,6 @@ cp = (char *) TD_TO_VPROCG(curthread); \ arg1 = cp + (size_t) arg1; \ break; \ - case V_CPU: \ - cp = (char *) TD_TO_VCPU(curthread); \ - arg1 = cp + (size_t) arg1; \ - break; \ default: \ panic("unsupported module id %d", oidp->oid_v_subs); \ } \ ==== //depot/projects/vimage/src/sys/sys/vimage.h#92 (text+ko) ==== @@ -44,6 +44,13 @@ #define VNET_DEBUG #endif +struct vimage; +struct vprocg; +struct vnet; +struct vi_req; +struct kld_sym_lookup; +struct ifnet; + typedef int vnet_attach_fn(const void *); typedef int vnet_detach_fn(const void *); @@ -111,6 +118,7 @@ /* Major module IDs for vimage sysctl virtualization. */ #define V_GLOBAL 0 /* global variable - no indirection */ #define V_NET 1 +#define V_PROCG 2 /* Name mappings for minor module IDs in vimage sysctl virtualization. */ #define V_MOD_vnet_net VNET_MOD_NET @@ -121,6 +129,8 @@ #define V_MOD_vnet_pf VNET_MOD_PF #define V_MOD_vnet_gif VNET_MOD_GIF #define V_MOD_vnet_ipsec VNET_MOD_IPSEC + +#define V_MOD_vprocg 0 /* no minor module ids like in vnet */ int vi_symlookup(struct kld_sym_lookup *, char *); void vnet_mod_register(const struct vnet_modinfo *); @@ -128,6 +138,15 @@ void vnet_mod_deregister(const struct vnet_modinfo *); void vnet_mod_deregister_multi(const struct vnet_modinfo *, void *, char *); +int vi_td_ioctl(u_long, struct vi_req *, struct thread *); +int vi_if_move(struct vi_req *, struct ifnet *, struct vimage *); +void if_reassign_common(struct ifnet *, struct vnet *, const char *); + +struct vimage *vnet2vimage(struct vnet *); +struct vimage *vimage_by_name(struct vimage *, char *); +char *vnet_name(struct vnet *); +int vi_child_of(struct vimage *, struct vimage *); + #endif /* !VIMAGE_GLOBALS */ #ifdef VIMAGE_GLOBALS @@ -162,6 +181,7 @@ void *mod_data[VNET_MOD_MAX]; LIST_ENTRY(vnet) vnet_le; /* all vnets list */ u_int vnet_magic_n; + u_int vnet_id; u_int ifccnt; u_int sockcnt; }; @@ -177,55 +197,67 @@ int _morphing_symlinks; }; -#ifdef VIMAGE -#define curvnet curthread->td_vnet -#else -#define curvnet NULL -#endif +struct vimage { + LIST_ENTRY(vimage) vi_le; /* all vimage list */ + LIST_ENTRY(vimage) vi_sibling; /* vimages with same parent */ + LIST_HEAD(, vimage) vi_child_head; /* direct offspring list */ + struct vimage *vi_parent; /* ptr to parent vimage */ + u_int vi_id; /* ID num */ + u_int vi_ucredrefc; /* # of ucreds pointing to us */ + + char vi_name[MAXHOSTNAMELEN]; + + struct vnet *v_net; + struct vprocg *v_procg; +}; + +#define curvnet curthread->td_vnet + +#define basevprocg thread0.td_ucred->cr_vimage->v_procg -#define VNET_MAGIC_N 0x3e0d8f29 +#define VNET_MAGIC_N 0x3e0d8f29 #ifdef VIMAGE #ifdef VNET_DEBUG -#define VNET_ASSERT(condition) \ +#define VNET_ASSERT(condition) \ if (!(condition)) { \ printf("VNET_ASSERT @ %s:%d %s():\n", \ __FILE__, __LINE__, __FUNCTION__); \ panic(#condition); \ } -#define CURVNET_SET_QUIET(arg) \ +#define CURVNET_SET_QUIET(arg) \ VNET_ASSERT((arg)->vnet_magic_n == VNET_MAGIC_N); \ struct vnet *saved_vnet = curvnet; \ const char *saved_vnet_lpush = curthread->td_vnet_lpush; \ curvnet = arg; \ curthread->td_vnet_lpush = __FUNCTION__; -#define CURVNET_SET_VERBOSE(arg) \ +#define CURVNET_SET_VERBOSE(arg) \ CURVNET_SET_QUIET(arg) \ if (saved_vnet) \ printf("curvnet_set(%p) in %s() on cpu %d, prev %p in %s()\n", curvnet, \ curthread->td_vnet_lpush, curcpu, \ saved_vnet, saved_vnet_lpush); -#define CURVNET_SET(arg) CURVNET_SET_VERBOSE(arg) +#define CURVNET_SET(arg) CURVNET_SET_VERBOSE(arg) -#define CURVNET_RESTORE() \ +#define CURVNET_RESTORE() \ VNET_ASSERT(saved_vnet == NULL || \ saved_vnet->vnet_magic_n == VNET_MAGIC_N); \ curvnet = saved_vnet; \ curthread->td_vnet_lpush = saved_vnet_lpush; #else /* !VNET_DEBUG */ -#define VNET_ASSERT(condition) +#define VNET_ASSERT(condition) -#define CURVNET_SET(arg) \ +#define CURVNET_SET(arg) \ struct vnet *saved_vnet = curvnet; \ curvnet = arg; -#define CURVNET_SET_VERBOSE(arg) CURVNET_SET(arg) -#define CURVNET_SET_QUIET(arg) CURVNET_SET(arg) +#define CURVNET_SET_VERBOSE(arg) CURVNET_SET(arg) +#define CURVNET_SET_QUIET(arg) CURVNET_SET(arg) -#define CURVNET_RESTORE() \ +#define CURVNET_RESTORE() \ curvnet = saved_vnet; #endif /* !VNET_DEBUG */ #else /* !VIMAGE */ @@ -261,29 +293,93 @@ #define VNET_FOREACH(arg) #endif -#define TD_TO_VNET(td) (td)->td_ucred->cr_vnet +#ifdef VIMAGE +LIST_HEAD(vimage_list_head, vimage); +extern struct vimage_list_head vimage_head; +#endif + +#ifdef VIMAGE +LIST_HEAD(vprocg_list_head, vprocg); +extern struct vprocg_list_head vprocg_head; +#define INIT_VPROCG(arg) struct vprocg *vprocg = (arg); +#define VPROCG_ITERLOOP_BEGIN() \ + struct vprocg *vprocg_iter; \ + LIST_FOREACH(vprocg_iter, &vprocg_head, vprocg_le) { + +#define VPROCG_ITERLOOP_END() \ + } +#else +#define INIT_VPROCG(arg) +#define VPROCG_ITERLOOP_BEGIN() +#define VPROCG_ITERLOOP_END() +#endif + +#ifdef VIMAGE +#define IS_DEFAULT_VIMAGE(arg) ((arg)->vi_id == 0) +#define IS_DEFAULT_VNET(arg) ((arg)->vnet_id == 0) +#else +#define IS_DEFAULT_VIMAGE(arg) 1 +#define IS_DEFAULT_VNET(arg) 1 +#endif + +#define TD_TO_VIMAGE(td) (td)->td_ucred->cr_vimage +#define TD_TO_VNET(td) (td)->td_ucred->cr_vimage->v_net +#define TD_TO_VPROCG(td) (td)->td_ucred->cr_vimage->v_procg +#define P_TO_VIMAGE(p) (p)->p_ucred->cr_vimage +#define P_TO_VNET(p) (p)->p_ucred->cr_vimage->v_net +#define P_TO_VPROCG(p) (p)->p_ucred->cr_vimage->v_procg /* Non-VIMAGE null-macros */ -#define IS_DEFAULT_VNET(arg) 1 #define VNET_LIST_RLOCK() #define VNET_LIST_RUNLOCK() -#define INIT_VPROCG(arg) -#define INIT_VCPU(arg) -#define TD_TO_VIMAGE(td) -#define TD_TO_VPROCG(td) -#define TD_TO_VCPU(td) -#define P_TO_VIMAGE(p) -#define P_TO_VNET(p) -#define P_TO_VPROCG(p) -#define P_TO_VCPU(p) /* XXX those defines bellow should probably go into vprocg.h and vcpu.h */ -#define VPROCG(sym) (sym) -#define VCPU(sym) (sym) +#define VPROCG(sym) VSYM(vprocg,sym) #define V_hostname VPROCG(hostname) -#define G_hostname VPROCG(hostname) /* global hostname */ +#define G_hostname VSYM(basevprocg, hostname) /* global hostname */ #define V_domainname VPROCG(domainname) +#define V_morphing_symlinks VPROCG(morphing_symlinks) + +struct vi_req { + int req_action; /* What to do with this reqest? */ + u_int vi_cpu_min; /* Guaranteed CPU share */ + u_int vi_cpu_max; /* Maximum average CPU usage */ + u_int vi_cpu_weight; /* Prop. share scheduling priority */ + int vi_intr_limit; /* Limit on CPU usage in intr ctx */ + int vi_maxsockets; + u_short vi_proc_limit; /* max. number of processes */ + u_short vi_proc_count; /* current number of processes */ + u_short vi_child_limit; /* max. number of child vnets */ + u_short vi_child_count; /* current number of child vnets */ + int vi_if_count; /* current number network interfaces */ + int vi_sock_count; + char vi_name[MAXPATHLEN]; + char vi_chroot[MAXPATHLEN]; + char vi_if_xname[MAXPATHLEN]; /* XXX should be IFNAMSIZ */ + u_int cp_time_avg; + struct loadavg averunnable; +}; + +#define VI_CREATE 0x00000001 +#define VI_DESTROY 0x00000002 +#define VI_MODIFY 0x00000004 +#define VI_SWITCHTO 0x00000008 +#define VI_IFACE 0x00000010 + +#define VI_GET 0x00000100 +#define VI_GETNEXT 0x00000200 +#define VI_GETNEXT_RECURSE 0x00000300 + +#define VI_SET_CPU_MIN 0x00001000 +#define VI_SET_CPU_MAX 0x00002000 +#define VI_SET_CPU_WEIGHT 0x00004000 +#define VI_SET_INTR_LIMIT 0x00008000 +#define VI_SET_PROC_LIMIT 0x00010000 +#define VI_SET_CHILD_LIMIT 0x00020000 +#define VI_SET_SOCK_LIMIT 0x00040000 +#define VI_SET_NAME 0x00100000 +#define VI_SET_CHROOT 0x00200000 /* * Size-guards for the vimage structures.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200905061641.n46GfVVr087629>