Date: Thu, 27 Jul 2006 08:38:31 GMT From: Chris Jones <cdjones@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 102535 for review Message-ID: <200607270838.k6R8cV8j044535@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=102535 Change 102535 by cdjones@cdjones-impulse on 2006/07/27 08:37:54 Refactor to pass prison structures to _memory and _memory_limit. Affected files ... .. //depot/projects/soc2006/cdjones_jail/src/sys/kern/kern_jail.c#13 edit .. //depot/projects/soc2006/cdjones_jail/src/sys/sys/jail.h#13 edit Differences ... ==== //depot/projects/soc2006/cdjones_jail/src/sys/kern/kern_jail.c#13 (text+ko) ==== @@ -126,6 +126,11 @@ if (pr->pr_pager_flags & J_PAGER_TD_DIE) break; + if (prison_memory(pr) > prison_memory_limit(pr)) { + /* the logic from vm_daemon() really needs to go here. + TODO: refactor vm_daemon to optionally act on specific jails. */ + } + /* TODO --- make interval into a sysctl? */ tsleep(pr, 0, "-", hz); } @@ -458,7 +463,7 @@ /* Given credential, return memory usage in bytes. */ int -prison_memory(struct ucred *cred) +prison_memory(struct prison *pr) { struct proc *p; u_int mem_used = 0; @@ -466,7 +471,7 @@ /* TODO: cut this to search only procs in given jail. */ FOREACH_PROC_IN_SYSTEM(p) { if (!jailed(p->p_ucred) || - (cred->cr_prison != p->p_ucred->cr_prison)) { + (pr != p->p_ucred->cr_prison)) { continue; } @@ -479,17 +484,17 @@ /* Convert to bytes, cache (maybe unncessary?). */ mem_used *= PAGE_SIZE; - mtx_lock(&cred->cr_prison->pr_mtx); - cred->cr_prison->pr_mem_usage = mem_used; - mtx_unlock(&cred->cr_prison->pr_mtx); + mtx_lock(&pr->pr_mtx); + pr->pr_mem_usage = mem_used; + mtx_unlock(&pr->pr_mtx); return mem_used; } /* Given credential, return permitted memory usage in bytes. */ int -prison_memory_limit(struct ucred *cred) +prison_memory_limit(struct prison *pr) { - return cred->cr_prison->pr_mem_limit; + return pr->pr_mem_limit; } /* ==== //depot/projects/soc2006/cdjones_jail/src/sys/sys/jail.h#13 (text+ko) ==== @@ -143,8 +143,8 @@ void prison_hold(struct prison *pr); int prison_if(struct ucred *cred, struct sockaddr *sa); int prison_ip(struct ucred *cred, int flag, u_int32_t *ip); -int prison_memory(struct ucred *cred); -int prison_memory_limit(struct ucred *cred); +int prison_memory(struct prison *pr); +int prison_memory_limit(struct prison *pr); void prison_remote_ip(struct ucred *cred, int flags, u_int32_t *ip); #endif /* _KERNEL */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200607270838.k6R8cV8j044535>