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


Groups > linux.kernel > #1247943

[PATCH V2 5/5] cpufreq: postfix policy directory with the first CPU in related_cpus

From Viresh Kumar <viresh.kumar@linaro.org>
Newsgroups linux.kernel
Subject [PATCH V2 5/5] cpufreq: postfix policy directory with the first CPU in related_cpus
Date 2015-10-15 18:10 +0200
Message-ID <qjTgm-2Z7-33@gated-at.bofh.it> (permalink)
References <qjTgm-2Z7-21@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


The sysfs policy directory is postfixed currently with the CPU number
for which the policy was created, which isn't necessarily the first CPU
in related_cpus mask.

To make it more consistent and predictable, lets postfix the policy with
the first cpu in related-cpus mask.

Suggested-by: Saravana Kannan <skannan@codeaurora.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/cpufreq.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 4fa2215cc6ec..3fe13875565d 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1022,7 +1022,6 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu)
 {
 	struct device *dev = get_cpu_device(cpu);
 	struct cpufreq_policy *policy;
-	int ret;
 
 	if (WARN_ON(!dev))
 		return NULL;
@@ -1040,13 +1039,6 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu)
 	if (!zalloc_cpumask_var(&policy->real_cpus, GFP_KERNEL))
 		goto err_free_rcpumask;
 
-	ret = kobject_init_and_add(&policy->kobj, &ktype_cpufreq,
-				   cpufreq_global_kobject, "policy%u", cpu);
-	if (ret) {
-		pr_err("%s: failed to init policy->kobj: %d\n", __func__, ret);
-		goto err_free_real_cpus;
-	}
-
 	INIT_LIST_HEAD(&policy->policy_list);
 	init_rwsem(&policy->rwsem);
 	spin_lock_init(&policy->transition_lock);
@@ -1057,7 +1049,6 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu)
 	policy->cpu = cpu;
 	return policy;
 
-err_free_real_cpus:
 	free_cpumask_var(policy->real_cpus);
 err_free_rcpumask:
 	free_cpumask_var(policy->related_cpus);
@@ -1163,6 +1154,16 @@ static int cpufreq_online(unsigned int cpu)
 		cpumask_copy(policy->related_cpus, policy->cpus);
 		/* Remember CPUs present at the policy creation time. */
 		cpumask_and(policy->real_cpus, policy->cpus, cpu_present_mask);
+
+		/* Initialize the kobject */
+		ret = kobject_init_and_add(&policy->kobj, &ktype_cpufreq,
+					   cpufreq_global_kobject, "policy%u",
+					   cpumask_first(policy->related_cpus));
+		if (ret) {
+			pr_err("%s: failed to init policy->kobj: %d\n",
+			       __func__, ret);
+			goto out_exit_policy;
+		}
 	}
 
 	/*
-- 
2.4.0

--
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/

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH V2 5/5] cpufreq: postfix policy directory with the first CPU in related_cpus Viresh Kumar <viresh.kumar@linaro.org> - 2015-10-15 18:10 +0200
  Re: [PATCH V2 5/5] cpufreq: postfix policy directory with the first  CPU in related_cpus Saravana Kannan <skannan@codeaurora.org> - 2015-10-15 21:20 +0200
    Re: [PATCH V2 5/5] cpufreq: postfix policy directory with the first  CPU in related_cpus Viresh Kumar <viresh.kumar@linaro.org> - 2015-10-16 09:10 +0200
      [PATCH V3 5/5] cpufreq: postfix policy directory with the first CPU in related_cpus Viresh Kumar <viresh.kumar@linaro.org> - 2015-10-16 09:20 +0200
        Re: [PATCH V3 5/5] cpufreq: postfix policy directory with the first  CPU in related_cpus Saravana Kannan <skannan@codeaurora.org> - 2015-10-16 22:00 +0200
          Re: [PATCH V3 5/5] cpufreq: postfix policy directory with the first  CPU in related_cpus Viresh Kumar <viresh.kumar@linaro.org> - 2015-10-17 06:30 +0200

csiph-web