Date: Tue, 16 Jun 2009 16:11:54 GMT From: Edward Tomasz Napierala <trasz@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 164512 for review Message-ID: <200906161611.n5GGBs3b097882@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=164512 Change 164512 by trasz@trasz_victim on 2009/06/16 16:11:45 Support hierarchical jails (untested). Add debugging printfs. Affected files ... .. //depot/projects/soc2009/trasz_limits/sys/kern/kern_exit.c#4 edit .. //depot/projects/soc2009/trasz_limits/sys/kern/kern_hrl.c#11 edit .. //depot/projects/soc2009/trasz_limits/sys/kern/kern_jail.c#4 edit .. //depot/projects/soc2009/trasz_limits/sys/kern/kern_resource.c#8 edit Differences ... ==== //depot/projects/soc2009/trasz_limits/sys/kern/kern_exit.c#4 (text+ko) ==== @@ -129,7 +129,7 @@ struct ucred *tracecred; #endif struct plimit *plim; - int locked; + int locked, i; mtx_assert(&Giant, MA_NOTOWNED); @@ -404,6 +404,12 @@ PROC_UNLOCK(p); lim_free(plim); + for (i = 0; i < HRL_RESOURCE_MAX; i++) { + if (p->p_accounting.ha_resources[i] != 0) + printf("exit1: exiting process: resource %d = %lld\n", + i, p->p_accounting.ha_resources[i]); + } + /* * Remove proc from allproc queue and pidhash chain. * Place onto zombproc. Unlink from parent's child list. ==== //depot/projects/soc2009/trasz_limits/sys/kern/kern_hrl.c#11 (text+ko) ==== @@ -106,6 +106,7 @@ { int i; struct ucred *cred; + struct prison *pr; KASSERT(amount > 0, ("invalid amount")); @@ -115,7 +116,8 @@ p->p_accounting.ha_resources[resource] += amount; cred = p->p_ucred; cred->cr_ruidinfo->ui_accounting.ha_resources[resource] += amount; - cred->cr_prison->pr_accounting.ha_resources[resource] += amount; + for (pr = cred->cr_prison; pr != NULL; pr = pr->pr_parent) + pr->pr_accounting.ha_resources[resource] += amount; for (i = 0; i < cred->cr_ngroups; i++) cred->cr_gidinfos[i]->gi_accounting.ha_resources[resource] += amount; @@ -132,12 +134,14 @@ int i; int64_t diff; struct ucred *cred; + struct prison *pr; diff = amount - p->p_accounting.ha_resources[resource]; p->p_accounting.ha_resources[resource] += diff; cred = p->p_ucred; cred->cr_ruidinfo->ui_accounting.ha_resources[resource] += diff; - cred->cr_prison->pr_accounting.ha_resources[resource] += diff; + for (pr = cred->cr_prison; pr != NULL; pr = pr->pr_parent) + pr->pr_accounting.ha_resources[resource] += diff; for (i = 0; i < cred->cr_ngroups; i++) cred->cr_gidinfos[i]->gi_accounting.ha_resources[resource] += diff; @@ -154,13 +158,15 @@ { int i; struct ucred *cred; + struct prison *pr; KASSERT(amount > 0, ("invalid amount")); p->p_accounting.ha_resources[resource] -= amount; cred = p->p_ucred; cred->cr_ruidinfo->ui_accounting.ha_resources[resource] -= amount; - cred->cr_prison->pr_accounting.ha_resources[resource] -= amount; + for (pr = cred->cr_prison; pr != NULL; pr = pr->pr_parent) + pr->pr_accounting.ha_resources[resource] -= amount; for (i = 0; i < cred->cr_ngroups; i++) cred->cr_gidinfos[i]->gi_accounting.ha_resources[resource] -= amount; } ==== //depot/projects/soc2009/trasz_limits/sys/kern/kern_jail.c#4 (text+ko) ==== @@ -2341,7 +2341,7 @@ prison_deref(struct prison *pr, int flags) { struct prison *ppr, *tpr; - int vfslocked; + int vfslocked, i; if (!(flags & PD_LOCKED)) mtx_lock(&pr->pr_mtx); @@ -2414,6 +2414,11 @@ if (pr->pr_cpuset != NULL) cpuset_rel(pr->pr_cpuset); osd_jail_exit(pr); + for (i = 0; i < HRL_RESOURCE_MAX; i++) { + if (pr->pr_accounting.ha_resources[i] != 0) + printf("prison_deref: resource %d = %lld\n", + i, pr->pr_accounting.ha_resources[i]); + } free(pr, M_PRISON); /* Removing a prison frees a reference on its parent. */ ==== //depot/projects/soc2009/trasz_limits/sys/kern/kern_resource.c#8 (text+ko) ==== @@ -1352,7 +1352,7 @@ uifree(uip) struct uidinfo *uip; { - int old; + int old, i; /* Prepare for optimal case. */ old = uip->ui_ref; @@ -1370,6 +1370,12 @@ if (uip->ui_proccnt != 0) printf("freeing uidinfo: uid = %d, proccnt = %ld\n", uip->ui_uid, uip->ui_proccnt); + for (i = 0; i < HRL_RESOURCE_MAX; i++) { + if (uip->ui_accounting.ha_resources[i] != 0) + printf("uifree: freeing uidinfo: uid = %d, " + "resource %d = %lld \n", uip->ui_uid, i, + uip->ui_accounting.ha_resources[i]); + } free(uip, M_UIDINFO); return; } @@ -1497,7 +1503,7 @@ gifree(gip) struct gidinfo *gip; { - int old; + int old, i; /* Prepare for optimal case. */ old = gip->gi_ref; @@ -1509,6 +1515,12 @@ if (refcount_release(&gip->gi_ref)) { LIST_REMOVE(gip, gi_hash); rw_wunlock(&gihashtbl_lock); + for (i = 0; i < HRL_RESOURCE_MAX; i++) { + if (gip->gi_accounting.ha_resources[i] != 0) + printf("gifree: freeing gidinfo: gid = %d, " + "resource %d = %lld \n", gip->gi_gid, i, + gip->gi_accounting.ha_resources[i]); + } free(gip, M_GIDINFO); return; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906161611.n5GGBs3b097882>