public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: tglx@linutronix.de, mingo@redhat.com, peterz@infradead.org,
	bp@suse.de, lenb@kernel.org, rjw@rjwysocki.net,
	mgorman@techsingularity.net, x86@kernel.org,
	linux-pm@vger.kernel.org, juri.lelli@arm.com,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC/RFT] [PATCH 06/10] cpufreq / sched: Add interface to get utilization values
Date: Wed, 16 May 2018 15:25:57 -0700	[thread overview]
Message-ID: <1526509557.61700.95.camel@linux.intel.com> (raw)
In-Reply-To: <20180516064055.gbmemcxsv2qvx67g@vireshk-i7>

On Wed, 2018-05-16 at 12:10 +0530, Viresh Kumar wrote:
> On 15-05-18, 21:49, Srinivas Pandruvada wrote:
> > Added cpufreq_get_sched_util() to get the CFS, DL and max
> > utilization
> > values for a CPU. This is required for getting utilization values
> > for cpufreq drivers outside of kernel/sched folder.
> > 
> > Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel
> > .com>
> > ---
> >  include/linux/sched/cpufreq.h |  2 ++
> >  kernel/sched/cpufreq.c        | 23 +++++++++++++++++++++++
> >  2 files changed, 25 insertions(+)
> > 
> > diff --git a/include/linux/sched/cpufreq.h
> > b/include/linux/sched/cpufreq.h
> > index 5966744..a366600 100644
> > --- a/include/linux/sched/cpufreq.h
> > +++ b/include/linux/sched/cpufreq.h
> > @@ -20,6 +20,8 @@ void cpufreq_add_update_util_hook(int cpu, struct
> > update_util_data *data,
> >                         void (*func)(struct update_util_data *data,
> > u64 time,
> >  				    unsigned int flags));
> >  void cpufreq_remove_update_util_hook(int cpu);
> > +void cpufreq_get_sched_util(int cpu, unsigned long *util_cfs,
> > +			    unsigned long *util_dl, unsigned long
> > *max);
> >  #endif /* CONFIG_CPU_FREQ */
> >  
> >  #endif /* _LINUX_SCHED_CPUFREQ_H */
> > diff --git a/kernel/sched/cpufreq.c b/kernel/sched/cpufreq.c
> > index 5e54cbc..36e2839 100644
> > --- a/kernel/sched/cpufreq.c
> > +++ b/kernel/sched/cpufreq.c
> > @@ -60,3 +60,26 @@ void cpufreq_remove_update_util_hook(int cpu)
> >  	rcu_assign_pointer(per_cpu(cpufreq_update_util_data, cpu),
> > NULL);
> >  }
> >  EXPORT_SYMBOL_GPL(cpufreq_remove_update_util_hook);
> > +
> > +/**
> > + * cpufreq_get_sched_util - Get utilization values.
> > + * @cpu: The targeted CPU.
> > + *
> > + * Get the CFS, DL and max utilization.
> > + * This function allows cpufreq driver outside the kernel/sched to
> > access
> > + * utilization value for a CPUs run queue.
> > + */
> > +void cpufreq_get_sched_util(int cpu, unsigned long *util_cfs,
> > +			    unsigned long *util_dl, unsigned long
> > *max)
> > +{
> > +#ifdef CONFIG_CPU_FREQ_GOV_SCHEDUTIL
> 
> What will happen when schedutil is compiled in the kernel but
> ondemand
> is the one getting used currently ?
It should still work. The only reason I have to use ifdef because of
compile issues when CONFIG_CPU_FREQ_SCHEDUTIL is not defined.
The reason for that is that cpu_util_cfs() and cpu_util_dl() is defined
under #ifdef CONFIG_CPU_FREQ_GOV_SCHEDUTIL.
The actual code inside the cpu_util_cfs() and cpu_util_dl() uses
rq->cfs.avg.util_avg and rq->cfs.avg.util_avg, which are updated
irrespective of cpufreq governor. May be better to remove ifdefs for
cpu_util_dl() and cpu_util_cfs().

Thanks,
Srinivas
> 
> > +	struct rq *rq = cpu_rq(cpu);
> > +
> > +	*max = arch_scale_cpu_capacity(NULL, cpu);
> > +	*util_cfs = cpu_util_cfs(rq);
> > +	*util_dl  = cpu_util_dl(rq);
> > +#else
> > +	*util_cfs = *util_dl = 1;
> > +#endif
> > +}
> > +EXPORT_SYMBOL_GPL(cpufreq_get_sched_util);
> > -- 
> > 2.9.5
> 
> 

  reply	other threads:[~2018-05-16 22:26 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-16  4:49 [RFC/RFT] [PATCH 00/10] Intel_pstate: HWP Dynamic performance boost Srinivas Pandruvada
2018-05-16  4:49 ` [RFC/RFT] [PATCH 01/10] x86,sched: Add support for frequency invariance Srinivas Pandruvada
2018-05-16  9:56   ` Peter Zijlstra
2018-05-16  4:49 ` [RFC/RFT] [PATCH 02/10] cpufreq: intel_pstate: Conditional frequency invariant accounting Srinivas Pandruvada
2018-05-16  7:16   ` Peter Zijlstra
2018-05-16  7:29     ` Peter Zijlstra
2018-05-16  9:07       ` Rafael J. Wysocki
2018-05-16 17:32         ` Srinivas Pandruvada
2018-05-16 15:19   ` Juri Lelli
2018-05-16 15:47     ` Peter Zijlstra
2018-05-16 16:31       ` Juri Lelli
2018-05-17 10:59         ` Juri Lelli
2018-05-17 15:04           ` Juri Lelli
2018-05-17 15:41             ` Srinivas Pandruvada
2018-05-17 16:16               ` Peter Zijlstra
2018-05-17 16:42                 ` Srinivas Pandruvada
2018-05-17 16:56                   ` Rafael J. Wysocki
2018-05-17 18:28                     ` Peter Zijlstra
2018-05-18  7:36                       ` Rafael J. Wysocki
2018-05-18 10:57                       ` Patrick Bellasi
2018-05-18 11:29                         ` Peter Zijlstra
2018-05-18 13:33                           ` Patrick Bellasi
2018-05-30 16:57                             ` Patrick Bellasi
2018-05-18 14:09                           ` Valentin Schneider
2018-05-16 15:58     ` Srinivas Pandruvada
2018-05-16  4:49 ` [RFC/RFT] [PATCH 03/10] cpufreq: intel_pstate: Utility functions to boost HWP performance limits Srinivas Pandruvada
2018-05-16  7:22   ` Peter Zijlstra
2018-05-16  9:15     ` Rafael J. Wysocki
2018-05-16 10:43       ` Peter Zijlstra
2018-05-16 15:39         ` Srinivas Pandruvada
2018-05-16 15:41     ` Srinivas Pandruvada
2018-05-16  4:49 ` [RFC/RFT] [PATCH 04/10] cpufreq: intel_pstate: Add update_util_hook for HWP Srinivas Pandruvada
2018-05-16  4:49 ` [RFC/RFT] [PATCH 05/10] cpufreq: intel_pstate: HWP boost performance on IO Wake Srinivas Pandruvada
2018-05-16  7:37   ` Peter Zijlstra
2018-05-16 17:55     ` Srinivas Pandruvada
2018-05-17  8:19       ` Peter Zijlstra
2018-05-16  9:45   ` Rafael J. Wysocki
2018-05-16 19:28     ` Srinivas Pandruvada
2018-05-16  4:49 ` [RFC/RFT] [PATCH 06/10] cpufreq / sched: Add interface to get utilization values Srinivas Pandruvada
2018-05-16  6:40   ` Viresh Kumar
2018-05-16 22:25     ` Srinivas Pandruvada [this message]
2018-05-16  8:11   ` Peter Zijlstra
2018-05-16 22:40     ` Srinivas Pandruvada
2018-05-17  7:50       ` Peter Zijlstra
2018-05-16  4:49 ` [RFC/RFT] [PATCH 07/10] cpufreq: intel_pstate: HWP boost performance on busy task migrate Srinivas Pandruvada
2018-05-16  9:49   ` Rafael J. Wysocki
2018-05-16 20:59     ` Srinivas Pandruvada
2018-05-16  4:49 ` [RFC/RFT] [PATCH 08/10] cpufreq: intel_pstate: Dyanmically update busy pct Srinivas Pandruvada
2018-05-16  7:43   ` Peter Zijlstra
2018-05-16  7:47   ` Peter Zijlstra
2018-05-16  4:49 ` [RFC/RFT] [PATCH 09/10] cpufreq: intel_pstate: New sysfs entry to control HWP boost Srinivas Pandruvada
2018-05-16  4:49 ` [RFC/RFT] [PATCH 10/10] cpufreq: intel_pstate: enable boost for SKX Srinivas Pandruvada
2018-05-16  7:49   ` Peter Zijlstra
2018-05-16 15:46     ` Srinivas Pandruvada
2018-05-16 15:54       ` Peter Zijlstra
2018-05-17  0:52         ` Srinivas Pandruvada
2018-05-16  6:49 ` [RFC/RFT] [PATCH 00/10] Intel_pstate: HWP Dynamic performance boost Juri Lelli
2018-05-16 15:43   ` Srinivas Pandruvada

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1526509557.61700.95.camel@linux.intel.com \
    --to=srinivas.pandruvada@linux.intel.com \
    --cc=bp@suse.de \
    --cc=juri.lelli@arm.com \
    --cc=lenb@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mgorman@techsingularity.net \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rjw@rjwysocki.net \
    --cc=tglx@linutronix.de \
    --cc=viresh.kumar@linaro.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox