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


Groups > linux.kernel > #1698502 > unrolled thread

[PATCH V5 2/2] cpufreq: Process remote callbacks from any CPU if the platform permits

Started byViresh Kumar <viresh.kumar@linaro.org>
First post2017-07-28 08:50 +0200
Last post2017-08-02 05:50 +0200
Articles 6 — 4 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 V5 2/2] cpufreq: Process remote callbacks from any CPU if the platform permits Viresh Kumar <viresh.kumar@linaro.org> - 2017-07-28 08:50 +0200
    Re: [PATCH V5 2/2] cpufreq: Process remote callbacks from any CPU if  the platform permits Joel Fernandes <joelaf@google.com> - 2017-07-29 05:50 +0200
      Re: [PATCH V5 2/2] cpufreq: Process remote callbacks from any CPU if  the platform permits Viresh Kumar <viresh.kumar@linaro.org> - 2017-07-31 06:10 +0200
    Re: [PATCH V5 2/2] cpufreq: Process remote callbacks from any CPU  if the platform permits Saravana Kannan <skannan@codeaurora.org> - 2017-07-31 23:30 +0200
    Re: [Eas-dev] [PATCH V5 2/2] cpufreq: Process remote callbacks from  any CPU if the platform permits Pavan Kondeti <pkondeti@codeaurora.org> - 2017-08-01 13:10 +0200
      Re: [Eas-dev] [PATCH V5 2/2] cpufreq: Process remote callbacks from  any CPU if the platform permits Viresh Kumar <viresh.kumar@linaro.org> - 2017-08-02 05:50 +0200

#1698502 — [PATCH V5 2/2] cpufreq: Process remote callbacks from any CPU if the platform permits

FromViresh Kumar <viresh.kumar@linaro.org>
Date2017-07-28 08:50 +0200
Subject[PATCH V5 2/2] cpufreq: Process remote callbacks from any CPU if the platform permits
Message-ID<u87fX-dv-7@gated-at.bofh.it>
On many platforms, CPUs can do DVFS across cpufreq policies. i.e CPU
from policy-A can change frequency of CPUs belonging to policy-B.

This is quite common in case of ARM platforms where we don't
configure any per-cpu register.

Add a flag to identify such platforms and update
cpufreq_can_do_remote_dvfs() to allow remote callbacks if this flag is
set.

Also enable the flag for cpufreq-dt driver which is used only on ARM
platforms currently.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/cpufreq-dt.c |  1 +
 include/linux/cpufreq.h      | 18 ++++++++++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c
index fef3c2160691..d83ab94d041a 100644
--- a/drivers/cpufreq/cpufreq-dt.c
+++ b/drivers/cpufreq/cpufreq-dt.c
@@ -274,6 +274,7 @@ static int cpufreq_init(struct cpufreq_policy *policy)
 		transition_latency = CPUFREQ_ETERNAL;
 
 	policy->cpuinfo.transition_latency = transition_latency;
