[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150128052330.GD29600@developer.hsd1.ca.comcast.net>
Date: Wed, 28 Jan 2015 01:23:33 -0400
From: Eduardo Valentin <edubezval@...il.com>
To: Javi Merino <javi.merino@....com>
Cc: linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org,
punit.agrawal@....com, broonie@...nel.org,
Zhang Rui <rui.zhang@...el.com>
Subject: Re: [RFC PATCH v6 6/9] thermal: cpu_cooling: implement the power
cooling device API
Hello Javi,
On Fri, Dec 05, 2014 at 07:04:17PM +0000, Javi Merino wrote:
> Add a basic power model to the cpu cooling device to implement the
> power cooling device API. The power model uses the current frequency,
> current load and OPPs for the power calculations. The cpus must have
> registered their OPPs using the OPP library.
>
> Cc: Zhang Rui <rui.zhang@...el.com>
> Cc: Eduardo Valentin <edubezval@...il.com>
> Signed-off-by: Punit Agrawal <punit.agrawal@....com>
> Signed-off-by: Javi Merino <javi.merino@....com>
<big cut>
> +
> +/**
> + * get_load() - get load for a cpu since last updated
> + * @cpufreq_device: &struct cpufreq_cooling_device for this cpu
> + * @cpu: cpu number
> + *
> + * Return: The average load of cpu @cpu in percentage since this
> + * function was last called.
> + */
> +static u32 get_load(struct cpufreq_cooling_device *cpufreq_device, int cpu)
> +{
> + u32 load;
> + u64 now, now_idle, delta_time, delta_idle;
> +
> + now_idle = get_cpu_idle_time(cpu, &now, 0);
> + delta_idle = now_idle - cpufreq_device->time_in_idle[cpu];
> + delta_time = now - cpufreq_device->time_in_idle_timestamp[cpu];
> +
> + if (delta_time <= delta_idle)
> + load = 0;
> + else
> + load = div64_u64(100 * (delta_time - delta_idle), delta_time);
> +
> + cpufreq_device->time_in_idle[cpu] = now_idle;
> + cpufreq_device->time_in_idle_timestamp[cpu] = now;
> +
> + return load;
> +}
<cut>
>
> +/**
> + * cpufreq_get_actual_power() - get the current power
> + * @cdev: &thermal_cooling_device pointer
> + *
> + * Return the current power consumption of the cpus in milliwatts.
> + */
> +static u32 cpufreq_get_actual_power(struct thermal_cooling_device *cdev)
> +{
> + unsigned long freq;
> + int cpu;
> + u32 static_power, dynamic_power, total_load = 0;
> + struct cpufreq_cooling_device *cpufreq_device = cdev->devdata;
> +
> + freq = cpufreq_quick_get(cpumask_any(&cpufreq_device->allowed_cpus));
> +
> + for_each_cpu(cpu, &cpufreq_device->allowed_cpus) {
> + u32 load;
> +
> + if (cpu_online(cpu))
> + load = get_load(cpufreq_device, cpu);
> + else
> + load = 0;
> +
> + total_load += load;
> + }
> +
> + cpufreq_device->last_load = total_load;
> +
> + static_power = get_static_power(cpufreq_device, freq);
> + dynamic_power = get_dynamic_power(cpufreq_device, freq);
> +
> + return static_power + dynamic_power;
> +}
With respect to load computation vs. frequency usage vs. power
estimation, while getting actual power for a given interval T. What if
in interval T, we have used, say, 3 different cpu frequencies, and the
load on the first was 50%, on the second 80%, and on the last frequency,
the load was 60%, what should be the right load value for computing the
actual power?
I mean, we are using the total idle time for a given interval, but 1 -
idle not always seams to reflect actual load on different opps, if opps
change over time within T time interval window.
BR,
BR,
Eduardo Valentin
Download attachment "signature.asc" of type "application/pgp-signature" (474 bytes)
Powered by blists - more mailing lists