From owner-svn-src-head@FreeBSD.ORG Tue Nov 13 11:29:08 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 90765D30; Tue, 13 Nov 2012 11:29:08 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 74A6B8FC1D; Tue, 13 Nov 2012 11:29:08 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qADBT8v5038302; Tue, 13 Nov 2012 11:29:08 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qADBT8pG038301; Tue, 13 Nov 2012 11:29:08 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201211131129.qADBT8pG038301@svn.freebsd.org> From: Edward Tomasz Napierala Date: Tue, 13 Nov 2012 11:29:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r242957 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Nov 2012 11:29:08 -0000 Author: trasz Date: Tue Nov 13 11:29:08 2012 New Revision: 242957 URL: http://svnweb.freebsd.org/changeset/base/242957 Log: Don't divide by zero. Tested by: swills Modified: head/sys/kern/kern_racct.c Modified: head/sys/kern/kern_racct.c ============================================================================== --- head/sys/kern/kern_racct.c Tue Nov 13 08:35:25 2012 (r242956) +++ head/sys/kern/kern_racct.c Tue Nov 13 11:29:08 2012 (r242957) @@ -921,9 +921,12 @@ racct_proc_exit(struct proc *p) #endif microuptime(&wallclock); timevalsub(&wallclock, &p->p_stats->p_start); - pct_estimate = (1000000 * runtime * 100) / - ((uint64_t)wallclock.tv_sec * 1000000 + - wallclock.tv_usec); + if (wallclock.tv_sec > 0 || wallclock.tv_usec > 0) { + pct_estimate = (1000000 * runtime * 100) / + ((uint64_t)wallclock.tv_sec * 1000000 + + wallclock.tv_usec); + } else + pct_estimate = 0; pct = racct_getpcpu(p, pct_estimate); mtx_lock(&racct_lock); @@ -1136,9 +1139,12 @@ racctd(void) runtime = p->p_prev_runtime; #endif p->p_prev_runtime = runtime; - pct_estimate = (1000000 * runtime * 100) / - ((uint64_t)wallclock.tv_sec * 1000000 + - wallclock.tv_usec); + if (wallclock.tv_sec > 0 || wallclock.tv_usec > 0) { + pct_estimate = (1000000 * runtime * 100) / + ((uint64_t)wallclock.tv_sec * 1000000 + + wallclock.tv_usec); + } else + pct_estimate = 0; pct = racct_getpcpu(p, pct_estimate); mtx_lock(&racct_lock); racct_set_force_locked(p, RACCT_PCTCPU, pct);