From owner-svn-soc-all@FreeBSD.ORG Sun Aug 12 08:54:22 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 8ADEF106566B for ; Sun, 12 Aug 2012 08:54:20 +0000 (UTC) (envelope-from rudot@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Sun, 12 Aug 2012 08:54:20 +0000 Date: Sun, 12 Aug 2012 08:54:20 +0000 From: rudot@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120812085420.8ADEF106566B@hub.freebsd.org> Cc: Subject: socsvn commit: r240292 - soc2012/rudot/sys/kern X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Aug 2012 08:54:22 -0000 Author: rudot Date: Sun Aug 12 08:54:19 2012 New Revision: 240292 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240292 Log: decaying pcpu - complete Modified: soc2012/rudot/sys/kern/kern_racct.c Modified: soc2012/rudot/sys/kern/kern_racct.c ============================================================================== --- soc2012/rudot/sys/kern/kern_racct.c Sun Aug 12 07:09:25 2012 (r240291) +++ soc2012/rudot/sys/kern/kern_racct.c Sun Aug 12 08:54:19 2012 (r240292) @@ -308,9 +308,9 @@ fixpt_t p_pctcpu; struct thread *td; - swtime = (ticks - p->p_swtick) / hz; - if ((swtime == 0) || ((p->p_flag & P_INMEM) == 0)) + if ((p->p_flag & P_INMEM) == 0) return (0); + swtime = (ticks - p->p_swtick) / hz; if (swtime < RACCT_PCPU_SECS) { /* * For short-lived processes, the sched_pctcpu() returns small @@ -479,6 +479,12 @@ ("racct_alloc_resource: usage < 0")); racct->r_resources[resource] = 0; } + + if (resource == RACCT_PCTCPU) { + if (racct->r_resources[RACCT_PCTCPU] > 100) { + racct->r_resources[RACCT_PCTCPU] = 100; + } + } } static int @@ -608,16 +614,16 @@ } available = INT64_MAX; -#ifdef RCTL - available = rctl_pcpu_available(p); -#endif racct_alloc_resource(p->p_racct, resource, diff_proc); if (diff_cred > 0) racct_add_cred_locked(p->p_ucred, resource, diff_cred); else if (diff_cred < 0) racct_sub_cred_locked(p->p_ucred, resource, -diff_cred); - return (available <= diff_proc); +#ifdef RCTL + available = rctl_pcpu_available(p); +#endif + return (available <= 0); } static int