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


Groups > linux.kernel > #1693678 > unrolled thread

Re: [PATCH V3 1/3] sched: cpufreq: Allow remote cpufreq callbacks

Started byPeter Zijlstra <peterz@infradead.org>
First post2017-07-21 15:10 +0200
Last post2017-07-31 06:00 +0200
Articles 13 — 5 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

  Re: [PATCH V3 1/3] sched: cpufreq: Allow remote cpufreq callbacks Peter Zijlstra <peterz@infradead.org> - 2017-07-21 15:10 +0200
    Re: [PATCH V3 1/3] sched: cpufreq: Allow remote cpufreq callbacks Viresh Kumar <viresh.kumar@linaro.org> - 2017-07-24 13:10 +0200
      Re: [PATCH V3 1/3] sched: cpufreq: Allow remote cpufreq callbacks Peter Zijlstra <peterz@infradead.org> - 2017-07-24 15:50 +0200
        Re: [PATCH V3 1/3] sched: cpufreq: Allow remote cpufreq callbacks Viresh Kumar <viresh.kumar@linaro.org> - 2017-07-26 08:30 +0200
          Re: [PATCH V3 1/3] sched: cpufreq: Allow remote cpufreq callbacks Peter Zijlstra <peterz@infradead.org> - 2017-07-26 10:20 +0200
          Re: [PATCH V3 1/3] sched: cpufreq: Allow remote cpufreq callbacks "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2017-07-26 19:40 +0200
    Re: [Eas-dev] [PATCH V3 1/3] sched: cpufreq: Allow remote cpufreq  callbacks Saravana Kannan <skannan@codeaurora.org> - 2017-07-26 23:10 +0200
      Re: [Eas-dev] [PATCH V3 1/3] sched: cpufreq: Allow remote cpufreq  callbacks Viresh Kumar <viresh.kumar@linaro.org> - 2017-07-27 05:40 +0200
        Re: [Eas-dev] [PATCH V3 1/3] sched: cpufreq: Allow remote cpufreq  callbacks Saravana Kannan <skannan@codeaurora.org> - 2017-07-27 22:00 +0200
          Re: [Eas-dev] [PATCH V3 1/3] sched: cpufreq: Allow remote cpufreq callbacks "Joel Fernandes (Google)" <joel.opensrc@gmail.com> - 2017-07-28 06:40 +0200
          Re: [Eas-dev] [PATCH V3 1/3] sched: cpufreq: Allow remote cpufreq  callbacks Viresh Kumar <viresh.kumar@linaro.org> - 2017-07-28 08:10 +0200
            Re: [Eas-dev] [PATCH V3 1/3] sched: cpufreq: Allow remote cpufreq  callbacks Saravana Kannan <skannan@codeaurora.org> - 2017-07-28 23:10 +0200
              Re: [Eas-dev] [PATCH V3 1/3] sched: cpufreq: Allow remote cpufreq  callbacks Viresh Kumar <viresh.kumar@linaro.org> - 2017-07-31 06:00 +0200

#1693678 — Re: [PATCH V3 1/3] sched: cpufreq: Allow remote cpufreq callbacks

