From owner-p4-projects@FreeBSD.ORG Mon Aug 30 21:00:29 2010 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 7CA9510656B4; Mon, 30 Aug 2010 21:00:29 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3CC2610656A6 for ; Mon, 30 Aug 2010 21:00:29 +0000 (UTC) (envelope-from trasz@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:4f8:fff6::2d]) by mx1.freebsd.org (Postfix) with ESMTP id 1037E8FC18 for ; Mon, 30 Aug 2010 21:00:29 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.4/8.14.4) with ESMTP id o7UL0Sbn007357 for ; Mon, 30 Aug 2010 21:00:28 GMT (envelope-from trasz@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.4/8.14.4/Submit) id o7UL0SWe007353 for perforce@freebsd.org; Mon, 30 Aug 2010 21:00:28 GMT (envelope-from trasz@freebsd.org) Date: Mon, 30 Aug 2010 21:00:28 GMT Message-Id: <201008302100.o7UL0SWe007353@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to trasz@freebsd.org using -f From: Edward Tomasz Napierala To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 183090 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Aug 2010 21:00:29 -0000 http://p4web.freebsd.org/@@183090?ac=10 Change 183090 by trasz@trasz_victim on 2010/08/30 21:00:15 RUSAGE_SWAP. It's slow and ugly, but will have to do for now. It will be redone after tackling SysV shm. Affected files ... .. //depot/projects/soc2009/trasz_limits/sys/vm/swap_pager.c#7 edit .. //depot/projects/soc2009/trasz_limits/sys/vm/vm_map.c#20 edit .. //depot/projects/soc2009/trasz_limits/sys/vm/vm_pageout.c#14 edit Differences ... ==== //depot/projects/soc2009/trasz_limits/sys/vm/swap_pager.c#7 (text+ko) ==== @@ -75,6 +75,7 @@ #include #include #include +#include #include #include #include @@ -207,8 +208,14 @@ if (res) { PROC_LOCK(curproc); UIDINFO_VMSIZE_LOCK(uip); - if ((overcommit & SWAP_RESERVE_RLIMIT_ON) != 0 && + if ( +#ifdef CONTAINERS + rusage_add(curproc, RUSAGE_SWAP, incr) && +#endif +#ifndef HRL + (overcommit & SWAP_RESERVE_RLIMIT_ON) != 0 && uip->ui_vmsize + incr > lim_cur(curproc, RLIMIT_SWAP) && +#endif priv_check(curthread, PRIV_VM_SWAP_NORLIMIT)) res = 0; else @@ -251,6 +258,9 @@ { struct uidinfo *uip; +#ifdef CONTAINERS + rusage_sub(curproc, RUSAGE_SWAP, decr); +#endif PROC_LOCK(curproc); uip = curthread->td_ucred->cr_ruidinfo; swap_release_by_uid(decr, uip); ==== //depot/projects/soc2009/trasz_limits/sys/vm/vm_map.c#20 (text+ko) ==== @@ -418,6 +418,7 @@ rusage_set(p, RUSAGE_RSS, 0); rusage_set(p, RUSAGE_MEMLOCK, 0); rusage_set(p, RUSAGE_VMEM, 0); + rusage_set(p, RUSAGE_SWAP, 0); #endif } ==== //depot/projects/soc2009/trasz_limits/sys/vm/vm_pageout.c#14 (text+ko) ==== @@ -1709,6 +1709,18 @@ size = vmspace_resident_count(vm); rusage_set(p, RUSAGE_RSS, IDX_TO_OFF(size)); } + + /* + * This is the ugly (and temporary, hopefully) part + * of dealing with RUSAGE_SWAP. Basically, we increase + * swap counters in the proper place, and decrease them + * here. Doing it properly will require adding either + * proc or ucred pointer to vm objects; before I do that, + * I want to get a better feeling on how the memory + * management works. In other words, it's post-shm task. + */ + size = vmspace_swap_count(vm); + rusage_set(p, RUSAGE_SWAP, IDX_TO_OFF(size)); #endif vmspace_free(vm); }