summaryrefslogtreecommitdiff
path: root/overlay/cpu-top.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2013-08-27 17:40:45 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2013-08-27 17:43:46 +0100
commitc6b26c5a406225868f05672949bcc4997c94c3ab (patch)
tree913cf3ee290f0e458042c0b50ee167ac0bc56f10 /overlay/cpu-top.c
parent177208b0d4cf64a3e2f18909a47afc5bd646a651 (diff)
overlay: Scale the CPU busy value by the numer of active cores
Having 100% always mean one processor fully utilised is much easier to understand (than having to remember how many cores are on each machine and scale appropriately). Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'overlay/cpu-top.c')
-rw-r--r--overlay/cpu-top.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/overlay/cpu-top.c b/overlay/cpu-top.c
index 4e31da1b..c134d409 100644
--- a/overlay/cpu-top.c
+++ b/overlay/cpu-top.c
@@ -25,10 +25,20 @@
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
+#include <string.h>
#include <errno.h>
#include "cpu-top.h"
+int cpu_top_init(struct cpu_top *cpu)
+{
+ memset(cpu, 0, sizeof(*cpu));
+
+ cpu->nr_cpu = sysconf(_SC_NPROCESSORS_ONLN);
+
+ return 0;
+}
+
int cpu_top_update(struct cpu_top *cpu)
{
struct cpu_stat *s = &cpu->stat[cpu->count++&1];