FromPeter Zijlstra <peterz@infradead.org>
Date2017-07-21 15:10 +0200
SubjectRe: [PATCH V3 1/3] sched: cpufreq: Allow remote cpufreq callbacks
Message-ID<u5FQR-5ft-1@gated-at.bofh.it>
On Thu, Jul 13, 2017 at 12:14:37PM +0530, Viresh Kumar wrote:
> diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
> index 47e24b5384b3..606b1a37a1af 100644
> --- a/drivers/cpufreq/cpufreq_governor.c
> +++ b/drivers/cpufreq/cpufreq_governor.c
> @@ -275,6 +275,10 @@ static void dbs_update_util_handler(struct update_util_data *data, u64 time,
>  	struct policy_dbs_info *policy_dbs = cdbs->policy_dbs;
>  	u64 delta_ns, lst;
>  
> +	/* Don't allow remote callbacks */
> +	if (smp_processor_id() != data->cpu)
> +		return;
> +

The alternative is using some of that policy_dbs->policy->*cpus crud I
suppose, because:

>  	/*
>  	 * The work may not be allowed to be queued up right now.
>  	 * Possible reasons:
> diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
> index b7fb8b7c980d..4bee2f4cbc28 100644
> --- a/drivers/cpufreq/intel_pstate.c
> +++ b/drivers/cpufreq/intel_pstate.c
> @@ -1732,6 +1732,10 @@ static void intel_pstate_update_util_pid(struct update_util_data *data,
>  	struct cpudata *cpu = container_of(data, struct cpudata, update_util);
>  	u64 delta_ns = time - cpu->sample.time;
>  
> +	/* Don't allow remote callbacks */
> +	if (smp_processor_id() != data->cpu)
> +		return;
> +
>  	if ((s64)delta_ns < pid_params.sample_rate_ns)
>  		return;
>  
> @@ -1749,6 +1753,10 @@ static void intel_pstate_update_util(struct update_util_data *data, u64 time,
>  	struct cpudata *cpu = container_of(data, struct cpudata, update_util);
>  	u64 delta_ns;
>  
> +	/* Don't allow remote callbacks */
> +	if (smp_processor_id() != data->cpu)
> +		return;
> +
>  	if (flags & SCHED_CPUFREQ_IOWAIT) {
>  		cpu->iowait_boost = int_tofp(1);
>  	} else if (cpu->iowait_boost) {


For these we can already use cpu->cpu, which would make:

> diff --git a/include/linux/sched/cpufreq.h b/include/linux/sched/cpufreq.h
> index d2be2ccbb372..8256a8f35f22 100644
> --- a/include/linux/sched/cpufreq.h
> +++ b/include/linux/sched/cpufreq.h
> @@ -16,6 +16,7 @@
>  #ifdef CONFIG_CPU_FREQ
>  struct update_util_data {
>         void (*func)(struct update_util_data *data, u64 time, unsigned int flags);
> +       unsigned int cpu;
>  };
>  
>  void cpufreq_add_update_util_hook(int cpu, struct update_util_data *data,
> diff --git a/kernel/sched/cpufreq.c b/kernel/sched/cpufreq.c
> index dbc51442ecbc..ee4c596b71b4 100644
> --- a/kernel/sched/cpufreq.c
> +++ b/kernel/sched/cpufreq.c
> @@ -42,6 +42,7 @@ void cpufreq_add_update_util_hook(int cpu, struct update_util_data *data,
>  		return;
>  
>  	data->func = func;
> +	data->cpu = cpu;
>  	rcu_assign_pointer(per_cpu(cpufreq_update_util_data, cpu), data);
>  }
>  EXPORT_SYMBOL_GPL(cpufreq_add_update_util_hook);

redundant.

> diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
> index 29a397067ffa..ed9c589e5386 100644
> --- a/kernel/sched/cpufreq_schedutil.c
> +++ b/kernel/sched/cpufreq_schedutil.c
> @@ -218,6 +218,10 @@ static void sugov_update_single(struct update_util_data *hook, u64 time,
>  	unsigned int next_f;
>  	bool busy;
>  
> +	/* Remote callbacks aren't allowed for policies which aren't shared */
> +	if (smp_processor_id() != hook->cpu)
> +		return;
> +
>  	sugov_set_iowait_boost(sg_cpu, time, flags);
>  	sg_cpu->last_update = time;
>  
> @@ -290,6 +294,10 @@ static void sugov_update_shared(struct update_util_data *hook, u64 time,
>  	unsigned long util, max;
>  	unsigned int next_f;
>  
> +	/* Don't allow remote callbacks */
> +	if (smp_processor_id() != hook->cpu)
> +		return;
> +
>  	sugov_get_util(&util, &max);
>  
>  	raw_spin_lock(&sg_policy->update_lock);


Given the whole rq->lock thing, I suspect we could actually not do these
two. That would then continue to process the iowait and other accounting
stuff, but stall the moment we call into the actual driver, which will
then drop the request on the floor as per the first few hunks.

> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index a84299f44b5d..7fcfaee39d19 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
> @@ -1136,7 +1136,7 @@ static void update_curr_dl(struct rq *rq)
>  	}
>  
>  	/* kick cpufreq (see the comment in kernel/sched/sched.h). */
> -	cpufreq_update_this_cpu(rq, SCHED_CPUFREQ_DL);
> +	cpufreq_update_util(rq, SCHED_CPUFREQ_DL);
>  
>  	schedstat_set(curr->se.statistics.exec_max,
>  		      max(curr->se.statistics.exec_max, delta_exec));
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index c95880e216f6..d378d02fdfcb 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -3278,7 +3278,9 @@ static inline void set_tg_cfs_propagate(struct cfs_rq *cfs_rq) {}
>  
>  static inline void cfs_rq_util_change(struct cfs_rq *cfs_rq)
>  {
> -	if (&this_rq()->cfs == cfs_rq) {
> +	struct rq *rq = rq_of(cfs_rq);
> +
> +	if (&rq->cfs == cfs_rq) {
>  		/*
>  		 * There are a few boundary cases this might miss but it should
>  		 * get called often enough that that should (hopefully) not be
> @@ -3295,7 +3297,7 @@ static inline void cfs_rq_util_change(struct cfs_rq *cfs_rq)
>  		 *
>  		 * See cpu_util().
>  		 */
> -		cpufreq_update_util(rq_of(cfs_rq), 0);
> +		cpufreq_update_util(rq, 0);
>  	}
>  }
>  
> @@ -4875,7 +4877,7 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags)
>  	 * passed.
>  	 */
>  	if (p->in_iowait)
> -		cpufreq_update_this_cpu(rq, SCHED_CPUFREQ_IOWAIT);
> +		cpufreq_update_util(rq, SCHED_CPUFREQ_IOWAIT);
>  
>  	for_each_sched_entity(se) {
>  		if (se->on_rq)
> diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
> index 45caf937ef90..0af5ca9e3e3f 100644
> --- a/kernel/sched/rt.c
> +++ b/kernel/sched/rt.c
> @@ -970,7 +970,7 @@ static void update_curr_rt(struct rq *rq)
>  		return;
>  
>  	/* Kick cpufreq (see the comment in kernel/sched/sched.h). */
> -	cpufreq_update_this_cpu(rq, SCHED_CPUFREQ_RT);
> +	cpufreq_update_util(rq, SCHED_CPUFREQ_RT);
>  
>  	schedstat_set(curr->se.statistics.exec_max,
>  		      max(curr->se.statistics.exec_max, delta_exec));
> diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
> index eeef1a3086d1..aa9d5b87b4f8 100644
> --- a/kernel/sched/sched.h
> +++ b/kernel/sched/sched.h
> @@ -2070,19 +2070,13 @@ static inline void cpufreq_update_util(struct rq *rq, unsigned int flags)
>  {
>  	struct update_util_data *data;
>  
> -	data = rcu_dereference_sched(*this_cpu_ptr(&cpufreq_update_util_data));
> +	data = rcu_dereference_sched(*per_cpu_ptr(&cpufreq_update_util_data,
> +						  cpu_of(rq)));
>  	if (data)
>  		data->func(data, rq_clock(rq), flags);
>  }
> -
> -static inline void cpufreq_update_this_cpu(struct rq *rq, unsigned int flags)
> -{
> -	if (cpu_of(rq) == smp_processor_id())
> -		cpufreq_update_util(rq, flags);
> -}
>  #else
>  static inline void cpufreq_update_util(struct rq *rq, unsigned int flags) {}
> -static inline void cpufreq_update_this_cpu(struct rq *rq, unsigned int flags) {}
>  #endif /* CONFIG_CPU_FREQ */

This seems ok. Except of course you'll have conflicts with Juri's patch
set, but that should be trivial to sort out.

[toc] | [next] | [standalone]


#1694640

FromViresh Kumar <viresh.kumar@linaro.org>
Date2017-07-24 13:10 +0200
Message-ID<u6Jpn-3Yr-1@gated-at.bofh.it>
In reply to#1693678
On 21-07-17, 15:03, Peter Zijlstra wrote:
> On Thu, Jul 13, 2017 at 12:14:37PM +0530, Viresh Kumar wrote:

> > @@ -42,6 +42,7 @@ void cpufreq_add_update_util_hook(int cpu, struct update_util_data *data,
> >  		return;
> >  
> >  	data->func = func;
> > +	data->cpu = cpu;
> >  	rcu_assign_pointer(per_cpu(cpufreq_update_util_data, cpu), data);
> >  }
> >  EXPORT_SYMBOL_GPL(cpufreq_add_update_util_hook);
> 
> redundant.

Actually we will still need it. We pass hook->cpu to sugov_get_util()
in the 2nd patch of this series and there is no work around possible
around that.

> > diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
> > index 29a397067ffa..ed9c589e5386 100644
> > --- a/kernel/sched/cpufreq_schedutil.c
> > +++ b/kernel/sched/cpufreq_schedutil.c
> > @@ -218,6 +218,10 @@ static void sugov_update_single(struct update_util_data *hook, u64 time,
> >  	unsigned int next_f;
> >  	bool busy;
> >  
> > +	/* Remote callbacks aren't allowed for policies which aren't shared */
> > +	if (smp_processor_id() != hook->cpu)
> > +		return;
> > +
> >  	sugov_set_iowait_boost(sg_cpu, time, flags);
> >  	sg_cpu->last_update = time;
> >  
> > @@ -290,6 +294,10 @@ static void sugov_update_shared(struct update_util_data *hook, u64 time,
> >  	unsigned long util, max;
> >  	unsigned int next_f;
> >  
> > +	/* Don't allow remote callbacks */
> > +	if (smp_processor_id() != hook->cpu)
> > +		return;
> > +
> >  	sugov_get_util(&util, &max);
> >  
> >  	raw_spin_lock(&sg_policy->update_lock);
> 
> 
> Given the whole rq->lock thing, I suspect we could actually not do these
> two.

You meant sugov_get_util() and raw_spin_lock()? Why?

The locking is required here in the shared-policy case to make sure
only one CPU is updating the frequency for the entire policy. And we
can't really avoid that even with the rq->lock guarantees from the
scheduler for the target CPU. 

> That would then continue to process the iowait and other accounting
> stuff, but stall the moment we call into the actual driver, which will
> then drop the request on the floor as per the first few hunks.

I am not sure I understood your comment completely though.

> This seems ok. Except of course you'll have conflicts with Juri's patch
> set, but that should be trivial to sort out.

Yeah, I wouldn't mind rebasing if his series gets in first.

-- 
viresh

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


#1694733

FromPeter Zijlstra <peterz@infradead.org>
Date2017-07-24 15:50 +0200
Message-ID<u6LUd-5yD-1@gated-at.bofh.it>
In reply to#1694640
On Mon, Jul 24, 2017 at 04:31:22PM +0530, Viresh Kumar wrote:
> On 21-07-17, 15:03, Peter Zijlstra wrote:
> > On Thu, Jul 13, 2017 at 12:14:37PM +0530, Viresh Kumar wrote:

> > > diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
> > > index 29a397067ffa..ed9c589e5386 100644
> > > --- a/kernel/sched/cpufreq_schedutil.c
> > > +++ b/kernel/sched/cpufreq_schedutil.c
> > > @@ -218,6 +218,10 @@ static void sugov_update_single(struct update_util_data *hook, u64 time,
> > >  	unsigned int next_f;
> > >  	bool busy;
> > >  
> > > +	/* Remote callbacks aren't allowed for policies which aren't shared */
> > > +	if (smp_processor_id() != hook->cpu)
> > > +		return;
> > > +
> > >  	sugov_set_iowait_boost(sg_cpu, time, flags);
> > >  	sg_cpu->last_update = time;
> > >  
> > > @@ -290,6 +294,10 @@ static void sugov_update_shared(struct update_util_data *hook, u64 time,
> > >  	unsigned long util, max;
> > >  	unsigned int next_f;
> > >  
> > > +	/* Don't allow remote callbacks */
> > > +	if (smp_processor_id() != hook->cpu)
> > > +		return;
> > > +
> > >  	sugov_get_util(&util, &max);
> > >  
> > >  	raw_spin_lock(&sg_policy->update_lock);
> > 
> > 
> > Given the whole rq->lock thing, I suspect we could actually not do these
> > two.
> 
> You meant sugov_get_util() and raw_spin_lock()? Why?
> 
> The locking is required here in the shared-policy case to make sure
> only one CPU is updating the frequency for the entire policy. And we
> can't really avoid that even with the rq->lock guarantees from the
> scheduler for the target CPU. 

I said nothing about the shared locking. That is indeed required. All I
said is that those two tests you add could be left out.

> > That would then continue to process the iowait and other accounting
> > stuff, but stall the moment we call into the actual driver, which will
> > then drop the request on the floor as per the first few hunks.
> 
> I am not sure I understood your comment completely though.

Since we call cpufreq_update_util(@rq, ...) with @rq->lock held, all
such calls are in fact serialized for that cpu. Therefore the cpu !=
current_cpu test you add are pointless.

Only once we get to the actual cpufreq driver (intel_pstate and others)
do we run into the fact that we might not be able to service the request
remotely. But since you also add a test there, that is sufficient.

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


#1696812

FromViresh Kumar <viresh.kumar@linaro.org>
Date2017-07-26 08:30 +0200
Message-ID<u7nZw-59N-3@gated-at.bofh.it>
In reply to#1694733
On 24-07-17, 15:47, Peter Zijlstra wrote:
> I said nothing about the shared locking. That is indeed required. All I
> said is that those two tests you add could be left out.

I was right, I didn't understood your comment at all :(

> > > That would then continue to process the iowait and other accounting
> > > stuff, but stall the moment we call into the actual driver, which will
> > > then drop the request on the floor as per the first few hunks.
> > 
> > I am not sure I understood your comment completely though.
> 
> Since we call cpufreq_update_util(@rq, ...) with @rq->lock held, all
> such calls are in fact serialized for that cpu.

Yes, they are serialized but ..

> Therefore the cpu !=
> current_cpu test you add are pointless.

.. I didn't understand why you said so. This check isn't there to take
care of serialization but remote callbacks.

> Only once we get to the actual cpufreq driver (intel_pstate and others)
> do we run into the fact that we might not be able to service the request
> remotely.

We never check for remote callbacks in drivers.

> But since you also add a test there, that is sufficient.

No.

The diff for intel-pstate that you saw in this patch was for the case
where intel-pstate works directly with the scheduler (i.e. no
schedutil governor). The routine that gets called with schedutil is
intel_cpufreq_target(), which doesn't check for remoteness at all.

-- 
viresh

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


#1696867

FromPeter Zijlstra <peterz@infradead.org>
Date2017-07-26 10:20 +0200
Message-ID<u7pHX-6hc-7@gated-at.bofh.it>
In reply to#1696812
On Wed, Jul 26, 2017 at 11:59:12AM +0530, Viresh Kumar wrote:
> On 24-07-17, 15:47, Peter Zijlstra wrote:
> > I said nothing about the shared locking. That is indeed required. All I
> > said is that those two tests you add could be left out.
> 
> I was right, I didn't understood your comment at all :(
> 
> > > > That would then continue to process the iowait and other accounting
> > > > stuff, but stall the moment we call into the actual driver, which will
> > > > then drop the request on the floor as per the first few hunks.
> > > 
> > > I am not sure I understood your comment completely though.
> > 
> > Since we call cpufreq_update_util(@rq, ...) with @rq->lock held, all
> > such calls are in fact serialized for that cpu.
> 
> Yes, they are serialized but ..
> 
> > Therefore the cpu !=
> > current_cpu test you add are pointless.
> 
> .. I didn't understand why you said so. This check isn't there to take
> care of serialization but remote callbacks.
> 
> > Only once we get to the actual cpufreq driver (intel_pstate and others)
> > do we run into the fact that we might not be able to service the request
> > remotely.
> 
> We never check for remote callbacks in drivers.
> 
> > But since you also add a test there, that is sufficient.
> 
> No.
> 
> The diff for intel-pstate that you saw in this patch was for the case
> where intel-pstate works directly with the scheduler (i.e. no
> schedutil governor). The routine that gets called with schedutil is
> intel_cpufreq_target(), which doesn't check for remoteness at all.

Argh, what a horrible mess.. :-(

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


#1697444

From"Rafael J. Wysocki" <rjw@rjwysocki.net>
Date2017-07-26 19:40 +0200
Message-ID<u7yrU-3hV-25@gated-at.bofh.it>
In reply to#1696812
On Wednesday, July 26, 2017 11:59:12 AM Viresh Kumar wrote:
> On 24-07-17, 15:47, Peter Zijlstra wrote:
> > I said nothing about the shared locking. That is indeed required. All I
> > said is that those two tests you add could be left out.
> 
> I was right, I didn't understood your comment at all :(
> 
> > > > That would then continue to process the iowait and other accounting
> > > > stuff, but stall the moment we call into the actual driver, which will
> > > > then drop the request on the floor as per the first few hunks.
> > > 
> > > I am not sure I understood your comment completely though.
> > 
> > Since we call cpufreq_update_util(@rq, ...) with @rq->lock held, all
> > such calls are in fact serialized for that cpu.
> 
> Yes, they are serialized but ..
> 
> > Therefore the cpu !=
> > current_cpu test you add are pointless.
> 
> .. I didn't understand why you said so. This check isn't there to take
> care of serialization but remote callbacks.
> 
> > Only once we get to the actual cpufreq driver (intel_pstate and others)
> > do we run into the fact that we might not be able to service the request
> > remotely.
> 
> We never check for remote callbacks in drivers.
> 
> > But since you also add a test there, that is sufficient.
> 
> No.
> 
> The diff for intel-pstate that you saw in this patch was for the case
> where intel-pstate works directly with the scheduler (i.e. no
> schedutil governor). The routine that gets called with schedutil is
> intel_cpufreq_target(), which doesn't check for remoteness at all.

And of course acpi-cpufreq doesn't check for that too, for example.

Thanks,
Rafael

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


#1697560 — Re: [Eas-dev] [PATCH V3 1/3] sched: cpufreq: Allow remote cpufreq callbacks

FromSaravana Kannan <skannan@codeaurora.org>
Date2017-07-26 23:10 +0200
SubjectRe: [Eas-dev] [PATCH V3 1/3] sched: cpufreq: Allow remote cpufreq callbacks
Message-ID<u7BJ8-5vg-19@gated-at.bofh.it>
In reply to#1693678
On 07/21/2017 06:03 AM, Peter Zijlstra wrote:
> On Thu, Jul 13, 2017 at 12:14:37PM +0530, Viresh Kumar wrote:
>> diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
>> index 47e24b5384b3..606b1a37a1af 100644
>> --- a/drivers/cpufreq/cpufreq_governor.c
>> +++ b/drivers/cpufreq/cpufreq_governor.c
>> @@ -275,6 +275,10 @@ static void dbs_update_util_handler(struct update_util_data *data, u64 time,
>>   	struct policy_dbs_info *policy_dbs = cdbs->policy_dbs;
>>   	u64 delta_ns, lst;
>>
>> +	/* Don't allow remote callbacks */
>> +	if (smp_processor_id() != data->cpu)
>> +		return;
>> +
>
> The alternative is using some of that policy_dbs->policy->*cpus crud I
> suppose, because:

No, the alternative is to pass it on to the CPU freq driver and let it 
decide what it wants to do. That's the whole point if having a CPU freq 
driver -- so that the generic code doesn't need to care about HW 
specific details. Which is the point I was making in an earlier email to 
Viresh's patch -- we shouldn't be doing any CPU check for the call backs 
at the scheduler or ever governor level.

That would simplify this whole thing by deleting a bunch of code. And 
having much simpler checks in those drivers that actually have to deal 
with their HW specific details.


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


#1697694 — Re: [Eas-dev] [PATCH V3 1/3] sched: cpufreq: Allow remote cpufreq callbacks

FromViresh Kumar <viresh.kumar@linaro.org>
Date2017-07-27 05:40 +0200
SubjectRe: [Eas-dev] [PATCH V3 1/3] sched: cpufreq: Allow remote cpufreq callbacks
Message-ID<u7HOx-QN-1@gated-at.bofh.it>
In reply to#1697560
On 26-07-17, 14:00, Saravana Kannan wrote:
> No, the alternative is to pass it on to the CPU freq driver and let it
> decide what it wants to do. That's the whole point if having a CPU freq
> driver -- so that the generic code doesn't need to care about HW specific
> details. Which is the point I was making in an earlier email to Viresh's
> patch -- we shouldn't be doing any CPU check for the call backs at the
> scheduler or ever governor level.
> 
> That would simplify this whole thing by deleting a bunch of code. And having
> much simpler checks in those drivers that actually have to deal with their
> HW specific details.

So what you are saying is that we go and update (almost) every cpufreq
driver we have today and make their ->target() callbacks return early
if they don't support switching frequency remotely ? Is that really
simplifying anything?

The core already has most of the data required and I believe that we
need to handle it in the governor's code as is handled in this series.

To solve the problem that you have been reporting (update from any
CPU), we need something like this which I earlier suggested and I
will come back to it after this series is gone. Don't want to
complicate things here unnecessarily.

https://marc.info/?l=linux-kernel&m=148906012827786&w=2

-- 
viresh

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


#1698286 — Re: [Eas-dev] [PATCH V3 1/3] sched: cpufreq: Allow remote cpufreq callbacks

FromSaravana Kannan <skannan@codeaurora.org>
Date2017-07-27 22:00 +0200
SubjectRe: [Eas-dev] [PATCH V3 1/3] sched: cpufreq: Allow remote cpufreq callbacks
Message-ID<u7X6V-21e-5@gated-at.bofh.it>
In reply to#1697694
On 07/26/2017 08:30 PM, Viresh Kumar wrote:
> On 26-07-17, 14:00, Saravana Kannan wrote:
>> No, the alternative is to pass it on to the CPU freq driver and let it
>> decide what it wants to do. That's the whole point if having a CPU freq
>> driver -- so that the generic code doesn't need to care about HW specific
>> details. Which is the point I was making in an earlier email to Viresh's
>> patch -- we shouldn't be doing any CPU check for the call backs at the
>> scheduler or ever governor level.
>>
>> That would simplify this whole thing by deleting a bunch of code. And having
>> much simpler checks in those drivers that actually have to deal with their
>> HW specific details.
>
> So what you are saying is that we go and update (almost) every cpufreq
> driver we have today and make their ->target() callbacks return early
> if they don't support switching frequency remotely ? Is that really
> simplifying anything?

Yes. Simplifying isn't always about number of lines of code. It's also 
about abstraction. Having generic scheduler code care about HW details 
doesn't seem nice.

It'll literally one simple check (cpu == smp_processor_id()) or (cpu 
"in" policy->cpus).

Also, this is only for drivers that currently support fast switching. 
How many of those do you have?

> The core already has most of the data required and I believe that we
> need to handle it in the governor's code as is handled in this series.

Clearly, it doesn't. You are just making assumptions about HW.

> To solve the problem that you have been reporting (update from any
> CPU), we need something like this which I earlier suggested and I
> will come back to it after this series is gone. Don't want to
> complicate things here unnecessarily.
>
> https://marc.info/?l=linux-kernel&m=148906012827786&w=2

I'm okay with handling it later. I'm just saying that if we are going to 
go back and debate the CPU check, then maybe it's better do it in one 
series.

-Saravana

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


#1698458 — Re: [Eas-dev] [PATCH V3 1/3] sched: cpufreq: Allow remote cpufreq callbacks

From"Joel Fernandes (Google)" <joel.opensrc@gmail.com>
Date2017-07-28 06:40 +0200
SubjectRe: [Eas-dev] [PATCH V3 1/3] sched: cpufreq: Allow remote cpufreq callbacks
Message-ID<u85e9-7ox-3@gated-at.bofh.it>
In reply to#1698286
On Thu, Jul 27, 2017 at 12:55 PM, Saravana Kannan
<skannan@codeaurora.org> wrote:
> On 07/26/2017 08:30 PM, Viresh Kumar wrote:
>>
>> On 26-07-17, 14:00, Saravana Kannan wrote:
>>>
>>> No, the alternative is to pass it on to the CPU freq driver and let it
>>> decide what it wants to do. That's the whole point if having a CPU freq
>>> driver -- so that the generic code doesn't need to care about HW specific
>>> details. Which is the point I was making in an earlier email to Viresh's
>>> patch -- we shouldn't be doing any CPU check for the call backs at the
>>> scheduler or ever governor level.
>>>
>>> That would simplify this whole thing by deleting a bunch of code. And
>>> having
>>> much simpler checks in those drivers that actually have to deal with
>>> their
>>> HW specific details.
>>
>>
>> So what you are saying is that we go and update (almost) every cpufreq
>> driver we have today and make their ->target() callbacks return early
>> if they don't support switching frequency remotely ? Is that really
>> simplifying anything?
>
>
> Yes. Simplifying isn't always about number of lines of code. It's also about
> abstraction. Having generic scheduler code care about HW details doesn't
> seem nice.
>
> It'll literally one simple check (cpu == smp_processor_id()) or (cpu "in"
> policy->cpus).
>

I think we can have both approaches? So we query the driver some time
around sugov_should_update_freq (with a new driver callback?) and ask
it if it has any say over the default behavior of "can't update remote
CPU if I'm not a part of its policy" and use that over the default if
it hasn't defined it in their struct cpufreq_driver.

I think this will also not have the concern of "updating every
driver", then we can just stick to the sane default of "no" for
drivers that haven't defined it. Probably Viresh has already thought
about this, but I just thought of bringing it up anyway. I also think
its fine to handle this case after this series gets in, but that's
just my opinion.

thanks!

-Joel

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


#1698485 — Re: [Eas-dev] [PATCH V3 1/3] sched: cpufreq: Allow remote cpufreq callbacks

FromViresh Kumar <viresh.kumar@linaro.org>
Date2017-07-28 08:10 +0200
SubjectRe: [Eas-dev] [PATCH V3 1/3] sched: cpufreq: Allow remote cpufreq callbacks
Message-ID<u86Df-8nH-1@gated-at.bofh.it>
In reply to#1698286
On 27-07-17, 12:55, Saravana Kannan wrote:
> Yes. Simplifying isn't always about number of lines of code. It's also about
> abstraction. Having generic scheduler code care about HW details doesn't
> seem nice.

I can argue that even the policy->cpus field is also hardware
specific, isn't it ? And we are using that in the schedutil governor
anyway. What's wrong with having another field (in a generic way) in
the same structure that tells us more about hardware ?

And then schedutil isn't really scheduler, but a cpufreq governor.
Just like ondemand/conservative, which are also called from the same
scheduler path.

> It'll literally one simple check (cpu == smp_processor_id()) or (cpu "in"
> policy->cpus).
> 
> Also, this is only for drivers that currently support fast switching. How
> many of those do you have?

Why? Why shouldn't we do that for the other drivers? I think it should
be done across everyone.

> >The core already has most of the data required and I believe that we
> >need to handle it in the governor's code as is handled in this series.
> 
> Clearly, it doesn't. You are just making assumptions about HW.

So assuming that any CPU from a policy can change freq on behalf of
all the CPUs of the same policy is wrong? That is the basis of how the
cpufreq core is designed.

-- 
viresh

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


#1699103 — Re: [Eas-dev] [PATCH V3 1/3] sched: cpufreq: Allow remote cpufreq callbacks

FromSaravana Kannan <skannan@codeaurora.org>
Date2017-07-28 23:10 +0200
SubjectRe: [Eas-dev] [PATCH V3 1/3] sched: cpufreq: Allow remote cpufreq callbacks
Message-ID<u8kGe-C9-19@gated-at.bofh.it>
In reply to#1698485
On 07/27/2017 11:00 PM, Viresh Kumar wrote:
> On 27-07-17, 12:55, Saravana Kannan wrote:
>> Yes. Simplifying isn't always about number of lines of code. It's also about
>> abstraction. Having generic scheduler code care about HW details doesn't
>> seem nice.
>
> I can argue that even the policy->cpus field is also hardware
> specific, isn't it ?

Yes.
> And we are using that in the schedutil governor
> anyway.
Yes

> What's wrong with having another field (in a generic way) in
> the same structure that tells us more about hardware ?

Nothing wrong. I'm not saying you shouldn't have the cpu field in the 
data or as a parameter to the hook. You'll definitely need that.

> And then schedutil isn't really scheduler, but a cpufreq governor.
> Just like ondemand/conservative, which are also called from the same
> scheduler path.

Exactly. I never debated anything about schedutil. I'm just saying don't 
have any CPU limitations or check on the scheduler side when sending 
notification. Scheduler shouldn't have to know/care of the driver can 
only set the freq on that CPU or across CPUs in a cluster or across the 
entire system.

>> It'll literally one simple check (cpu == smp_processor_id()) or (cpu "in"
>> policy->cpus).
>>
>> Also, this is only for drivers that currently support fast switching. How
>> many of those do you have?
>
> Why? Why shouldn't we do that for the other drivers? I think it should
> be done across everyone.

Because if I remember it right, the "don't send the notification if it's 
not the same CPU" limitation is only for the fast switching case?  I 
might be mistaken about this part though.

>>> The core already has most of the data required and I believe that we
>>> need to handle it in the governor's code as is handled in this series.
>>
>> Clearly, it doesn't. You are just making assumptions about HW.
>
> So assuming that any CPU from a policy can change freq on behalf of
> all the CPUs of the same policy is wrong? That is the basis of how the
> cpufreq core is designed.

1. I'm not saying that. I'm saying assuming CPUs can change the freq 
only on behalf of all the CPUs in the same policy is wrong. Again, the 
scheduler or governor shouldn't even be making any of that assumption. 
That's a CPUfreq driver problem.

2. No, that is not the basis of the entire cpufreq core design. None of 
the existing CPUfreq code has any assumptions that only CPUs in a policy 
can change their frequency. It doesn't break in any way in system where 
any CPU can change any other CPU's frequency -- all Qualcomm chips are 
like that. It's only the recent scheduler notifier changes that are 
adding this additional limitation and breaking stuff for systems where 
any CPU can change any other CPU's frequency.

-Saravana

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


#1699672 — Re: [Eas-dev] [PATCH V3 1/3] sched: cpufreq: Allow remote cpufreq callbacks

FromViresh Kumar <viresh.kumar@linaro.org>
Date2017-07-31 06:00 +0200
SubjectRe: [Eas-dev] [PATCH V3 1/3] sched: cpufreq: Allow remote cpufreq callbacks
Message-ID<u9a25-15b-5@gated-at.bofh.it>
In reply to#1699103
On 28-07-17, 14:05, Saravana Kannan wrote:
> 1. I'm not saying that. I'm saying assuming CPUs can change the freq only on
> behalf of all the CPUs in the same policy is wrong. Again, the scheduler or
> governor shouldn't even be making any of that assumption. That's a CPUfreq
> driver problem.
> 
> 2. No, that is not the basis of the entire cpufreq core design. None of the
> existing CPUfreq code has any assumptions that only CPUs in a policy can
> change their frequency. It doesn't break in any way in system where any CPU
> can change any other CPU's frequency -- all Qualcomm chips are like that.
> It's only the recent scheduler notifier changes that are adding this
> additional limitation and breaking stuff for systems where any CPU can
> change any other CPU's frequency.

Can you please have a look at V5 and see f the solution proposed there would be
fine ?

-- 
viresh

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web