Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Nov 2015 14:14:32 +0000 (UTC)
From:      Josh Paetzel <jpaetzel@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r290662 - head/sys/kern
Message-ID:  <201511101414.tAAEEWHZ057069@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jpaetzel
Date: Tue Nov 10 14:14:32 2015
New Revision: 290662
URL: https://svnweb.freebsd.org/changeset/base/290662

Log:
  Fix a bug in the CPU % limiting code
  
  If you attempt to set a pcpu limit that is higher than
  110% using rctl (for instance, you want a jail to be
  able to use 2 cores on your system so you set pcpu to
  200%) the thing you are trying to limit becomes unthrottled.
  
  PR:	189870
  Submitted by:	dustinwenz@ebureau.com
  Reviewed by:	trasz
  MFC after:	1 week

Modified:
  head/sys/kern/kern_racct.c

Modified: head/sys/kern/kern_racct.c
==============================================================================
--- head/sys/kern/kern_racct.c	Tue Nov 10 13:47:28 2015	(r290661)
+++ head/sys/kern/kern_racct.c	Tue Nov 10 14:14:32 2015	(r290662)
@@ -517,16 +517,16 @@ racct_adjust_resource(struct racct *racc
 	
 	/*
 	 * There are some cases where the racct %cpu resource would grow
-	 * beyond 100%.
-	 * For example in racct_proc_exit() we add the process %cpu usage
-	 * to the ucred racct containers.  If too many processes terminated
-	 * in a short time span, the ucred %cpu resource could grow too much.
-	 * Also, the 4BSD scheduler sometimes returns for a thread more than
-	 * 100% cpu usage.  So we set a boundary here to 100%.
+	 * beyond 100% per core.  For example in racct_proc_exit() we add
+	 * the process %cpu usage to the ucred racct containers.  If too
+	 * many processes terminated in a short time span, the ucred %cpu
+	 * resource could grow too much.  Also, the 4BSD scheduler sometimes
+	 * returns for a thread more than 100% cpu usage. So we set a sane
+	 * boundary here to 100% * the maxumum number of CPUs.
 	 */
 	if ((resource == RACCT_PCTCPU) &&
-	    (racct->r_resources[RACCT_PCTCPU] > 100 * 1000000))
-		racct->r_resources[RACCT_PCTCPU] = 100 * 1000000;
+	    (racct->r_resources[RACCT_PCTCPU] > 100 * 1000000 * (int64_t)MAXCPU))
+		racct->r_resources[RACCT_PCTCPU] = 100 * 1000000 * (int64_t)MAXCPU;
 }
 
 static int



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