Re: [PATCH 4/4] cpufreq: governor: Implement per policy instances of governors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11 February 2013 09:46, Viresh Kumar <viresh.kumar@xxxxxxxxxx> wrote:
> On 11 February 2013 02:44, Francesco Lavra <francescolavra.fl@xxxxxxxxx> wrote:
>> dbs_data->tuners is never freed, which means there is a memory leak
>> across CPUFREQ_GOV_POLICY_INIT and CPUFREQ_GOV_POLICY_EXIT events.
>>
>> The same goes for the ondemand governor.
>
> Thanks for pointing out. Would be fixed in next version.

Adding following to the original patch:

diff --git a/drivers/cpufreq/cpufreq_conservative.c
b/drivers/cpufreq/cpufreq_conservative.c
index 6b13f9f..5d03577 100644
--- a/drivers/cpufreq/cpufreq_conservative.c
+++ b/drivers/cpufreq/cpufreq_conservative.c
@@ -329,6 +329,11 @@ static int cs_init(struct dbs_data *dbs_data)
        return 0;
 }

+static void cs_exit(struct dbs_data *dbs_data)
+{
+       kfree(dbs_data->tuners);
+}
+
 define_get_cpu_dbs_routines(cs_cpu_dbs_info);

 static struct notifier_block cs_cpufreq_notifier_block = {
@@ -348,6 +353,7 @@ static struct common_dbs_data cs_dbs_cdata = {
        .gov_check_cpu = cs_check_cpu,
        .gov_ops = &cs_ops,
        .init = cs_init,
+       .exit = cs_exit,
 };

 static int cs_cpufreq_governor_dbs(struct cpufreq_policy *policy,
diff --git a/drivers/cpufreq/cpufreq_governor.c
b/drivers/cpufreq/cpufreq_governor.c
index 925f5b3..7722505 100644
--- a/drivers/cpufreq/cpufreq_governor.c
+++ b/drivers/cpufreq/cpufreq_governor.c
@@ -255,6 +255,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
                                        latency * LATENCY_MULTIPLIER));
                return 0;
        case CPUFREQ_GOV_POLICY_EXIT:
+               cdata->exit(dbs_data);
                kfree(dbs_data);
                policy->governor_data = NULL;
                return 0;
diff --git a/drivers/cpufreq/cpufreq_governor.h
b/drivers/cpufreq/cpufreq_governor.h
index 8bd8df6..6301790 100644
--- a/drivers/cpufreq/cpufreq_governor.h
+++ b/drivers/cpufreq/cpufreq_governor.h
@@ -139,6 +139,7 @@ struct common_dbs_data {
        void (*gov_dbs_timer)(struct work_struct *work);
        void (*gov_check_cpu)(int cpu, unsigned int load);
        int (*init)(struct dbs_data *dbs_data);
+       void (*exit)(struct dbs_data *dbs_data);

        /* Governor specific ops, see below */
        void *gov_ops;
diff --git a/drivers/cpufreq/cpufreq_ondemand.c
b/drivers/cpufreq/cpufreq_ondemand.c
index 5eda540..f2539e0 100644
--- a/drivers/cpufreq/cpufreq_ondemand.c
+++ b/drivers/cpufreq/cpufreq_ondemand.c
@@ -525,6 +525,11 @@ static int od_init(struct dbs_data *dbs_data)
        return 0;
 }

+static void od_exit(struct dbs_data *dbs_data)
+{
+       kfree(dbs_data->tuners);
+}
+
 define_get_cpu_dbs_routines(od_cpu_dbs_info);

 static struct od_ops od_ops = {
@@ -542,6 +547,7 @@ static struct common_dbs_data od_dbs_cdata = {
        .gov_check_cpu = od_check_cpu,
        .gov_ops = &od_ops,
        .init = od_init,
+       .exit = od_exit,
 };

 static int od_cpufreq_governor_dbs(struct cpufreq_policy *policy,
--
To unsubscribe from this list: send the line "unsubscribe cpufreq" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Devel]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Forum]     [Linux SCSI]

  Powered by Linux