Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1274601 > unrolled thread

[PATCH V2] cpufreq: Always remove sysfs cpuX/cpufreq link on ->remove_dev()

Started byViresh Kumar <viresh.kumar@linaro.org>
First post2015-11-21 04:40 +0100
Last post2015-11-23 23:20 +0100
Articles 3 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH V2] cpufreq: Always remove sysfs cpuX/cpufreq link on ->remove_dev() Viresh Kumar <viresh.kumar@linaro.org> - 2015-11-21 04:40 +0100
    Re: [PATCH V2] cpufreq: Always remove sysfs cpuX/cpufreq link on  ->remove_dev() Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> - 2015-11-21 15:50 +0100
      Re: [PATCH V2] cpufreq: Always remove sysfs cpuX/cpufreq link on ->remove_dev() "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2015-11-23 23:20 +0100

#1274601 — [PATCH V2] cpufreq: Always remove sysfs cpuX/cpufreq link on ->remove_dev()

FromViresh Kumar <viresh.kumar@linaro.org>
Date2015-11-21 04:40 +0100
Subject[PATCH V2] cpufreq: Always remove sysfs cpuX/cpufreq link on ->remove_dev()
Message-ID<qx7bP-89u-13@gated-at.bofh.it>
Subsys interface's ->remove_dev() is called when the cpufreq driver is
unregistering or the CPU is getting physically removed. We keep removing
the cpuX/cpufreq link for all CPUs except the last one, which is a
mistake as all CPUs contain a link now.

Because of this, one CPU from each policy will still contain a link (to
an already removed policyX directory), after the cpufreq driver is
unregistered.

Fix that by removing the link first and then only see if the policy is
required to be freed. That will make sure that no links are left out.

Fixes: 96bdda61f58b ("cpufreq: create cpu/cpufreq/policyX directories")
Reported-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
[v2] Drop the unnecessary 'return', sorry about that :(

 drivers/cpufreq/cpufreq.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 7c48e7316d91..a83c995a62df 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1401,13 +1401,10 @@ static void cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif)
 	}
 
 	cpumask_clear_cpu(cpu, policy->real_cpus);
+	remove_cpu_dev_symlink(policy, cpu);
 
-	if (cpumask_empty(policy->real_cpus)) {
+	if (cpumask_empty(policy->real_cpus))
 		cpufreq_policy_free(policy, true);
-		return;
-	}
-
-	remove_cpu_dev_symlink(policy, cpu);
 }
 
 static void handle_update(struct work_struct *work)
-- 
2.6.2.198.g614a2ac

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1274670 — Re: [PATCH V2] cpufreq: Always remove sysfs cpuX/cpufreq link on ->remove_dev()

FromSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Date2015-11-21 15:50 +0100
SubjectRe: [PATCH V2] cpufreq: Always remove sysfs cpuX/cpufreq link on ->remove_dev()
Message-ID<qxhEd-6AU-7@gated-at.bofh.it>
In reply to#1274601
On Sat, 2015-11-21 at 09:06 +0530, Viresh Kumar wrote:
> Subsys interface's ->remove_dev() is called when the cpufreq driver
> is
> unregistering or the CPU is getting physically removed. We keep
> removing
> the cpuX/cpufreq link for all CPUs except the last one, which is a
> mistake as all CPUs contain a link now.
> 
> Because of this, one CPU from each policy will still contain a link
> (to
> an already removed policyX directory), after the cpufreq driver is
> unregistered.
> 
> Fix that by removing the link first and then only see if the policy
> is
> required to be freed. That will make sure that no links are left out.
> 
> Fixes: 96bdda61f58b ("cpufreq: create cpu/cpufreq/policyX
> directories")
> Reported-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com

Tested-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com
> >
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
> [v2] Drop the unnecessary 'return', sorry about that :(
> 
>  drivers/cpufreq/cpufreq.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 7c48e7316d91..a83c995a62df 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -1401,13 +1401,10 @@ static void cpufreq_remove_dev(struct device
> *dev, struct subsys_interface *sif)
>  	}
>  
>  	cpumask_clear_cpu(cpu, policy->real_cpus);
> +	remove_cpu_dev_symlink(policy, cpu);
>  
> -	if (cpumask_empty(policy->real_cpus)) {
> +	if (cpumask_empty(policy->real_cpus))
>  		cpufreq_policy_free(policy, true);
> -		return;
> -	}
> -
> -	remove_cpu_dev_symlink(policy, cpu);
>  }
>  
>  static void handle_update(struct work_struct *work)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1275930

From"Rafael J. Wysocki" <rjw@rjwysocki.net>
Date2015-11-23 23:20 +0100
Message-ID<qy7CQ-7Sa-37@gated-at.bofh.it>
In reply to#1274670
On Saturday, November 21, 2015 06:42:09 AM Srinivas Pandruvada wrote:
> On Sat, 2015-11-21 at 09:06 +0530, Viresh Kumar wrote:
> > Subsys interface's ->remove_dev() is called when the cpufreq driver
> > is
> > unregistering or the CPU is getting physically removed. We keep
> > removing
> > the cpuX/cpufreq link for all CPUs except the last one, which is a
> > mistake as all CPUs contain a link now.
> > 
> > Because of this, one CPU from each policy will still contain a link
> > (to
> > an already removed policyX directory), after the cpufreq driver is
> > unregistered.
> > 
> > Fix that by removing the link first and then only see if the policy
> > is
> > required to be freed. That will make sure that no links are left out.
> > 
> > Fixes: 96bdda61f58b ("cpufreq: create cpu/cpufreq/policyX
> > directories")
> > Reported-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com
> 
> Tested-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com

Applied, thanks!

Rafael

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web