Re: [REDO PATCH v7] perf/x86/amd/power: Add AMD accumulated power reporting mechanism

From: Vince Weaver
Date: Wed Jun 15 2016 - 21:14:13 EST



three questions about this functionality:

1. In theory this should also work on an amd fam16h model 30h
processor too, correct? The current code limits things to fam15h
even though the fam16mod30h has all the proper cpuid flags.

I've tested the functionality a bit and it seems to work but for
some reason the ptsc seems to occasionally count backwards
on my machine. Any reason that would be? (It doesn't seem to be
an overflow, just reading the ptsc 5ms apart and the values are
slightly lower after than before).

2. Unless I'm misunderstanding things, the code seems to be accumulating
Power. (see chunk below) Power is an instantaneous measurement, it
makes no sense to add values. If you use 5W for 1ms and 10W for
1ms, the average power across the 2ms interval is not 15W.

You can add energy, but not power.

> + delta *= cpu_pwr_sample_ratio * 1000;
> + tdelta = new_ptsc - prev_ptsc;
> +
> + do_div(delta, tdelta);
> + local64_add(delta, &event->count);

3. The actual results gathered seem rediculously low. 341 seconds of
calculation and only using 183 mWatts of power?

> Performance counter stats for 'system wide':
>
> 183.44 mWatts power/power-pkg/
>
> 341.837270111 seconds time elapsed
>
> root@hr-zp:/home/ray/tip# ./tools/perf/perf stat -a -e 'power/power-pkg/' sleep 10

Vince