From c6b26c5a406225868f05672949bcc4997c94c3ab Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Tue, 27 Aug 2013 17:40:45 +0100 Subject: 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 --- overlay/cpu-top.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'overlay/cpu-top.c') 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 #include #include +#include #include #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]; -- cgit v1.2.3