xenpm, x86: Fix reporting of idle state average residency times
PATCH 1/1 xenpm, x86: Fix reporting of idle state average residency times
# HG changeset patch
# User Boris Ostrovsky <[email protected]>
# Date 1338831484 -7200
# Node ID 390346181927d0350f83c4046470a0b9b28c1686
# Parent 6bea63e6c780de6303361e5f190d6925996cd2a2 xenpm, x86: Fix reporting of idle state average residency times
If CPU stays in the same idle state for the full duration of xenpm sample then average residency may not be reported correctly since usage counter will not be incremented.
In addition, in order to calculate averages correctly residence time and usage counter should be read and written atomically.
Signed-off-by Boris Ostrovsky <[email protected]>
tools/misc/xenpm.c +8 -1
@@ -389,7 +389,14 @@ static void signal_int_handler(int signo res = ( diff >=0 ) ? diff :0 ; triggers = cxstat_end[i].triggers[j] - cxstat_start[i].triggers[j]; - avg_res = (triggers==0 ) ?0 : (double )res/triggers/1000000.0 ; +/* +* triggers may be zero if the CPU has been in this state for +* the whole sample or if it never entered the state +*/ +if ( triggers ==0 && cxstat_end[i].last == j ) + avg_res = (double )sum_cx[i]/1000000.0 ; +else + avg_res = (triggers==0 ) ?0 : (double )res/triggers/1000000.0 ;printf (" C%d\t%" PRIu64"\t(%5.2f%%)\t%.2f\n" , j, res/1000000UL ,100 * res / (double )sum_cx[i], avg_res ); }
xen/arch/x86/acpi/cpu_idle.c +61 -36
190 lines not on this page · raw message
xen/include/xen/cpuidle.h +2 -0
@@ -28,6 +28,7 @@#define _XEN_CPUIDLE_H#include <xen/cpumask.h> +#include <xen/spinlock.h> #define ACPI_PROCESSOR_MAX_POWER 8#define CPUIDLE_NAME_LEN 16
@@ -69,6 +70,7 @@ struct acpi_processor_powervoid *gdata;/* governor specific data */ u32 last_residency;u32 count; +spinlock_t stat_lock;struct acpi_processor_cx states[ACPI_PROCESSOR_MAX_POWER ]; };