diff mbox

[v6,1/8] cpufreq: Store cpufreq policies in a list

Message ID 1374770011-22171-2-git-send-email-l.majewski@samsung.com (mailing list archive)
State Changes Requested, archived
Headers show

Commit Message

Lukasz Majewski July 25, 2013, 4:33 p.m. UTC
Policies available in a cpufreq framework are now linked together. They are
accessible via cpufreq_policy_list defined at cpufreq core.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>

---
Changes for v6:
- Move policy list entry delete code to __cpufreq_remove_dev()
- Protect operations on cpufreq_policy_list elements with lock

Changes for v5:
- Call list_add() only when device successfully added

Changes for v4:
- New patch

 drivers/cpufreq/cpufreq.c |    9 +++++++++
 include/linux/cpufreq.h   |    1 +
 2 files changed, 10 insertions(+)

Comments

Viresh Kumar July 26, 2013, 10:14 a.m. UTC | #1
On 25 July 2013 22:03, Lukasz Majewski <l.majewski@samsung.com> wrote:
> Policies available in a cpufreq framework are now linked together. They are
> accessible via cpufreq_policy_list defined at cpufreq core.
>
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>

Looks good but would have been better if you could have moved
existing code to use this infrastructure..

For example, this code in __cpufreq_add_dev()

#ifdef CONFIG_HOTPLUG_CPU
	/* Check if this cpu was hot-unplugged earlier and has siblings */
	read_lock_irqsave(&cpufreq_driver_lock, flags);
	for_each_online_cpu(sibling) {

         ---

	}
	read_unlock_irqrestore(&cpufreq_driver_lock, flags);
#endif
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Lukasz Majewski July 26, 2013, 10:58 a.m. UTC | #2
On Fri, 26 Jul 2013 15:44:29 +0530 Viresh Kumar viresh.kumar@linaro.org
wrote,
> On 25 July 2013 22:03, Lukasz Majewski <l.majewski@samsung.com> wrote:
> > Policies available in a cpufreq framework are now linked together.
> > They are accessible via cpufreq_policy_list defined at cpufreq core.
> >
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>
> 
> Looks good but would have been better if you could have moved
> existing code to use this infrastructure..
> 
> For example, this code in __cpufreq_add_dev()
> 
> #ifdef CONFIG_HOTPLUG_CPU
> 	/* Check if this cpu was hot-unplugged earlier and has
> siblings */ read_lock_irqsave(&cpufreq_driver_lock, flags);
> 	for_each_online_cpu(sibling) {
> 
>          ---
> 
> 	}
> 	read_unlock_irqrestore(&cpufreq_driver_lock, flags);
> #endif

Do you mean to write something like:

#ifdef CONFIG_CPU_FREQ_BOOST_SW
	write_lock_irqsave(&cpufreq_driver_lock, flags);
	list_add(&policy->policy_list, &cpufreq_policy_list);
	write_unlock_irqrestore(&cpufreq_driver_lock, flags);
#endif

Or Am I missing something?
Viresh Kumar July 26, 2013, 11:02 a.m. UTC | #3
On 26 July 2013 16:28, Lukasz Majewski <l.majewski@samsung.com> wrote:
> On Fri, 26 Jul 2013 15:44:29 +0530 Viresh Kumar viresh.kumar@linaro.org
> wrote,
>> On 25 July 2013 22:03, Lukasz Majewski <l.majewski@samsung.com> wrote:

>> Looks good but would have been better if you could have moved
>> existing code to use this infrastructure..
>>
>> For example, this code in __cpufreq_add_dev()
>>
>> #ifdef CONFIG_HOTPLUG_CPU
>>       /* Check if this cpu was hot-unplugged earlier and has
>> siblings */ read_lock_irqsave(&cpufreq_driver_lock, flags);
>>       for_each_online_cpu(sibling) {
>>
>>          ---
>>
>>       }
>>       read_unlock_irqrestore(&cpufreq_driver_lock, flags);
>> #endif
>
> Do you mean to write something like:
>
> #ifdef CONFIG_CPU_FREQ_BOOST_SW
>         write_lock_irqsave(&cpufreq_driver_lock, flags);
>         list_add(&policy->policy_list, &cpufreq_policy_list);
>         write_unlock_irqrestore(&cpufreq_driver_lock, flags);
> #endif
>
> Or Am I missing something?

I can't imaging how you though I am saying this :)

The code I mentioned actually requires to iterate through the
list of available policies but was iterating over all online cpus..

