lkml.org 
[lkml]   [2019]   [Dec]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [Patch v6 6/7] thermal/cpu-cooling: Update thermal pressure in case of a maximum frequency capping
    On Wednesday 11 Dec 2019 at 23:11:47 (-0500), Thara Gopinath wrote:
    [...]
    > @@ -430,6 +430,10 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev,
    > unsigned long state)
    > {
    > struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata;
    > + struct cpumask *cpus;
    > + unsigned int frequency;
    > + unsigned long capacity;
    > + int ret;
    >
    > /* Request state should be less than max_level */
    > if (WARN_ON(state > cpufreq_cdev->max_level))
    > @@ -441,8 +445,19 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev,
    >
    > cpufreq_cdev->cpufreq_state = state;
    >
    > - return freq_qos_update_request(&cpufreq_cdev->qos_req,
    > - get_state_freq(cpufreq_cdev, state));
    > + frequency = get_state_freq(cpufreq_cdev, state);
    > +
    > + ret = freq_qos_update_request(&cpufreq_cdev->qos_req, frequency);
    > +
    > + if (ret > 0) {
    > + cpus = cpufreq_cdev->policy->cpus;
    > + capacity = frequency *
    > + arch_scale_cpu_capacity(cpumask_first(cpus));
    > + capacity /= cpufreq_cdev->policy->cpuinfo.max_freq;
    > + arch_set_thermal_pressure(cpus, capacity);

    Given that you already get a CPU's capacity (orig) here, why don't
    you pass thermal pressure directly to arch_set_thermal_pressure,
    rather than passing the capped capacity and subtracting it later from
    the same CPU capacity (arch_scale_cpu_capacity)?

    If my math is correct this would work nicely:
    pressure = cpufreq_cdev->policy->cpuinfo.max_freq;
    pressure -= frequency;
    pressure *= arch_scale_cpu_capacity(cpumask_first(cpus);
    pressure /= cpufreq_cdev->policy->cpuinfo.max_freq;

    Thanks,
    Ionela.

    > + }
    > +
    > + return ret;
    > }
    >
    > /* Bind cpufreq callbacks to thermal cooling device ops */
    > --
    > 2.1.4
    >

    \
     
     \ /
      Last update: 2019-12-23 18:55    [W:4.532 / U:0.488 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site