Here is a bug and fix from J?rgen.
J?rgen Keil <> wrote:
>
> It's a bug in powertop. ?The dtrace code that powertop is using
> aggregates on a processorid_t (cpu) and an uint32_t (cpuspeed).
>
> But in function pt_cpufreq_dtrace_walk() the cpu speed is
> read as uint64_t - this is working with bogus values for cpu
> speed!
>
> Suggested fix:
>
> diff --git a/usr/src/cmd/powertop/common/cpufreq.c
> b/usr/src/cmd/powertop/common/cpufreq.c
> --- a/usr/src/cmd/powertop/common/cpufreq.c
> +++ b/usr/src/cmd/powertop/common/cpufreq.c
> @@ -431,7 +431,7 @@ pt_cpufreq_dtrace_walk(const dtrace_aggd
> ? ? ? ?dtrace_recdesc_t ? ? ? ?*cpu_rec, *speed_rec;
> ? ? ? ?cpu_power_info_t ? ? ? ?*cpu_pow;
> ? ? ? ?int32_t ? ? ? ? ? ? ? ? cpu;
> - ? ? ? uint64_t ? ? ? ? ? ? ? ?speed;
> + ? ? ? uint32_t ? ? ? ? ? ? ? ?speed;
> ? ? ? ?hrtime_t ? ? ? ? ? ? ? ?dt_state_time = 0;
> ? ? ? ?int ? ? ? ? ? ? ? ? ? ? i;
>
> @@ -447,7 +447,7 @@ pt_cpufreq_dtrace_walk(const dtrace_aggd
> ? ? ? ? ? ? ? ?/* LINTED - alignment */
> ? ? ? ? ? ? ? ?cpu = *(int32_t *)(data->dtada_data + cpu_rec->dtrd_offset);
> ? ? ? ? ? ? ? ?/* LINTED - alignment */
> - ? ? ? ? ? ? ? speed = *(uint64_t *)(data->dtada_data +
> + ? ? ? ? ? ? ? speed = *(uint32_t *)(data->dtada_data +
> ? ? ? ? ? ? ? ? ? ?speed_rec->dtrd_offset);
>
> ? ? ? ? ? ? ? ?if (speed == 0) {
> --
Or we can remove the (uint32_t) casting in the dtrace script.
the argument in the dtrace probe :::cpu-change-speed is also uint64_t.
Thanks,
-Aubrey