And so your new infrastructure or this list can be used instead
of looping for all cpus.
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Lukasz Majewski July 26, 2013, 12:46 p.m. UTC | #4
On Fri, 26 Jul 2013 16:32:34 +0530 Viresh Kumar viresh.kumar@linaro.org
wrote,
> On 26 July 2013 16:28, Lukasz Majewski <l.majewski@samsung.com> wrote:
> > On Fri, 26 Jul 2013 15:44:29 +0530 Viresh Kumar
> > viresh.kumar@linaro.org wrote,
> >> On 25 July 2013 22:03, Lukasz Majewski <l.majewski@samsung.com>
> >> wrote:
> 
> >> Looks good but would have been better if you could have moved
> >> existing code to use this infrastructure..
> >>
> >> For example, this code in __cpufreq_add_dev()
> >>
> >> #ifdef CONFIG_HOTPLUG_CPU
> >>       /* Check if this cpu was hot-unplugged earlier and has
> >> siblings */ read_lock_irqsave(&cpufreq_driver_lock, flags);
> >>       for_each_online_cpu(sibling) {
> >>
> >>          ---
> >>
> >>       }
> >>       read_unlock_irqrestore(&cpufreq_driver_lock, flags);
> >> #endif
> >
> > Do you mean to write something like:
> >
> > #ifdef CONFIG_CPU_FREQ_BOOST_SW
> >         write_lock_irqsave(&cpufreq_driver_lock, flags);
> >         list_add(&policy->policy_list, &cpufreq_policy_list);
> >         write_unlock_irqrestore(&cpufreq_driver_lock, flags);
> > #endif
> >
> > Or Am I missing something?
> 
> I can't imaging how you though I am saying this :)
>

:-)
 
> The code I mentioned actually requires to iterate through the
> list of available policies but was iterating over all online cpus..
> 
> And so your new infrastructure or this list can be used instead
> of looping for all cpus.

So instead of reading policies from per_cpu variables for all online
cpus, you think of using the list explicitly.

Good idea, but can we first finish the boost patches? Such change can
be applied on top of boost patch series as well.
Viresh Kumar July 29, 2013, 7:03 a.m. UTC | #5
On 26 July 2013 18:16, Lukasz Majewski <l.majewski@samsung.com> wrote:
> So instead of reading policies from per_cpu variables for all online
> cpus, you think of using the list explicitly.
>
> Good idea, but can we first finish the boost patches? Such change can
> be applied on top of boost patch series as well.

Its not a problem where we do it. But making sure that we do it :)
If you need to resend this patchset, then that list can be used at the
place I just highlighted.. Change isn't big and so shouldn't be a problem.

Otherwise it might get missed by both of us.
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 0937b8d..172a25e 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -46,6 +46,7 @@  static struct cpufreq_driver *cpufreq_driver;
 static DEFINE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_data);
 static DEFINE_RWLOCK(cpufreq_driver_lock);
 static DEFINE_MUTEX(cpufreq_governor_lock);
+static LIST_HEAD(cpufreq_policy_list);
 
 #ifdef CONFIG_HOTPLUG_CPU
 /* This one keeps track of the previously set governor of a removed CPU */
@@ -1054,6 +1055,10 @@  static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif)
 	if (ret)
 		goto err_out_unregister;
 
+	write_lock_irqsave(&cpufreq_driver_lock, flags);
+	list_add(&policy->policy_list, &cpufreq_policy_list);
+	write_unlock_irqrestore(&cpufreq_driver_lock, flags);
+
 	kobject_uevent(&policy->kobj, KOBJ_ADD);
 	module_put(cpufreq_driver->owner);
 	pr_debug("initialization complete\n");
@@ -1202,6 +1207,10 @@  static int __cpufreq_remove_dev(struct device *dev,
 		if (cpufreq_driver->exit)
 			cpufreq_driver->exit(data);
 
+		write_lock_irqsave(&cpufreq_driver_lock, flags);
+		list_del(&data->policy_list);
+		write_unlock_irqrestore(&cpufreq_driver_lock, flags);
+
 		free_cpumask_var(data->related_cpus);
 		free_cpumask_var(data->cpus);
 		kfree(data);
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 90d5a15..d8e30fc 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -117,6 +117,7 @@  struct cpufreq_policy {
 
 	struct cpufreq_real_policy	user_policy;
 
+	struct list_head        policy_list;
 	struct kobject		kobj;
 	struct completion	kobj_unregister;
 	int			transition_ongoing; /* Tracks transition status */