• Len Brown's avatar
    tools/power turbostat: Gracefully handle ACPI S3 · ba3dec99
    Len Brown authored
    turbostat gives valid results across suspend to idle, aka freeze,
    whether invoked in  interval mode, or in command mode.
    Indeed, this can be used to measure suspend to idle:
    
    turbostat echo freeze > /sys/power/state
    
    But this does not work across suspend to ACPI S3, because the
    processor counters, including the TSC, are reset on resume.
    Further, when turbostat detects a problem, it does't forgive
    the hardware, and interval mode will print *'s from there on out.
    
    Instead, upon detecting counters going backwards, simply
    reset and start over.
    
    Interval mode across ACPI S3: (observe TSC going backwards)
    
    root@sharkbay:/home/lenb/turbostat-src# ./turbostat -M 0x10
         CPU Avg_MHz   Busy% Bzy_MHz TSC_MHz           MSR 0x010
           -       1    0.06     858    2294  0x0000000000000000
           0       0    0.06     847    2294  0x0000002a254b98ac
           1       1    0.06     878    2294  0x0000002a254efa3a
           2       1    0.07     843    2294  0x0000002a2551df65
           3       0    0.05     863    2294  0x0000002a2553fea2
    turbostat: re-initialized with num_cpus 4
         CPU Avg_MHz   Busy% Bzy_MHz TSC_MHz           MSR 0x010
           -       2    0.20     849    2294  0x0000000000000000
           0       2    0.26     856    2294  0x0000000449abb60d
           1       2    0.20     844    2294  0x0000000449b087ec
           2       2    0.21     850    2294  0x0000000449b35d5d
           3       1    0.12     839    2294  0x0000000449b5fd5a
    ^C
    
    Command mode across ACPI S3:
    root@sharkbay:/home/lenb/turbostat-src# ./turbostat -M 0x10 sleep 10
    ./turbostat: Counter reset detected
    14.196299 sec
    Signed-off-by: default avatarLen Brown <len.brown@intel.com>
    ba3dec99
turbostat.c 96.5 KB