+	policy->dvfs_possible_from_any_cpu = true;
 
 	return 0;
 
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index b3b6e8203e82..227cd0f13300 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -127,6 +127,15 @@ struct cpufreq_policy {
 	 */
 	unsigned int		transition_delay_us;
 
+	/*
+	 * Remote DVFS flag (Not added to the driver structure as we don't want
+	 * to access another structure from scheduler hotpath).
+	 *
+	 * Should be set if CPUs can do DVFS on behalf of other CPUs from
+	 * different cpufreq policies.
+	 */
+	bool			dvfs_possible_from_any_cpu;
+
 	 /* Cached frequency lookup from cpufreq_driver_resolve_freq. */
 	unsigned int cached_target_freq;
 	int cached_resolved_idx;
@@ -564,8 +573,13 @@ struct governor_attr {
 
 static inline bool cpufreq_can_do_remote_dvfs(struct cpufreq_policy *policy)
 {
-	/* Allow remote callbacks only on the CPUs sharing cpufreq policy */
-	if (cpumask_test_cpu(smp_processor_id(), policy->cpus))
+	/*
+	 * Allow remote callbacks if:
+	 * - dvfs_possible_from_any_cpu flag is set
+	 * - the local and remote CPUs share cpufreq policy
+	 */
+	if (policy->dvfs_possible_from_any_cpu ||
+	    cpumask_test_cpu(smp_processor_id(), policy->cpus))
 		return true;
 
 	return false;
-- 
2.13.0.71.gd7076ec9c9cb

[toc] | [next] | [standalone]


#1699209 — Re: [PATCH V5 2/2] cpufreq: Process remote callbacks from any CPU if the platform permits

FromJoel Fernandes <joelaf@google.com>
Date2017-07-29 05:50 +0200
SubjectRe: [PATCH V5 2/2] cpufreq: Process remote callbacks from any CPU if the platform permits
Message-ID<u8qVj-4Ur-1@gated-at.bofh.it>
In reply to#1698502
On Thu, Jul 27, 2017 at 11:46 PM, Viresh Kumar <viresh.kumar@linaro.org> wrote:
> On many platforms, CPUs can do DVFS across cpufreq policies. i.e CPU
> from policy-A can change frequency of CPUs belonging to policy-B.
>
> This is quite common in case of ARM platforms where we don't
> configure any per-cpu register.
>
> Add a flag to identify such platforms and update
> cpufreq_can_do_remote_dvfs() to allow remote callbacks if this flag is
> set.
>
> Also enable the flag for cpufreq-dt driver which is used only on ARM
> platforms currently.
>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
>  drivers/cpufreq/cpufreq-dt.c |  1 +
>  include/linux/cpufreq.h      | 18 ++++++++++++++++--
>  2 files changed, 17 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c
> index fef3c2160691..d83ab94d041a 100644
> --- a/drivers/cpufreq/cpufreq-dt.c
> +++ b/drivers/cpufreq/cpufreq-dt.c
> @@ -274,6 +274,7 @@ static int cpufreq_init(struct cpufreq_policy *policy)
>                 transition_latency = CPUFREQ_ETERNAL;
>
>         policy->cpuinfo.transition_latency = transition_latency;
> +       policy->dvfs_possible_from_any_cpu = true;
>

Are there also ARM hardware that may not support it? If yes, wouldn't
a saner thing to do be to keep default as false and read the property
from DT for hardware that does support it and then set to true?

thanks,

-Joel

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


#1699676 — Re: [PATCH V5 2/2] cpufreq: Process remote callbacks from any CPU if the platform permits

FromViresh Kumar <viresh.kumar@linaro.org>
Date2017-07-31 06:10 +0200
SubjectRe: [PATCH V5 2/2] cpufreq: Process remote callbacks from any CPU if the platform permits
Message-ID<u9abL-1nS-5@gated-at.bofh.it>
In reply to#1699209
On 28-07-17, 20:43, Joel Fernandes wrote:
> On Thu, Jul 27, 2017 at 11:46 PM, Viresh Kumar <viresh.kumar@linaro.org> wrote:
> > On many platforms, CPUs can do DVFS across cpufreq policies. i.e CPU
> > from policy-A can change frequency of CPUs belonging to policy-B.
> >
> > This is quite common in case of ARM platforms where we don't
> > configure any per-cpu register.
> >
> > Add a flag to identify such platforms and update
> > cpufreq_can_do_remote_dvfs() to allow remote callbacks if this flag is
> > set.
> >
> > Also enable the flag for cpufreq-dt driver which is used only on ARM
> > platforms currently.
> >
> > Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> > ---
> >  drivers/cpufreq/cpufreq-dt.c |  1 +
> >  include/linux/cpufreq.h      | 18 ++++++++++++++++--
> >  2 files changed, 17 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c
> > index fef3c2160691..d83ab94d041a 100644
> > --- a/drivers/cpufreq/cpufreq-dt.c
> > +++ b/drivers/cpufreq/cpufreq-dt.c
> > @@ -274,6 +274,7 @@ static int cpufreq_init(struct cpufreq_policy *policy)
> >                 transition_latency = CPUFREQ_ETERNAL;
> >
> >         policy->cpuinfo.transition_latency = transition_latency;
> > +       policy->dvfs_possible_from_any_cpu = true;
> >
> 
> Are there also ARM hardware that may not support it?

I don't think so. ARM never had any per-cpu register interface which may break
due to this.

> If yes, wouldn't
> a saner thing to do be to keep default as false and read the property
> from DT for hardware that does support it and then set to true?

I would do it if required, but for now I don't think there are any such users of
cpufreq-dt.

-- 
viresh

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


#1700400 — Re: [PATCH V5 2/2] cpufreq: Process remote callbacks from any CPU if the platform permits

FromSaravana Kannan <skannan@codeaurora.org>
Date2017-07-31 23:30 +0200
SubjectRe: [PATCH V5 2/2] cpufreq: Process remote callbacks from any CPU if the platform permits
Message-ID<u9qqd-2Vo-3@gated-at.bofh.it>
In reply to#1698502
On 07/27/2017 11:46 PM, Viresh Kumar wrote:
> On many platforms, CPUs can do DVFS across cpufreq policies. i.e CPU
> from policy-A can change frequency of CPUs belonging to policy-B.
>
> This is quite common in case of ARM platforms where we don't
> configure any per-cpu register.
>
> Add a flag to identify such platforms and update
> cpufreq_can_do_remote_dvfs() to allow remote callbacks if this flag is
> set.
>
> Also enable the flag for cpufreq-dt driver which is used only on ARM
> platforms currently.
>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
>   drivers/cpufreq/cpufreq-dt.c |  1 +
>   include/linux/cpufreq.h      | 18 ++++++++++++++++--
>   2 files changed, 17 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c
> index fef3c2160691..d83ab94d041a 100644
> --- a/drivers/cpufreq/cpufreq-dt.c
> +++ b/drivers/cpufreq/cpufreq-dt.c
> @@ -274,6 +274,7 @@ static int cpufreq_init(struct cpufreq_policy *policy)
>   		transition_latency = CPUFREQ_ETERNAL;
>
>   	policy->cpuinfo.transition_latency = transition_latency;
> +	policy->dvfs_possible_from_any_cpu = true;
>
>   	return 0;
>
> diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
> index b3b6e8203e82..227cd0f13300 100644
> --- a/include/linux/cpufreq.h
> +++ b/include/linux/cpufreq.h
> @@ -127,6 +127,15 @@ struct cpufreq_policy {
>   	 */
>   	unsigned int		transition_delay_us;
>
> +	/*
> +	 * Remote DVFS flag (Not added to the driver structure as we don't want
> +	 * to access another structure from scheduler hotpath).
> +	 *
> +	 * Should be set if CPUs can do DVFS on behalf of other CPUs from
> +	 * different cpufreq policies.
> +	 */
> +	bool			dvfs_possible_from_any_cpu;
> +

Seems reasonable. This is something that can be easily set by the driver.

>   	 /* Cached frequency lookup from cpufreq_driver_resolve_freq. */
>   	unsigned int cached_target_freq;
>   	int cached_resolved_idx;
> @@ -564,8 +573,13 @@ struct governor_attr {
>
>   static inline bool cpufreq_can_do_remote_dvfs(struct cpufreq_policy *policy)
>   {
> -	/* Allow remote callbacks only on the CPUs sharing cpufreq policy */
> -	if (cpumask_test_cpu(smp_processor_id(), policy->cpus))
> +	/*
> +	 * Allow remote callbacks if:
> +	 * - dvfs_possible_from_any_cpu flag is set
> +	 * - the local and remote CPUs share cpufreq policy
> +	 */
> +	if (policy->dvfs_possible_from_any_cpu ||
> +	    cpumask_test_cpu(smp_processor_id(), policy->cpus))
>   		return true;
>
>   	return false;
>

Acked-by: Saravana Kannan <skannan@codeaurora.org>


-- 
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

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


#1700874 — Re: [Eas-dev] [PATCH V5 2/2] cpufreq: Process remote callbacks from any CPU if the platform permits

FromPavan Kondeti <pkondeti@codeaurora.org>
Date2017-08-01 13:10 +0200
SubjectRe: [Eas-dev] [PATCH V5 2/2] cpufreq: Process remote callbacks from any CPU if the platform permits
Message-ID<u9DdM-3gc-27@gated-at.bofh.it>
In reply to#1698502
On Fri, Jul 28, 2017 at 12:16 PM, Viresh Kumar <viresh.kumar@linaro.org> wrote:
> On many platforms, CPUs can do DVFS across cpufreq policies. i.e CPU
> from policy-A can change frequency of CPUs belonging to policy-B.
>
> This is quite common in case of ARM platforms where we don't
> configure any per-cpu register.
>
> Add a flag to identify such platforms and update
> cpufreq_can_do_remote_dvfs() to allow remote callbacks if this flag is
> set.
>
> Also enable the flag for cpufreq-dt driver which is used only on ARM
> platforms currently.
>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
>  drivers/cpufreq/cpufreq-dt.c |  1 +
>  include/linux/cpufreq.h      | 18 ++++++++++++++++--
>  2 files changed, 17 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c
> index fef3c2160691..d83ab94d041a 100644
> --- a/drivers/cpufreq/cpufreq-dt.c
> +++ b/drivers/cpufreq/cpufreq-dt.c
> @@ -274,6 +274,7 @@ static int cpufreq_init(struct cpufreq_policy *policy)
>                 transition_latency = CPUFREQ_ETERNAL;
>
>         policy->cpuinfo.transition_latency = transition_latency;
> +       policy->dvfs_possible_from_any_cpu = true;
>
>         return 0;
>
> diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
> index b3b6e8203e82..227cd0f13300 100644
> --- a/include/linux/cpufreq.h
> +++ b/include/linux/cpufreq.h
> @@ -127,6 +127,15 @@ struct cpufreq_policy {
>          */
>         unsigned int            transition_delay_us;
>
> +       /*
> +        * Remote DVFS flag (Not added to the driver structure as we don't want
> +        * to access another structure from scheduler hotpath).
> +        *
> +        * Should be set if CPUs can do DVFS on behalf of other CPUs from
> +        * different cpufreq policies.
> +        */
> +       bool                    dvfs_possible_from_any_cpu;
> +
>          /* Cached frequency lookup from cpufreq_driver_resolve_freq. */
>         unsigned int cached_target_freq;
>         int cached_resolved_idx;
> @@ -564,8 +573,13 @@ struct governor_attr {
>
>  static inline bool cpufreq_can_do_remote_dvfs(struct cpufreq_policy *policy)
>  {
> -       /* Allow remote callbacks only on the CPUs sharing cpufreq policy */
> -       if (cpumask_test_cpu(smp_processor_id(), policy->cpus))
> +       /*
> +        * Allow remote callbacks if:
> +        * - dvfs_possible_from_any_cpu flag is set
> +        * - the local and remote CPUs share cpufreq policy
> +        */
> +       if (policy->dvfs_possible_from_any_cpu ||
> +           cpumask_test_cpu(smp_processor_id(), policy->cpus))
>                 return true;
>
>         return false;

Currently sugov threads in the schedutil governor are pinned to the
policy CPUs. schedutil can now make use of this new
dvfs_possible_from_any_cpu flag and avoid the pinning, right?

Thanks,
Pavan
-- 
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a
Linux Foundation Collaborative Project

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


#1701682 — Re: [Eas-dev] [PATCH V5 2/2] cpufreq: Process remote callbacks from any CPU if the platform permits

FromViresh Kumar <viresh.kumar@linaro.org>
Date2017-08-02 05:50 +0200
SubjectRe: [Eas-dev] [PATCH V5 2/2] cpufreq: Process remote callbacks from any CPU if the platform permits
Message-ID<u9SPv-4x2-1@gated-at.bofh.it>
In reply to#1700874
On 01-08-17, 16:30, Pavan Kondeti wrote:
> Currently sugov threads in the schedutil governor are pinned to the
> policy CPUs. schedutil can now make use of this new
> dvfs_possible_from_any_cpu flag and avoid the pinning, right?

Actually yes and it would be something as simple as below. Will send a patch for
this if no one reports any problems with this.

diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
index 9deedd5f16a5..6ea12a8c8863 100644
--- a/kernel/sched/cpufreq_schedutil.c
+++ b/kernel/sched/cpufreq_schedutil.c
@@ -471,7 +471,10 @@ static int sugov_kthread_create(struct sugov_policy *sg_policy)
        }
 
        sg_policy->thread = thread;
-       kthread_bind_mask(thread, policy->related_cpus);
+
+       if (!policy->dvfs_possible_from_any_cpu)
+               kthread_bind_mask(thread, policy->related_cpus);
+
        init_irq_work(&sg_policy->irq_work, sugov_irq_work);
        mutex_init(&sg_policy->work_lock);
 

-- 
viresh

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web