Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Sep 2012 11:56:15 -0400 (EDT)
From:      Ben Wilber <ben@desync.com>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   kern/171811: [patch] rctl(8) cputime is too high
Message-ID:  <20120920155615.0B46B2D92@exile.desync.com>
Resent-Message-ID: <201209201600.q8KG0NQM037081@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         171811
>Category:       kern
>Synopsis:       [patch] rctl(8) cputime is too high
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Sep 20 16:00:22 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Ben Wilber
>Release:        FreeBSD 10.0-CURRENT amd64
>Organization:
>Environment:
System: FreeBSD exile 10.0-CURRENT FreeBSD 10.0-CURRENT #1 r240178M: Thu Sep 6 19:25:33 EDT 2012 bw@exodus:/usr/obj/usr/src/sys/COMRADE amd64

>Description:

rctl's idea of cputime is unreasonably high with lots of process turnover.

>How-To-Repeat:

# jail -c command=sh
jail# while true; do id > /dev/null; done

meanwhile:

# dtrace -n 'rusage:add-cred/args[0]->cr_prison->pr_id != 0 && args[1] == 0/{printf("%d: jail %d cputime %d", pid, args[0]->cr_prison->pr_id, args[2])}'
5  57139                  rusage:add-cred 37375: jail 5 cputime 124211
5  57139                  rusage:add-cred 37375: jail 5 cputime 6330
5  57139                  rusage:add-cred 37375: jail 5 cputime 51237828
5  57139                  rusage:add-cred 37375: jail 5 cputime 173602
5  57139                  rusage:add-cred 37375: jail 5 cputime 6834680
(...)

>Fix:

Attached patch seems to help.

--- kern_racct.diff begins here ---
Index: kern_racct.c
===================================================================
diff --git a/head/sys/kern/kern_racct.c b/head/sys/kern/kern_racct.c
--- a/head/sys/kern/kern_racct.c	(revision 240705)
+++ b/head/sys/kern/kern_racct.c	(working copy)
@@ -607,7 +607,9 @@
 	/*
 	 * We don't need to calculate rux, proc_reap() has already done this.
 	 */
+	PROC_SLOCK(p);
 	runtime = cputick2usec(p->p_rux.rux_runtime);
+	PROC_SUNLOCK(p);
 #ifdef notyet
 	KASSERT(runtime >= p->p_prev_runtime, ("runtime < p_prev_runtime"));
 #else
--- kern_racct.diff ends here ---

>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120920155615.0B46B2D92>