summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjpaetzel <jpaetzel@FreeBSD.org>2015-11-10 14:14:32 +0000
committerjpaetzel <jpaetzel@FreeBSD.org>2015-11-10 14:14:32 +0000
commit22e9b6f7807c841c4c59a7feeedc5e00352cf2a2 (patch)
tree45d01e5db1b80288a4e6e7e5a7d8e2b62625398f
parent5d0c34068a8fec6ee8ca82e4238f851f8b09fce6 (diff)
downloadFreeBSD-src-22e9b6f7807c841c4c59a7feeedc5e00352cf2a2.zip
FreeBSD-src-22e9b6f7807c841c4c59a7feeedc5e00352cf2a2.tar.gz
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
-rw-r--r--sys/kern/kern_racct.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/sys/kern/kern_racct.c b/sys/kern/kern_racct.c
index d32b432..dde0baf 100644
--- a/sys/kern/kern_racct.c
+++ b/sys/kern/kern_racct.c
@@ -517,16 +517,16 @@ racct_adjust_resource(struct racct *racct, int resource,
/*
* 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
OpenPOWER on IntegriCloud