Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1472615 > unrolled thread
| Started by | Juri Lelli <juri.lelli@arm.com> |
|---|---|
| First post | 2016-08-30 18:30 +0200 |
| Last post | 2016-09-01 11:00 +0200 |
| Articles | 5 — 2 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.
Re: [PATCH v6 2/8] arm: parse cpu capacity-dmips-mhz from DT Juri Lelli <juri.lelli@arm.com> - 2016-08-30 18:30 +0200
Re: [PATCH v6 2/8] arm: parse cpu capacity-dmips-mhz from DT Vincent Guittot <vincent.guittot@linaro.org> - 2016-08-31 10:20 +0200
Re: [PATCH v6 2/8] arm: parse cpu capacity-dmips-mhz from DT Juri Lelli <juri.lelli@arm.com> - 2016-08-31 19:10 +0200
Re: [PATCH v6 2/8] arm: parse cpu capacity-dmips-mhz from DT Vincent Guittot <vincent.guittot@linaro.org> - 2016-09-01 10:30 +0200
Re: [PATCH v6 2/8] arm: parse cpu capacity-dmips-mhz from DT Juri Lelli <juri.lelli@arm.com> - 2016-09-01 11:00 +0200
| From | Juri Lelli <juri.lelli@arm.com> |
|---|---|
| Date | 2016-08-30 18:30 +0200 |
| Subject | Re: [PATCH v6 2/8] arm: parse cpu capacity-dmips-mhz from DT |
| Message-ID | <sbU5b-7gZ-11@gated-at.bofh.it> |
Hi Vincent,
On 16/08/16 10:20, Vincent Guittot wrote:
> Hi Juri,
>
>
> On 19 July 2016 at 14:40, Juri Lelli <juri.lelli@arm.com> wrote:
[...]
> > +static int
> > +init_cpu_capacity_callback(struct notifier_block *nb,
> > + unsigned long val,
> > + void *data)
> > +{
> > + struct cpufreq_policy *policy = data;
> > + int cpu;
> > +
> > + if (cap_parsing_failed || cap_parsing_done)
> > + return 0;
> > +
> > + switch (val) {
> > + case CPUFREQ_NOTIFY:
> > + pr_debug("cpu_capacity: init cpu capacity for CPUs [%*pbl] (to_visit=%*pbl)\n",
> > + cpumask_pr_args(policy->related_cpus),
> > + cpumask_pr_args(cpus_to_visit));
> > + cpumask_andnot(cpus_to_visit,
> > + cpus_to_visit,
> > + policy->related_cpus);
> > + for_each_cpu(cpu, policy->related_cpus) {
> > + raw_capacity[cpu] = arch_scale_cpu_capacity(NULL, cpu) *
> > + policy->max / 1000UL;
>
> Should it be policy->cpuinfo.max_freq instead of policy->max ?
>
Right. I'll fix the arm64 bits as well.
> > + capacity_scale = max(raw_capacity[cpu], capacity_scale);
> > + }
> > + if (cpumask_empty(cpus_to_visit)) {
> > + normalize_cpu_capacity();
> > + kfree(raw_capacity);
> > + pr_debug("cpu_capacity: parsing done\n");
> > + cap_parsing_done = true;
>
> ok so you do that once with the 1st governor that will be registered
> for the CPU. Can't you unregister the notifier then ?
>
I tried, but the only place I could find to unregister it is from the
callback itself; and it is not possible to do so AFAIK. Suggestions?
Thanks for the review.
Best,
- Juri
[toc] | [next] | [standalone]
| From | Vincent Guittot <vincent.guittot@linaro.org> |
|---|---|
| Date | 2016-08-31 10:20 +0200 |
| Message-ID | <sc8Uy-8n3-21@gated-at.bofh.it> |
| In reply to | #1472615 |
On 30 August 2016 at 18:28, Juri Lelli <juri.lelli@arm.com> wrote:
> Hi Vincent,
>
> On 16/08/16 10:20, Vincent Guittot wrote:
>> Hi Juri,
>>
>>
>> On 19 July 2016 at 14:40, Juri Lelli <juri.lelli@arm.com> wrote:
>
> [...]
>
>> > +static int
>> > +init_cpu_capacity_callback(struct notifier_block *nb,
>> > + unsigned long val,
>> > + void *data)
>> > +{
>> > + struct cpufreq_policy *policy = data;
>> > + int cpu;
>> > +
>> > + if (cap_parsing_failed || cap_parsing_done)
>> > + return 0;
>> > +
>> > + switch (val) {
>> > + case CPUFREQ_NOTIFY:
>> > + pr_debug("cpu_capacity: init cpu capacity for CPUs [%*pbl] (to_visit=%*pbl)\n",
>> > + cpumask_pr_args(policy->related_cpus),
>> > + cpumask_pr_args(cpus_to_visit));
>> > + cpumask_andnot(cpus_to_visit,
>> > + cpus_to_visit,
>> > + policy->related_cpus);
>> > + for_each_cpu(cpu, policy->related_cpus) {
>> > + raw_capacity[cpu] = arch_scale_cpu_capacity(NULL, cpu) *
>> > + policy->max / 1000UL;
>>
>> Should it be policy->cpuinfo.max_freq instead of policy->max ?
>>
>
> Right. I'll fix the arm64 bits as well.
>
>> > + capacity_scale = max(raw_capacity[cpu], capacity_scale);
>> > + }
>> > + if (cpumask_empty(cpus_to_visit)) {
>> > + normalize_cpu_capacity();
>> > + kfree(raw_capacity);
>> > + pr_debug("cpu_capacity: parsing done\n");
>> > + cap_parsing_done = true;
>>
>> ok so you do that once with the 1st governor that will be registered
>> for the CPU. Can't you unregister the notifier then ?
>>
>
> I tried, but the only place I could find to unregister it is from the
> callback itself; and it is not possible to do so AFAIK. Suggestions?
yes, you're right
Can't you queue a work to unregister your callback ?
That's may be overkill but it seems weird to keep this notifier that
will do nothing, registered for the whole life of the system
>
> Thanks for the review.
>
> Best,
>
> - Juri
[toc] | [prev] | [next] | [standalone]
| From | Juri Lelli <juri.lelli@arm.com> |
|---|---|
| Date | 2016-08-31 19:10 +0200 |
| Message-ID | <schbs-59T-43@gated-at.bofh.it> |
| In reply to | #1473166 |
On 31/08/16 10:14, Vincent Guittot wrote:
> On 30 August 2016 at 18:28, Juri Lelli <juri.lelli@arm.com> wrote:
> > Hi Vincent,
> >
> > On 16/08/16 10:20, Vincent Guittot wrote:
> >> Hi Juri,
> >>
> >>
> >> On 19 July 2016 at 14:40, Juri Lelli <juri.lelli@arm.com> wrote:
> >
> > [...]
> >
> >> > +static int
> >> > +init_cpu_capacity_callback(struct notifier_block *nb,
> >> > + unsigned long val,
> >> > + void *data)
> >> > +{
> >> > + struct cpufreq_policy *policy = data;
> >> > + int cpu;
> >> > +
> >> > + if (cap_parsing_failed || cap_parsing_done)
> >> > + return 0;
> >> > +
> >> > + switch (val) {
> >> > + case CPUFREQ_NOTIFY:
> >> > + pr_debug("cpu_capacity: init cpu capacity for CPUs [%*pbl] (to_visit=%*pbl)\n",
> >> > + cpumask_pr_args(policy->related_cpus),
> >> > + cpumask_pr_args(cpus_to_visit));
> >> > + cpumask_andnot(cpus_to_visit,
> >> > + cpus_to_visit,
> >> > + policy->related_cpus);
> >> > + for_each_cpu(cpu, policy->related_cpus) {
> >> > + raw_capacity[cpu] = arch_scale_cpu_capacity(NULL, cpu) *
> >> > + policy->max / 1000UL;
> >>
> >> Should it be policy->cpuinfo.max_freq instead of policy->max ?
> >>
> >
> > Right. I'll fix the arm64 bits as well.
> >
> >> > + capacity_scale = max(raw_capacity[cpu], capacity_scale);
> >> > + }
> >> > + if (cpumask_empty(cpus_to_visit)) {
> >> > + normalize_cpu_capacity();
> >> > + kfree(raw_capacity);
> >> > + pr_debug("cpu_capacity: parsing done\n");
> >> > + cap_parsing_done = true;
> >>
> >> ok so you do that once with the 1st governor that will be registered
> >> for the CPU. Can't you unregister the notifier then ?
> >>
> >
> > I tried, but the only place I could find to unregister it is from the
> > callback itself; and it is not possible to do so AFAIK. Suggestions?
>
> yes, you're right
> Can't you queue a work to unregister your callback ?
You mean something like this? I guess I thought it would be much more
ugly. :)
If it looks OK, I'll add the same for arm64 and test it a bit more.
--->8---
arch/arm/kernel/topology.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/arch/arm/kernel/topology.c b/arch/arm/kernel/topology.c
index cbc57c287145..672ae22e2768 100644
--- a/arch/arm/kernel/topology.c
+++ b/arch/arm/kernel/topology.c
@@ -215,7 +215,8 @@ static void normalize_cpu_capacity(void)
#ifdef CONFIG_CPU_FREQ
static cpumask_var_t cpus_to_visit;
-static bool cap_parsing_done;
+static void parsing_done_workfn(struct work_struct *work);
+static DECLARE_WORK(parsing_done_work, parsing_done_workfn);
static int
init_cpu_capacity_callback(struct notifier_block *nb,
@@ -225,7 +226,7 @@ init_cpu_capacity_callback(struct notifier_block *nb,
struct cpufreq_policy *policy = data;
int cpu;
- if (cap_parsing_failed || cap_parsing_done)
+ if (cap_parsing_failed)
return 0;
switch (val) {
@@ -245,7 +246,7 @@ init_cpu_capacity_callback(struct notifier_block *nb,
normalize_cpu_capacity();
kfree(raw_capacity);
pr_debug("cpu_capacity: parsing done\n");
- cap_parsing_done = true;
+ schedule_work(&parsing_done_work);
}
}
return 0;
@@ -270,6 +271,13 @@ static int __init register_cpufreq_notifier(void)
CPUFREQ_POLICY_NOTIFIER);
}
core_initcall(register_cpufreq_notifier);
+
+static void parsing_done_workfn(struct work_struct *work)
+{
+ cpufreq_unregister_notifier(&init_cpu_capacity_notifier,
+ CPUFREQ_POLICY_NOTIFIER);
+}
+
#else
static int __init free_raw_capacity(void)
{
[toc] | [prev] | [next] | [standalone]
| From | Vincent Guittot <vincent.guittot@linaro.org> |
|---|---|
| Date | 2016-09-01 10:30 +0200 |
| Message-ID | <scvxL-70R-13@gated-at.bofh.it> |
| In reply to | #1473727 |
On 31 August 2016 at 19:08, Juri Lelli <juri.lelli@arm.com> wrote:
> On 31/08/16 10:14, Vincent Guittot wrote:
>> On 30 August 2016 at 18:28, Juri Lelli <juri.lelli@arm.com> wrote:
>> > Hi Vincent,
>> >
>> > On 16/08/16 10:20, Vincent Guittot wrote:
>> >> Hi Juri,
>> >>
>> >>
>> >> On 19 July 2016 at 14:40, Juri Lelli <juri.lelli@arm.com> wrote:
>> >
>> > [...]
>> >
>> >> > +static int
>> >> > +init_cpu_capacity_callback(struct notifier_block *nb,
>> >> > + unsigned long val,
>> >> > + void *data)
>> >> > +{
>> >> > + struct cpufreq_policy *policy = data;
>> >> > + int cpu;
>> >> > +
>> >> > + if (cap_parsing_failed || cap_parsing_done)
>> >> > + return 0;
>> >> > +
>> >> > + switch (val) {
>> >> > + case CPUFREQ_NOTIFY:
>> >> > + pr_debug("cpu_capacity: init cpu capacity for CPUs [%*pbl] (to_visit=%*pbl)\n",
>> >> > + cpumask_pr_args(policy->related_cpus),
>> >> > + cpumask_pr_args(cpus_to_visit));
>> >> > + cpumask_andnot(cpus_to_visit,
>> >> > + cpus_to_visit,
>> >> > + policy->related_cpus);
>> >> > + for_each_cpu(cpu, policy->related_cpus) {
>> >> > + raw_capacity[cpu] = arch_scale_cpu_capacity(NULL, cpu) *
>> >> > + policy->max / 1000UL;
>> >>
>> >> Should it be policy->cpuinfo.max_freq instead of policy->max ?
>> >>
>> >
>> > Right. I'll fix the arm64 bits as well.
>> >
>> >> > + capacity_scale = max(raw_capacity[cpu], capacity_scale);
>> >> > + }
>> >> > + if (cpumask_empty(cpus_to_visit)) {
>> >> > + normalize_cpu_capacity();
>> >> > + kfree(raw_capacity);
>> >> > + pr_debug("cpu_capacity: parsing done\n");
>> >> > + cap_parsing_done = true;
>> >>
>> >> ok so you do that once with the 1st governor that will be registered
>> >> for the CPU. Can't you unregister the notifier then ?
>> >>
>> >
>> > I tried, but the only place I could find to unregister it is from the
>> > callback itself; and it is not possible to do so AFAIK. Suggestions?
>>
>> yes, you're right
>> Can't you queue a work to unregister your callback ?
>
> You mean something like this? I guess I thought it would be much more
> ugly. :)
Yes something like below.
>
> If it looks OK, I'll add the same for arm64 and test it a bit more.
>
> --->8---
> arch/arm/kernel/topology.c | 14 +++++++++++---
> 1 file changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/arch/arm/kernel/topology.c b/arch/arm/kernel/topology.c
> index cbc57c287145..672ae22e2768 100644
> --- a/arch/arm/kernel/topology.c
> +++ b/arch/arm/kernel/topology.c
> @@ -215,7 +215,8 @@ static void normalize_cpu_capacity(void)
>
> #ifdef CONFIG_CPU_FREQ
> static cpumask_var_t cpus_to_visit;
> -static bool cap_parsing_done;
> +static void parsing_done_workfn(struct work_struct *work);
> +static DECLARE_WORK(parsing_done_work, parsing_done_workfn);
>
> static int
> init_cpu_capacity_callback(struct notifier_block *nb,
> @@ -225,7 +226,7 @@ init_cpu_capacity_callback(struct notifier_block *nb,
> struct cpufreq_policy *policy = data;
> int cpu;
>
> - if (cap_parsing_failed || cap_parsing_done)
> + if (cap_parsing_failed)
you probably need to keep cap_parsing_done to prevent spurious
notification until the work is scheduled
> return 0;
>
> switch (val) {
> @@ -245,7 +246,7 @@ init_cpu_capacity_callback(struct notifier_block *nb,
> normalize_cpu_capacity();
> kfree(raw_capacity);
> pr_debug("cpu_capacity: parsing done\n");
> - cap_parsing_done = true;
> + schedule_work(&parsing_done_work);
> }
> }
> return 0;
> @@ -270,6 +271,13 @@ static int __init register_cpufreq_notifier(void)
> CPUFREQ_POLICY_NOTIFIER);
> }
> core_initcall(register_cpufreq_notifier);
> +
> +static void parsing_done_workfn(struct work_struct *work)
> +{
> + cpufreq_unregister_notifier(&init_cpu_capacity_notifier,
> + CPUFREQ_POLICY_NOTIFIER);
> +}
> +
> #else
> static int __init free_raw_capacity(void)
> {
[toc] | [prev] | [next] | [standalone]
| From | Juri Lelli <juri.lelli@arm.com> |
|---|---|
| Date | 2016-09-01 11:00 +0200 |
| Message-ID | <scw0N-7nt-25@gated-at.bofh.it> |
| In reply to | #1474164 |
On 01/09/16 10:22, Vincent Guittot wrote:
> On 31 August 2016 at 19:08, Juri Lelli <juri.lelli@arm.com> wrote:
> > On 31/08/16 10:14, Vincent Guittot wrote:
> >> On 30 August 2016 at 18:28, Juri Lelli <juri.lelli@arm.com> wrote:
> >> > Hi Vincent,
> >> >
> >> > On 16/08/16 10:20, Vincent Guittot wrote:
> >> >> Hi Juri,
> >> >>
> >> >>
> >> >> On 19 July 2016 at 14:40, Juri Lelli <juri.lelli@arm.com> wrote:
> >> >
> >> > [...]
> >> >
> >> >> > +static int
> >> >> > +init_cpu_capacity_callback(struct notifier_block *nb,
> >> >> > + unsigned long val,
> >> >> > + void *data)
> >> >> > +{
> >> >> > + struct cpufreq_policy *policy = data;
> >> >> > + int cpu;
> >> >> > +
> >> >> > + if (cap_parsing_failed || cap_parsing_done)
> >> >> > + return 0;
> >> >> > +
> >> >> > + switch (val) {
> >> >> > + case CPUFREQ_NOTIFY:
> >> >> > + pr_debug("cpu_capacity: init cpu capacity for CPUs [%*pbl] (to_visit=%*pbl)\n",
> >> >> > + cpumask_pr_args(policy->related_cpus),
> >> >> > + cpumask_pr_args(cpus_to_visit));
> >> >> > + cpumask_andnot(cpus_to_visit,
> >> >> > + cpus_to_visit,
> >> >> > + policy->related_cpus);
> >> >> > + for_each_cpu(cpu, policy->related_cpus) {
> >> >> > + raw_capacity[cpu] = arch_scale_cpu_capacity(NULL, cpu) *
> >> >> > + policy->max / 1000UL;
> >> >>
> >> >> Should it be policy->cpuinfo.max_freq instead of policy->max ?
> >> >>
> >> >
> >> > Right. I'll fix the arm64 bits as well.
> >> >
> >> >> > + capacity_scale = max(raw_capacity[cpu], capacity_scale);
> >> >> > + }
> >> >> > + if (cpumask_empty(cpus_to_visit)) {
> >> >> > + normalize_cpu_capacity();
> >> >> > + kfree(raw_capacity);
> >> >> > + pr_debug("cpu_capacity: parsing done\n");
> >> >> > + cap_parsing_done = true;
> >> >>
> >> >> ok so you do that once with the 1st governor that will be registered
> >> >> for the CPU. Can't you unregister the notifier then ?
> >> >>
> >> >
> >> > I tried, but the only place I could find to unregister it is from the
> >> > callback itself; and it is not possible to do so AFAIK. Suggestions?
> >>
> >> yes, you're right
> >> Can't you queue a work to unregister your callback ?
> >
> > You mean something like this? I guess I thought it would be much more
> > ugly. :)
>
> Yes something like below.
>
> >
> > If it looks OK, I'll add the same for arm64 and test it a bit more.
> >
> > --->8---
> > arch/arm/kernel/topology.c | 14 +++++++++++---
> > 1 file changed, 11 insertions(+), 3 deletions(-)
> >
> > diff --git a/arch/arm/kernel/topology.c b/arch/arm/kernel/topology.c
> > index cbc57c287145..672ae22e2768 100644
> > --- a/arch/arm/kernel/topology.c
> > +++ b/arch/arm/kernel/topology.c
> > @@ -215,7 +215,8 @@ static void normalize_cpu_capacity(void)
> >
> > #ifdef CONFIG_CPU_FREQ
> > static cpumask_var_t cpus_to_visit;
> > -static bool cap_parsing_done;
> > +static void parsing_done_workfn(struct work_struct *work);
> > +static DECLARE_WORK(parsing_done_work, parsing_done_workfn);
> >
> > static int
> > init_cpu_capacity_callback(struct notifier_block *nb,
> > @@ -225,7 +226,7 @@ init_cpu_capacity_callback(struct notifier_block *nb,
> > struct cpufreq_policy *policy = data;
> > int cpu;
> >
> > - if (cap_parsing_failed || cap_parsing_done)
> > + if (cap_parsing_failed)
>
> you probably need to keep cap_parsing_done to prevent spurious
> notification until the work is scheduled
>
OK. Thanks.
Best,
- Juri
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web