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


Groups > linux.kernel > #1452908 > unrolled thread

[RFC][PATCH 0/7] cpufreq / sched: cpufreq_update_util() flags and iowait boosting

Started by"Rafael J. Wysocki" <rjw@rjwysocki.net>
First post2016-08-01 01:50 +0200
Last post2016-08-08 15:00 +0200
Articles 20 on this page of 40 — 7 participants

Back to article view | Back to linux.kernel


Contents

  [RFC][PATCH 0/7] cpufreq / sched: cpufreq_update_util() flags and iowait boosting "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-08-01 01:50 +0200
    [RFC][PATCH 4/7] cpufreq / sched: Add flags argument to cpufreq_update_util() "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-08-01 01:50 +0200
      Re: [RFC][PATCH 4/7] cpufreq / sched: Add flags argument to  cpufreq_update_util() Dominik Brodowski <linux@dominikbrodowski.net> - 2016-08-01 10:00 +0200
        Re: [RFC][PATCH 4/7] cpufreq / sched: Add flags argument to cpufreq_update_util() "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-08-01 17:10 +0200
          Re: [RFC][PATCH 4/7] cpufreq / sched: Add flags argument to  cpufreq_update_util() Steve Muckle <steve.muckle@linaro.org> - 2016-08-01 22:30 +0200
            Re: [RFC][PATCH 4/7] cpufreq / sched: Add flags argument to cpufreq_update_util() "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-08-02 01:50 +0200
              Re: [RFC][PATCH 4/7] cpufreq / sched: Add flags argument to  cpufreq_update_util() Steve Muckle <steve.muckle@linaro.org> - 2016-08-02 04:10 +0200
    [RFC][PATCH 3/7] cpufreq / sched: Check cpu_of(rq) in cpufreq_update_util() "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-08-01 01:50 +0200
      Re: [RFC][PATCH 3/7] cpufreq / sched: Check cpu_of(rq) in  cpufreq_update_util() Dominik Brodowski <linux@dominikbrodowski.net> - 2016-08-01 10:00 +0200
        Re: [RFC][PATCH 3/7] cpufreq / sched: Check cpu_of(rq) in cpufreq_update_util() "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-08-01 17:10 +0200
        Re: [RFC][PATCH 3/7] cpufreq / sched: Check cpu_of(rq) in  cpufreq_update_util() Steve Muckle <steve.muckle@linaro.org> - 2016-08-01 21:50 +0200
          Re: [RFC][PATCH 3/7] cpufreq / sched: Check cpu_of(rq) in cpufreq_update_util() "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-08-02 01:50 +0200
    [RFC][PATCH 1/7] cpufreq / sched: Make schedutil access utilization data directly "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-08-01 01:50 +0200
      Re: [RFC][PATCH 1/7] cpufreq / sched: Make schedutil access  utilization data directly Steve Muckle <steve.muckle@linaro.org> - 2016-08-01 21:40 +0200
        Re: [RFC][PATCH 1/7] cpufreq / sched: Make schedutil access utilization data directly "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-08-02 02:10 +0200
          Re: [RFC][PATCH 1/7] cpufreq / sched: Make schedutil access  utilization data directly Juri Lelli <juri.lelli@arm.com> - 2016-08-02 12:40 +0200
            Re: [RFC][PATCH 1/7] cpufreq / sched: Make schedutil access  utilization data directly Steve Muckle <steve.muckle@linaro.org> - 2016-08-02 16:40 +0200
              Re: [RFC][PATCH 1/7] cpufreq / sched: Make schedutil access  utilization data directly Juri Lelli <juri.lelli@arm.com> - 2016-08-02 17:00 +0200
          Re: [RFC][PATCH 1/7] cpufreq / sched: Make schedutil access  utilization data directly Peter Zijlstra <peterz@infradead.org> - 2016-08-08 12:40 +0200
    [RFC][PATCH 2/7] cpufreq / sched: Drop cpufreq_trigger_update() "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-08-01 01:50 +0200
    [RFC][PATCH 5/7] cpufreq / sched: UUF_IO flag to indicate iowait condition "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-08-01 01:50 +0200
      Re: [RFC][PATCH 5/7] cpufreq / sched: UUF_IO flag to indicate iowait  condition Steve Muckle <steve.muckle@linaro.org> - 2016-08-02 03:30 +0200
        Re: [RFC][PATCH 5/7] cpufreq / sched: UUF_IO flag to indicate iowait condition "Rafael J. Wysocki" <rafael@kernel.org> - 2016-08-02 03:50 +0200
          Re: [RFC][PATCH 5/7] cpufreq / sched: UUF_IO flag to indicate iowait  condition Steve Muckle <steve.muckle@linaro.org> - 2016-08-03 00:30 +0200
            Re: [RFC][PATCH 5/7] cpufreq / sched: UUF_IO flag to indicate iowait condition "Rafael J. Wysocki" <rafael@kernel.org> - 2016-08-03 00:50 +0200
              Re: [RFC][PATCH 5/7] cpufreq / sched: UUF_IO flag to indicate iowait  condition Steve Muckle <steve.muckle@linaro.org> - 2016-08-04 04:30 +0200
                Re: [RFC][PATCH 5/7] cpufreq / sched: UUF_IO flag to indicate iowait condition "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-08-04 23:20 +0200
                  Re: [RFC][PATCH 5/7] cpufreq / sched: UUF_IO flag to indicate iowait  condition Steve Muckle <steve.muckle@linaro.org> - 2016-08-05 00:10 +0200
                    Re: [RFC][PATCH 5/7] cpufreq / sched: UUF_IO flag to indicate iowait condition "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-08-06 23:20 +0200
    [RFC][PATCH 7/7] cpufreq: intel_pstate: Change P-state selection algorithm for Core "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-08-01 01:50 +0200
      RE: [RFC][PATCH 7/7] cpufreq: intel_pstate: Change P-state selection algorithm for Core "Doug Smythies" <dsmythies@telus.net> - 2016-08-04 09:00 +0200
        Re: [RFC][PATCH 7/7] cpufreq: intel_pstate: Change P-state selection algorithm for Core "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-08-06 23:50 +0200
          RE: [RFC][PATCH 7/7] cpufreq: intel_pstate: Change P-state selection algorithm for Core "Doug Smythies" <dsmythies@telus.net> - 2016-08-09 19:20 +0200
    [RFC][PATCH 6/7] cpufreq: schedutil: Add iowait boosting "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-08-01 01:50 +0200
      Re: [RFC][PATCH 6/7] cpufreq: schedutil: Add iowait boosting Steve Muckle <steve.muckle@linaro.org> - 2016-08-02 03:40 +0200
        Re: [RFC][PATCH 6/7] cpufreq: schedutil: Add iowait boosting "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-08-03 01:00 +0200
    RE: [RFC][PATCH 0/7] cpufreq / sched: cpufreq_update_util() flags and iowait boosting "Doug Smythies" <dsmythies@telus.net> - 2016-08-01 17:30 +0200
      Re: [RFC][PATCH 0/7] cpufreq / sched: cpufreq_update_util() flags and iowait boosting "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-08-01 18:30 +0200
        Re: [RFC][PATCH 0/7] cpufreq / sched: cpufreq_update_util() flags  and iowait boosting Peter Zijlstra <peterz@infradead.org> - 2016-08-08 13:10 +0200
          Re: [RFC][PATCH 0/7] cpufreq / sched: cpufreq_update_util() flags and iowait boosting "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-08-08 15:00 +0200

Page 1 of 2  [1] 2  Next page →


#1452908 — [RFC][PATCH 0/7] cpufreq / sched: cpufreq_update_util() flags and iowait boosting

From"Rafael J. Wysocki" <rjw@rjwysocki.net>
Date2016-08-01 01:50 +0200
Subject[RFC][PATCH 0/7] cpufreq / sched: cpufreq_update_util() flags and iowait boosting
Message-ID<s18Ex-6NS-1@gated-at.bofh.it>
Hi,

Admittedly, this hasn't been tested yet, so no promises and you have been
warned.  It builds, though (on x86-64 at least).

At this point I'm looking for general feedback mostly: does the direction make
sense or is there any reason why it can't work (that I'm not seeing), is it
acceptable and if not, how can it be improved?

Of course, if you don't like the details, please let me know too. :-)

This is based on Peter's suggestions and Srinivas's research.

The ultimate goal is to improve performance for tasks that have been waiting
on I/O in the schedutil governor and to provide a better default P-state
selection algorithm for intel_pstate (which also involves taking the "iowait"
into account).  The steps to get there are the following:

[1] Drop the util and max arguments from cpufreq_update_util() and the ->func()
    callback in struct update_util_data and make the schedutil governor access
    the scheduler's utilization data directly (this one is originally from Peter,
    I did my best to avoid breaking it).
[2] Drop cpufreq_trigger_update() as it is the same as cpufreq_update_util()
    after [1].
[3] Pass rq to cpufreq_update_util() (instead of the time) and make it do the
    smp_processor_id() check.
[4] Add a flags argument to cpufreq_update_util() and the ->func() callback in
    struct update_util_data, update their users accordingly and use the flags
    to clean up the handling of util updates from the RT sched class a bit.
[5] Make enqueue_task_fair() pass a new "IO" flag to cpufreq_update_util()
    if p->in_iowait is set.
[6] Modify the schedutil governor to use the new "IO" flag for boosting CPU
    frequency temporarily (in order to improve performance for tasks that
    have been waiting on I/O).
[7] Add a new P-state selection algorithm, based on "busy fraction" computation
    and "IO" boosting, and use it by default for Core processors.

Thanks,
Rafael

[toc] | [next] | [standalone]


#1452910 — [RFC][PATCH 4/7] cpufreq / sched: Add flags argument to cpufreq_update_util()

From"Rafael J. Wysocki" <rjw@rjwysocki.net>
Date2016-08-01 01:50 +0200
Subject[RFC][PATCH 4/7] cpufreq / sched: Add flags argument to cpufreq_update_util()
Message-ID<s18Ex-6NS-5@gated-at.bofh.it>
In reply to#1452908
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

It is useful to know the reason why cpufreq_update_util() has just
been called, so add a flags argument to it and to the ->func()
callback in struct update_util_data.

Update all of the users of them accordingly and use the flags
argument for marking updates coming from the RT sched class.

With that, modify the schedutil governor to use the "RT" flag
instead of the special utilization value of ULONG_MAX to track
updates from the RT sched class.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/cpufreq/cpufreq_governor.c |    3 ++-
 drivers/cpufreq/intel_pstate.c     |    3 ++-
 include/linux/sched.h              |    7 +++++--
 kernel/sched/cpufreq.c             |    3 ++-
 kernel/sched/cpufreq_schedutil.c   |   37 +++++++++++++++++++++----------------
 kernel/sched/deadline.c            |    2 +-
 kernel/sched/fair.c                |    2 +-
 kernel/sched/rt.c                  |    2 +-
 kernel/sched/sched.h               |    7 ++++---
 9 files changed, 39 insertions(+), 27 deletions(-)

Index: linux-pm/include/linux/sched.h
===================================================================
--- linux-pm.orig/include/linux/sched.h
+++ linux-pm/include/linux/sched.h
@@ -3375,13 +3375,16 @@ static inline unsigned long rlimit_max(u
 	return task_rlimit_max(current, limit);
 }
 
+#define UUF_RT	0x01
+
 #ifdef CONFIG_CPU_FREQ
 struct update_util_data {
-       void (*func)(struct update_util_data *data, u64 time);
+       void (*func)(struct update_util_data *data, u64 time, unsigned int flags);
 };
 
 void cpufreq_add_update_util_hook(int cpu, struct update_util_data *data,
-                       void (*func)(struct update_util_data *data, u64 time));
+                       void (*func)(struct update_util_data *data, u64 time,
+				    unsigned int flags));
 void cpufreq_remove_update_util_hook(int cpu);
 #endif /* CONFIG_CPU_FREQ */
 
Index: linux-pm/drivers/cpufreq/intel_pstate.c
===================================================================
--- linux-pm.orig/drivers/cpufreq/intel_pstate.c
+++ linux-pm/drivers/cpufreq/intel_pstate.c
@@ -1328,7 +1328,8 @@ static inline void intel_pstate_adjust_b
 		get_avg_frequency(cpu));
 }
 
-static void intel_pstate_update_util(struct update_util_data *data, u64 time)
+static void intel_pstate_update_util(struct update_util_data *data, u64 time,
+				     unsigned int flags)
 {
 	struct cpudata *cpu = container_of(data, struct cpudata, update_util);
 	u64 delta_ns = time - cpu->sample.time;
Index: linux-pm/drivers/cpufreq/cpufreq_governor.c
===================================================================
--- linux-pm.orig/drivers/cpufreq/cpufreq_governor.c
+++ linux-pm/drivers/cpufreq/cpufreq_governor.c
@@ -259,7 +259,8 @@ static void dbs_irq_work(struct irq_work
 	schedule_work_on(smp_processor_id(), &policy_dbs->work);
 }
 
-static void dbs_update_util_handler(struct update_util_data *data, u64 time)
+static void dbs_update_util_handler(struct update_util_data *data, u64 time,
+				    unsigned int flags)
 {
 	struct cpu_dbs_info *cdbs = container_of(data, struct cpu_dbs_info, update_util);
 	struct policy_dbs_info *policy_dbs = cdbs->policy_dbs;
Index: linux-pm/kernel/sched/cpufreq.c
===================================================================
--- linux-pm.orig/kernel/sched/cpufreq.c
+++ linux-pm/kernel/sched/cpufreq.c
@@ -32,7 +32,8 @@ DEFINE_PER_CPU(struct update_util_data *
  * called or it will WARN() and return with no effect.
  */
 void cpufreq_add_update_util_hook(int cpu, struct update_util_data *data,
-			void (*func)(struct update_util_data *data, u64 time))
+			void (*func)(struct update_util_data *data, u64 time,
+				     unsigned int flags))
 {
 	if (WARN_ON(!data || !func))
 		return;
Index: linux-pm/kernel/sched/cpufreq_schedutil.c
===================================================================
--- linux-pm.orig/kernel/sched/cpufreq_schedutil.c
+++ linux-pm/kernel/sched/cpufreq_schedutil.c
@@ -53,6 +53,7 @@ struct sugov_cpu {
 	unsigned long util;
 	unsigned long max;
 	u64 last_update;
+	unsigned int flags;
 };
 
 static DEFINE_PER_CPU(struct sugov_cpu, sugov_cpu);
@@ -144,7 +145,8 @@ static unsigned int get_next_freq(struct
 	return cpufreq_driver_resolve_freq(policy, freq);
 }
 
-static void sugov_get_util(unsigned long *util, unsigned long *max)
+static void sugov_get_util(unsigned long *util, unsigned long *max,
+			   unsigned int flags)
 {
 	unsigned long dl_util, dl_max;
 	unsigned long cfs_util, cfs_max;
@@ -152,10 +154,8 @@ static void sugov_get_util(unsigned long
 	struct dl_bw *dl_bw = dl_bw_of(cpu);
 	struct rq *rq = this_rq();
 
-	if (rt_prio(current->prio)) {
-		*util = ULONG_MAX;
+	if (flags & UUF_RT)
 		return;
-	}
 
 	dl_max = dl_bw_cpus(cpu) << 20;
 	dl_util = dl_bw->total_bw;
@@ -172,7 +172,8 @@ static void sugov_get_util(unsigned long
 	}
 }
 
-static void sugov_update_single(struct update_util_data *hook, u64 time)
+static void sugov_update_single(struct update_util_data *hook, u64 time,
+				unsigned int flags)
 {
 	struct sugov_cpu *sg_cpu = container_of(hook, struct sugov_cpu, update_util);
 	struct sugov_policy *sg_policy = sg_cpu->sg_policy;
@@ -183,15 +184,16 @@ static void sugov_update_single(struct u
 	if (!sugov_should_update_freq(sg_policy, time))
 		return;
 
-	sugov_get_util(&util, &max);
+	sugov_get_util(&util, &max, flags);
 
-	next_f = util == ULONG_MAX ? policy->cpuinfo.max_freq :
-			get_next_freq(sg_cpu, util, max);
+	next_f = flags & UUF_RT ? policy->cpuinfo.max_freq :
+				  get_next_freq(sg_cpu, util, max);
 	sugov_update_commit(sg_policy, time, next_f);
 }
 
 static unsigned int sugov_next_freq_shared(struct sugov_cpu *sg_cpu,
-					   unsigned long util, unsigned long max)
+					   unsigned long util, unsigned long max,
+					   unsigned int flags)
 {
 	struct sugov_policy *sg_policy = sg_cpu->sg_policy;
 	struct cpufreq_policy *policy = sg_policy->policy;
@@ -199,7 +201,7 @@ static unsigned int sugov_next_freq_shar
 	u64 last_freq_update_time = sg_policy->last_freq_update_time;
 	unsigned int j;
 
-	if (util == ULONG_MAX)
+	if (flags & UUF_RT)
 		return max_f;
 
 	for_each_cpu(j, policy->cpus) {
@@ -222,10 +224,10 @@ static unsigned int sugov_next_freq_shar
 		if (delta_ns > TICK_NSEC)
 			continue;
 
-		j_util = j_sg_cpu->util;
-		if (j_util == ULONG_MAX)
+		if (j_sg_cpu->flags & UUF_RT)
 			return max_f;
 
+		j_util = j_sg_cpu->util;
 		j_max = j_sg_cpu->max;
 		if (j_util * max > j_max * util) {
 			util = j_util;
@@ -236,23 +238,25 @@ static unsigned int sugov_next_freq_shar
 	return get_next_freq(sg_cpu, util, max);
 }
 
-static void sugov_update_shared(struct update_util_data *hook, u64 time)
+static void sugov_update_shared(struct update_util_data *hook, u64 time,
+				unsigned int flags)
 {
 	struct sugov_cpu *sg_cpu = container_of(hook, struct sugov_cpu, update_util);
 	struct sugov_policy *sg_policy = sg_cpu->sg_policy;
 	unsigned long util, max;
 	unsigned int next_f;
 
-	sugov_get_util(&util, &max);
+	sugov_get_util(&util, &max, flags);
 
 	raw_spin_lock(&sg_policy->update_lock);
 
 	sg_cpu->util = util;
 	sg_cpu->max = max;
+	sg_cpu->flags = flags;
 	sg_cpu->last_update = time;
 
 	if (sugov_should_update_freq(sg_policy, time)) {
-		next_f = sugov_next_freq_shared(sg_cpu, util, max);
+		next_f = sugov_next_freq_shared(sg_cpu, util, max, flags);
 		sugov_update_commit(sg_policy, time, next_f);
 	}
 
@@ -476,8 +480,9 @@ static int sugov_start(struct cpufreq_po
 
 		sg_cpu->sg_policy = sg_policy;
 		if (policy_is_shared(policy)) {
-			sg_cpu->util = ULONG_MAX;
+			sg_cpu->util = 0;
 			sg_cpu->max = 0;
+			sg_cpu->flags = UUF_RT;
 			sg_cpu->last_update = 0;
 			sg_cpu->cached_raw_freq = 0;
 			cpufreq_add_update_util_hook(cpu, &sg_cpu->update_util,
Index: linux-pm/kernel/sched/sched.h
===================================================================
--- linux-pm.orig/kernel/sched/sched.h
+++ linux-pm/kernel/sched/sched.h
@@ -1761,6 +1761,7 @@ DECLARE_PER_CPU(struct update_util_data
 /**
  * cpufreq_update_util - Take a note about CPU utilization changes.
  * @rq: Runqueue to carry out the update for.
+ * @flags: Update reason flags.
  *
  * This function is called by the scheduler on every invocation of
  * update_load_avg() on the CPU whose utilization is being updated.
@@ -1779,7 +1780,7 @@ DECLARE_PER_CPU(struct update_util_data
  * but that really is a band-aid.  Going forward it should be replaced with
  * solutions targeted more specifically at RT and DL tasks.
  */
-static inline void cpufreq_update_util(struct rq *rq)
+static inline void cpufreq_update_util(struct rq *rq, unsigned int flags)
 {
 	struct update_util_data *data;
 
@@ -1788,10 +1789,10 @@ static inline void cpufreq_update_util(s
 
 	data = rcu_dereference_sched(*this_cpu_ptr(&cpufreq_update_util_data));
 	if (data)
-		data->func(data, rq_clock(rq));
+		data->func(data, rq_clock(rq), flags);
 }
 #else
-static inline void cpufreq_update_util(struct rq *rq) {}
+static inline void cpufreq_update_util(struct rq *rq, unsigned int flags) {}
 #endif /* CONFIG_CPU_FREQ */
 
 #ifdef arch_scale_freq_capacity
Index: linux-pm/kernel/sched/deadline.c
===================================================================
--- linux-pm.orig/kernel/sched/deadline.c
+++ linux-pm/kernel/sched/deadline.c
@@ -733,7 +733,7 @@ static void update_curr_dl(struct rq *rq
 	}
 
 	/* kick cpufreq (see the comment in kernel/sched/sched.h). */
-	cpufreq_update_util(rq);
+	cpufreq_update_util(rq, 0);
 
 	schedstat_set(curr->se.statistics.exec_max,
 		      max(curr->se.statistics.exec_max, delta_exec));
Index: linux-pm/kernel/sched/fair.c
===================================================================
--- linux-pm.orig/kernel/sched/fair.c
+++ linux-pm/kernel/sched/fair.c
@@ -2887,7 +2887,7 @@ static inline void cfs_rq_util_change(st
 		 *
 		 * See cpu_util().
 		 */
-		cpufreq_update_util(rq_of(cfs_rq));
+		cpufreq_update_util(rq_of(cfs_rq), 0);
 	}
 }
 
Index: linux-pm/kernel/sched/rt.c
===================================================================
--- linux-pm.orig/kernel/sched/rt.c
+++ linux-pm/kernel/sched/rt.c
@@ -958,7 +958,7 @@ static void update_curr_rt(struct rq *rq
 		return;
 
 	/* Kick cpufreq (see the comment in kernel/sched/sched.h). */
-	cpufreq_update_util(rq);
+	cpufreq_update_util(rq, UUF_RT);
 
 	schedstat_set(curr->se.statistics.exec_max,
 		      max(curr->se.statistics.exec_max, delta_exec));

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


#1453029 — Re: [RFC][PATCH 4/7] cpufreq / sched: Add flags argument to cpufreq_update_util()

FromDominik Brodowski <linux@dominikbrodowski.net>
Date2016-08-01 10:00 +0200
SubjectRe: [RFC][PATCH 4/7] cpufreq / sched: Add flags argument to cpufreq_update_util()
Message-ID<s1giK-3pK-13@gated-at.bofh.it>
In reply to#1452910
On Mon, Aug 01, 2016 at 01:36:46AM +0200, Rafael J. Wysocki wrote:
> +#define UUF_RT	0x01

What does UUF stand for?

Best
	Dominik

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


#1453262 — Re: [RFC][PATCH 4/7] cpufreq / sched: Add flags argument to cpufreq_update_util()

From"Rafael J. Wysocki" <rjw@rjwysocki.net>
Date2016-08-01 17:10 +0200
SubjectRe: [RFC][PATCH 4/7] cpufreq / sched: Add flags argument to cpufreq_update_util()
Message-ID<s1n0R-7W5-3@gated-at.bofh.it>
In reply to#1453029
On Monday, August 01, 2016 09:33:12 AM Dominik Brodowski wrote:
> On Mon, Aug 01, 2016 at 01:36:46AM +0200, Rafael J. Wysocki wrote:
> > +#define UUF_RT	0x01
> 
> What does UUF stand for?

"Utilization upadte flag".

Thanks,
Rafael

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


#1453444 — Re: [RFC][PATCH 4/7] cpufreq / sched: Add flags argument to cpufreq_update_util()

FromSteve Muckle <steve.muckle@linaro.org>
Date2016-08-01 22:30 +0200
SubjectRe: [RFC][PATCH 4/7] cpufreq / sched: Add flags argument to cpufreq_update_util()
Message-ID<s1s0y-2MO-19@gated-at.bofh.it>
In reply to#1453262
On Mon, Aug 01, 2016 at 04:57:18PM +0200, Rafael J. Wysocki wrote:
> On Monday, August 01, 2016 09:33:12 AM Dominik Brodowski wrote:
> > On Mon, Aug 01, 2016 at 01:36:46AM +0200, Rafael J. Wysocki wrote:
> > > +#define UUF_RT	0x01
> > 
> > What does UUF stand for?
> 
> "Utilization upadte flag".

I had wondered the same - in my patchset I used CPUFREQ_SCHED_UPDATE_* for the
prefixes, though I guess some may object to the length.

thanks,
Steve

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


#1453510 — Re: [RFC][PATCH 4/7] cpufreq / sched: Add flags argument to cpufreq_update_util()

From"Rafael J. Wysocki" <rjw@rjwysocki.net>
Date2016-08-02 01:50 +0200
SubjectRe: [RFC][PATCH 4/7] cpufreq / sched: Add flags argument to cpufreq_update_util()
Message-ID<s1v85-4Pg-7@gated-at.bofh.it>
In reply to#1453444
On Monday, August 01, 2016 12:59:30 PM Steve Muckle wrote:
> On Mon, Aug 01, 2016 at 04:57:18PM +0200, Rafael J. Wysocki wrote:
> > On Monday, August 01, 2016 09:33:12 AM Dominik Brodowski wrote:
> > > On Mon, Aug 01, 2016 at 01:36:46AM +0200, Rafael J. Wysocki wrote:
> > > > +#define UUF_RT	0x01
> > > 
> > > What does UUF stand for?
> > 
> > "Utilization upadte flag".
> 
> I had wondered the same - in my patchset I used CPUFREQ_SCHED_UPDATE_* for the
> prefixes, though I guess some may object to the length.

Well, OK.

I guess something like SCHED_CPUFREQ_RT etc would be sufficient?

Thanks,
Rafael

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


#1453548 — Re: [RFC][PATCH 4/7] cpufreq / sched: Add flags argument to cpufreq_update_util()

FromSteve Muckle <steve.muckle@linaro.org>
Date2016-08-02 04:10 +0200
SubjectRe: [RFC][PATCH 4/7] cpufreq / sched: Add flags argument to cpufreq_update_util()
Message-ID<s1xjz-6oa-11@gated-at.bofh.it>
In reply to#1453510
On Tue, Aug 02, 2016 at 01:44:41AM +0200, Rafael J. Wysocki wrote:
> On Monday, August 01, 2016 12:59:30 PM Steve Muckle wrote:
> > On Mon, Aug 01, 2016 at 04:57:18PM +0200, Rafael J. Wysocki wrote:
> > > On Monday, August 01, 2016 09:33:12 AM Dominik Brodowski wrote:
> > > > On Mon, Aug 01, 2016 at 01:36:46AM +0200, Rafael J. Wysocki wrote:
> > > > > +#define UUF_RT	0x01
> > > > 
> > > > What does UUF stand for?
> > > 
> > > "Utilization upadte flag".
> > 
> > I had wondered the same - in my patchset I used CPUFREQ_SCHED_UPDATE_* for the
> > prefixes, though I guess some may object to the length.
> 
> Well, OK.
> 
> I guess something like SCHED_CPUFREQ_RT etc would be sufficient?

Yeah I think that would work.

thanks,
Steve

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


#1452911 — [RFC][PATCH 3/7] cpufreq / sched: Check cpu_of(rq) in cpufreq_update_util()

From"Rafael J. Wysocki" <rjw@rjwysocki.net>
Date2016-08-01 01:50 +0200
Subject[RFC][PATCH 3/7] cpufreq / sched: Check cpu_of(rq) in cpufreq_update_util()
Message-ID<s18Ex-6NS-7@gated-at.bofh.it>
In reply to#1452908
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

All of the callers of cpufreq_update_util() check whether or not
cpu_of(rq) is equal to smp_processor_id() before calling it and pass
rq_clock(rq) to it as the time argument, so rework it to take a
runqueue pointer as the argument and move the cpu_of(rq) check and
the rq_clock(rq) evaluation into it.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 kernel/sched/deadline.c |    3 +--
 kernel/sched/fair.c     |    5 +----
 kernel/sched/rt.c       |    3 +--
 kernel/sched/sched.h    |   11 +++++++----
 4 files changed, 10 insertions(+), 12 deletions(-)

Index: linux-pm/kernel/sched/deadline.c
===================================================================
--- linux-pm.orig/kernel/sched/deadline.c
+++ linux-pm/kernel/sched/deadline.c
@@ -733,8 +733,7 @@ static void update_curr_dl(struct rq *rq
 	}
 
 	/* kick cpufreq (see the comment in kernel/sched/sched.h). */
-	if (cpu_of(rq) == smp_processor_id())
-		cpufreq_update_util(rq_clock(rq));
+	cpufreq_update_util(rq);
 
 	schedstat_set(curr->se.statistics.exec_max,
 		      max(curr->se.statistics.exec_max, delta_exec));
Index: linux-pm/kernel/sched/fair.c
===================================================================
--- linux-pm.orig/kernel/sched/fair.c
+++ linux-pm/kernel/sched/fair.c
@@ -2871,8 +2871,6 @@ static inline u64 cfs_rq_clock_task(stru
 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);
-
 		/*
 		 * There are a few boundary cases this might miss but it should
 		 * get called often enough that that should (hopefully) not be
@@ -2889,8 +2887,7 @@ static inline void cfs_rq_util_change(st
 		 *
 		 * See cpu_util().
 		 */
-		if (cpu_of(rq) == smp_processor_id())
-			cpufreq_update_util(rq_clock(rq));
+		cpufreq_update_util(rq_of(cfs_rq));
 	}
 }
 
Index: linux-pm/kernel/sched/rt.c
===================================================================
--- linux-pm.orig/kernel/sched/rt.c
+++ linux-pm/kernel/sched/rt.c
@@ -958,8 +958,7 @@ static void update_curr_rt(struct rq *rq
 		return;
 
 	/* Kick cpufreq (see the comment in kernel/sched/sched.h). */
-	if (cpu_of(rq) == smp_processor_id())
-		cpufreq_update_util(rq_clock(rq));
+	cpufreq_update_util(rq);
 
 	schedstat_set(curr->se.statistics.exec_max,
 		      max(curr->se.statistics.exec_max, delta_exec));
Index: linux-pm/kernel/sched/sched.h
===================================================================
--- linux-pm.orig/kernel/sched/sched.h
+++ linux-pm/kernel/sched/sched.h
@@ -1760,7 +1760,7 @@ DECLARE_PER_CPU(struct update_util_data
 
 /**
  * cpufreq_update_util - Take a note about CPU utilization changes.
- * @time: Current time.
+ * @rq: Runqueue to carry out the update for.
  *
  * This function is called by the scheduler on every invocation of
  * update_load_avg() on the CPU whose utilization is being updated.
@@ -1779,16 +1779,19 @@ DECLARE_PER_CPU(struct update_util_data
  * but that really is a band-aid.  Going forward it should be replaced with
  * solutions targeted more specifically at RT and DL tasks.
  */
-static inline void cpufreq_update_util(u64 time)
+static inline void cpufreq_update_util(struct rq *rq)
 {
 	struct update_util_data *data;
 
+	if (cpu_of(rq) != smp_processor_id())
+		return;
+
 	data = rcu_dereference_sched(*this_cpu_ptr(&cpufreq_update_util_data));
 	if (data)
-		data->func(data, time);
+		data->func(data, rq_clock(rq));
 }
 #else
-static inline void cpufreq_update_util(u64 time) {}
+static inline void cpufreq_update_util(struct rq *rq) {}
 #endif /* CONFIG_CPU_FREQ */
 
 #ifdef arch_scale_freq_capacity

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


#1453028 — Re: [RFC][PATCH 3/7] cpufreq / sched: Check cpu_of(rq) in cpufreq_update_util()

FromDominik Brodowski <linux@dominikbrodowski.net>
Date2016-08-01 10:00 +0200
SubjectRe: [RFC][PATCH 3/7] cpufreq / sched: Check cpu_of(rq) in cpufreq_update_util()
Message-ID<s1giK-3pK-7@gated-at.bofh.it>
In reply to#1452911
A small nitpick:

On Mon, Aug 01, 2016 at 01:36:01AM +0200, Rafael J. Wysocki wrote:
> --- linux-pm.orig/kernel/sched/sched.h
> +++ linux-pm/kernel/sched/sched.h
> @@ -1760,7 +1760,7 @@ DECLARE_PER_CPU(struct update_util_data
>  
>  /**
>   * cpufreq_update_util - Take a note about CPU utilization changes.
> - * @time: Current time.
> + * @rq: Runqueue to carry out the update for.
>   *
>   * This function is called by the scheduler on every invocation of
>   * update_load_avg() on the CPU whose utilization is being updated.

This comment seems to need an update due to the smp_processor_id() check
being moved into this function.

Best,
	Dominik

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


#1453265 — Re: [RFC][PATCH 3/7] cpufreq / sched: Check cpu_of(rq) in cpufreq_update_util()

From"Rafael J. Wysocki" <rjw@rjwysocki.net>
Date2016-08-01 17:10 +0200
SubjectRe: [RFC][PATCH 3/7] cpufreq / sched: Check cpu_of(rq) in cpufreq_update_util()
Message-ID<s1n0S-7W5-15@gated-at.bofh.it>
In reply to#1453028
On Monday, August 01, 2016 09:29:57 AM Dominik Brodowski wrote:
> A small nitpick:
> 
> On Mon, Aug 01, 2016 at 01:36:01AM +0200, Rafael J. Wysocki wrote:
> > --- linux-pm.orig/kernel/sched/sched.h
> > +++ linux-pm/kernel/sched/sched.h
> > @@ -1760,7 +1760,7 @@ DECLARE_PER_CPU(struct update_util_data
> >  
> >  /**
> >   * cpufreq_update_util - Take a note about CPU utilization changes.
> > - * @time: Current time.
> > + * @rq: Runqueue to carry out the update for.
> >   *
> >   * This function is called by the scheduler on every invocation of
> >   * update_load_avg() on the CPU whose utilization is being updated.
> 
> This comment seems to need an update due to the smp_processor_id() check
> being moved into this function.

Right.

Thanks,
Rafael

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


#1453424 — Re: [RFC][PATCH 3/7] cpufreq / sched: Check cpu_of(rq) in cpufreq_update_util()

FromSteve Muckle <steve.muckle@linaro.org>
Date2016-08-01 21:50 +0200
SubjectRe: [RFC][PATCH 3/7] cpufreq / sched: Check cpu_of(rq) in cpufreq_update_util()
Message-ID<s1rnP-2ep-3@gated-at.bofh.it>
In reply to#1453028
On Mon, Aug 01, 2016 at 09:29:57AM +0200, Dominik Brodowski wrote:
> A small nitpick:
> 
> On Mon, Aug 01, 2016 at 01:36:01AM +0200, Rafael J. Wysocki wrote:
> > --- linux-pm.orig/kernel/sched/sched.h
> > +++ linux-pm/kernel/sched/sched.h
> > @@ -1760,7 +1760,7 @@ DECLARE_PER_CPU(struct update_util_data
> >  
> >  /**
> >   * cpufreq_update_util - Take a note about CPU utilization changes.
> > - * @time: Current time.
> > + * @rq: Runqueue to carry out the update for.
> >   *
> >   * This function is called by the scheduler on every invocation of
> >   * update_load_avg() on the CPU whose utilization is being updated.
> 
> This comment seems to need an update due to the smp_processor_id() check
> being moved into this function.

The callers of this have also changed - it is no longer called directly
by update_load_avg(), rather via cfs_rq_util_change() from several other
locations (I believe it was my patch that failed to update this
comment).

Could this be replaced with a more generic statement such as "called by
CFS in various paths?"

thanks,
Steve

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


#1453509 — Re: [RFC][PATCH 3/7] cpufreq / sched: Check cpu_of(rq) in cpufreq_update_util()

From"Rafael J. Wysocki" <rjw@rjwysocki.net>
Date2016-08-02 01:50 +0200
SubjectRe: [RFC][PATCH 3/7] cpufreq / sched: Check cpu_of(rq) in cpufreq_update_util()
Message-ID<s1v85-4Pg-3@gated-at.bofh.it>
In reply to#1453424
On Monday, August 01, 2016 12:48:18 PM Steve Muckle wrote:
> On Mon, Aug 01, 2016 at 09:29:57AM +0200, Dominik Brodowski wrote:
> > A small nitpick:
> > 
> > On Mon, Aug 01, 2016 at 01:36:01AM +0200, Rafael J. Wysocki wrote:
> > > --- linux-pm.orig/kernel/sched/sched.h
> > > +++ linux-pm/kernel/sched/sched.h
> > > @@ -1760,7 +1760,7 @@ DECLARE_PER_CPU(struct update_util_data
> > >  
> > >  /**
> > >   * cpufreq_update_util - Take a note about CPU utilization changes.
> > > - * @time: Current time.
> > > + * @rq: Runqueue to carry out the update for.
> > >   *
> > >   * This function is called by the scheduler on every invocation of
> > >   * update_load_avg() on the CPU whose utilization is being updated.
> > 
> > This comment seems to need an update due to the smp_processor_id() check
> > being moved into this function.
> 
> The callers of this have also changed - it is no longer called directly
> by update_load_avg(), rather via cfs_rq_util_change() from several other
> locations (I believe it was my patch that failed to update this
> comment).
> 
> Could this be replaced with a more generic statement such as "called by
> CFS in various paths?"

Good observation.

I'll modify that comment to match the code.

Thanks,
Rafael

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


#1452912 — [RFC][PATCH 1/7] cpufreq / sched: Make schedutil access utilization data directly

From"Rafael J. Wysocki" <rjw@rjwysocki.net>
Date2016-08-01 01:50 +0200
Subject[RFC][PATCH 1/7] cpufreq / sched: Make schedutil access utilization data directly
Message-ID<s18Ex-6NS-9@gated-at.bofh.it>
In reply to#1452908
From: Peter Zijlstra <peterz@infradead.org>

Since the schedutil governor is part of the scheduler proper, it can
access scheduler data directly.

This allows us to remove the util and max arguments of
cpufreq_update_util(), since only the schedutil governor will use
those, which leads to some text reduction:

  43595    1226      24   44845    af2d defconfig-build/kernel/sched/fair.o.pre
  42907    1226      24   44157    ac7d defconfig-build/kernel/sched/fair.o.post

Of course, we get more text in schedutil in return, but we can
benefit from not being tied to those two parameters by doing a very
coarse deadline reservation.

[ rjw: Subject/changelog + rebase, minor updates ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/cpufreq/cpufreq_governor.c |    3 --
 drivers/cpufreq/intel_pstate.c     |    3 --
 include/linux/sched.h              |    6 +----
 kernel/sched/core.c                |    4 +--
 kernel/sched/cpufreq.c             |    3 --
 kernel/sched/cpufreq_schedutil.c   |   40 +++++++++++++++++++++++++++++++++----
 kernel/sched/fair.c                |   11 +++-------
 kernel/sched/sched.h               |   17 +++++++--------
 8 files changed, 55 insertions(+), 32 deletions(-)

Index: linux-pm/drivers/cpufreq/cpufreq_governor.c
===================================================================
--- linux-pm.orig/drivers/cpufreq/cpufreq_governor.c
+++ linux-pm/drivers/cpufreq/cpufreq_governor.c
@@ -259,8 +259,7 @@ static void dbs_irq_work(struct irq_work
 	schedule_work_on(smp_processor_id(), &policy_dbs->work);
 }
 
-static void dbs_update_util_handler(struct update_util_data *data, u64 time,
-				    unsigned long util, unsigned long max)
+static void dbs_update_util_handler(struct update_util_data *data, u64 time)
 {
 	struct cpu_dbs_info *cdbs = container_of(data, struct cpu_dbs_info, update_util);
 	struct policy_dbs_info *policy_dbs = cdbs->policy_dbs;
Index: linux-pm/drivers/cpufreq/intel_pstate.c
===================================================================
--- linux-pm.orig/drivers/cpufreq/intel_pstate.c
+++ linux-pm/drivers/cpufreq/intel_pstate.c
@@ -1328,8 +1328,7 @@ static inline void intel_pstate_adjust_b
 		get_avg_frequency(cpu));
 }
 
-static void intel_pstate_update_util(struct update_util_data *data, u64 time,
-				     unsigned long util, unsigned long max)
+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 = time - cpu->sample.time;
Index: linux-pm/include/linux/sched.h
===================================================================
--- linux-pm.orig/include/linux/sched.h
+++ linux-pm/include/linux/sched.h
@@ -3377,13 +3377,11 @@ static inline unsigned long rlimit_max(u
 
 #ifdef CONFIG_CPU_FREQ
 struct update_util_data {
-	void (*func)(struct update_util_data *data,
-		     u64 time, unsigned long util, unsigned long max);
+       void (*func)(struct update_util_data *data, u64 time);
 };
 
 void cpufreq_add_update_util_hook(int cpu, struct update_util_data *data,
-			void (*func)(struct update_util_data *data, u64 time,
-				     unsigned long util, unsigned long max));
+                       void (*func)(struct update_util_data *data, u64 time));
 void cpufreq_remove_update_util_hook(int cpu);
 #endif /* CONFIG_CPU_FREQ */
 
Index: linux-pm/kernel/sched/cpufreq.c
===================================================================
--- linux-pm.orig/kernel/sched/cpufreq.c
+++ linux-pm/kernel/sched/cpufreq.c
@@ -32,8 +32,7 @@ DEFINE_PER_CPU(struct update_util_data *
  * called or it will WARN() and return with no effect.
  */
 void cpufreq_add_update_util_hook(int cpu, struct update_util_data *data,
-			void (*func)(struct update_util_data *data, u64 time,
-				     unsigned long util, unsigned long max))
+			void (*func)(struct update_util_data *data, u64 time))
 {
 	if (WARN_ON(!data || !func))
 		return;
Index: linux-pm/kernel/sched/cpufreq_schedutil.c
===================================================================
--- linux-pm.orig/kernel/sched/cpufreq_schedutil.c
+++ linux-pm/kernel/sched/cpufreq_schedutil.c
@@ -144,17 +144,47 @@ static unsigned int get_next_freq(struct
 	return cpufreq_driver_resolve_freq(policy, freq);
 }
 
-static void sugov_update_single(struct update_util_data *hook, u64 time,
-				unsigned long util, unsigned long max)
+static void sugov_get_util(unsigned long *util, unsigned long *max)
+{
+	unsigned long dl_util, dl_max;
+	unsigned long cfs_util, cfs_max;
+	int cpu = smp_processor_id();
+	struct dl_bw *dl_bw = dl_bw_of(cpu);
+	struct rq *rq = this_rq();
+
+	if (rt_prio(current->prio)) {
+		*util = ULONG_MAX;
+		return;
+	}
+
+	dl_max = dl_bw_cpus(cpu) << 20;
+	dl_util = dl_bw->total_bw;
+
+	cfs_max = rq->cpu_capacity_orig;
+	cfs_util = min(rq->cfs.avg.util_avg, cfs_max);
+
+	if (cfs_util * dl_max > dl_util * cfs_max) {
+		*util = cfs_util;
+		*max  = cfs_max;
+	} else {
+		*util = dl_util;
+		*max  = dl_max;
+	}
+}
+
+static void sugov_update_single(struct update_util_data *hook, u64 time)
 {
 	struct sugov_cpu *sg_cpu = container_of(hook, struct sugov_cpu, update_util);
 	struct sugov_policy *sg_policy = sg_cpu->sg_policy;
 	struct cpufreq_policy *policy = sg_policy->policy;
+	unsigned long util, max;
 	unsigned int next_f;
 
 	if (!sugov_should_update_freq(sg_policy, time))
 		return;
 
+	sugov_get_util(&util, &max);
+
 	next_f = util == ULONG_MAX ? policy->cpuinfo.max_freq :
 			get_next_freq(sg_cpu, util, max);
 	sugov_update_commit(sg_policy, time, next_f);
@@ -206,13 +236,15 @@ static unsigned int sugov_next_freq_shar
 	return get_next_freq(sg_cpu, util, max);
 }
 
-static void sugov_update_shared(struct update_util_data *hook, u64 time,
-				unsigned long util, unsigned long max)
+static void sugov_update_shared(struct update_util_data *hook, u64 time)
 {
 	struct sugov_cpu *sg_cpu = container_of(hook, struct sugov_cpu, update_util);
 	struct sugov_policy *sg_policy = sg_cpu->sg_policy;
+	unsigned long util, max;
 	unsigned int next_f;
 
+	sugov_get_util(&util, &max);
+
 	raw_spin_lock(&sg_policy->update_lock);
 
 	sg_cpu->util = util;
Index: linux-pm/kernel/sched/fair.c
===================================================================
--- linux-pm.orig/kernel/sched/fair.c
+++ linux-pm/kernel/sched/fair.c
@@ -2870,11 +2870,8 @@ static inline u64 cfs_rq_clock_task(stru
 
 static inline void cfs_rq_util_change(struct cfs_rq *cfs_rq)
 {
-	struct rq *rq = rq_of(cfs_rq);
-	int cpu = cpu_of(rq);
-
-	if (cpu == smp_processor_id() && &rq->cfs == cfs_rq) {
-		unsigned long max = rq->cpu_capacity_orig;
+	if (&this_rq()->cfs == cfs_rq) {
+		struct rq *rq = rq_of(cfs_rq);
 
 		/*
 		 * There are a few boundary cases this might miss but it should
@@ -2892,8 +2889,8 @@ static inline void cfs_rq_util_change(st
 		 *
 		 * See cpu_util().
 		 */
-		cpufreq_update_util(rq_clock(rq),
-				    min(cfs_rq->avg.util_avg, max), max);
+		if (cpu_of(rq) == smp_processor_id())
+			cpufreq_update_util(rq_clock(rq));
 	}
 }
 
Index: linux-pm/kernel/sched/sched.h
===================================================================
--- linux-pm.orig/kernel/sched/sched.h
+++ linux-pm/kernel/sched/sched.h
@@ -190,6 +190,7 @@ static inline int dl_bandwidth_enabled(v
 }
 
 extern struct dl_bw *dl_bw_of(int i);
+extern int dl_bw_cpus(int i);
 
 struct dl_bw {
 	raw_spinlock_t lock;
@@ -1760,21 +1761,19 @@ DECLARE_PER_CPU(struct update_util_data
 /**
  * cpufreq_update_util - Take a note about CPU utilization changes.
  * @time: Current time.
- * @util: Current utilization.
- * @max: Utilization ceiling.
  *
  * This function is called by the scheduler on every invocation of
  * update_load_avg() on the CPU whose utilization is being updated.
  *
  * It can only be called from RCU-sched read-side critical sections.
  */
-static inline void cpufreq_update_util(u64 time, unsigned long util, unsigned long max)
+static inline void cpufreq_update_util(u64 time)
 {
-       struct update_util_data *data;
+	struct update_util_data *data;
 
-       data = rcu_dereference_sched(*this_cpu_ptr(&cpufreq_update_util_data));
-       if (data)
-               data->func(data, time, util, max);
+	data = rcu_dereference_sched(*this_cpu_ptr(&cpufreq_update_util_data));
+	if (data)
+		data->func(data, time);
 }
 
 /**
@@ -1795,10 +1794,10 @@ static inline void cpufreq_update_util(u
  */
 static inline void cpufreq_trigger_update(u64 time)
 {
-	cpufreq_update_util(time, ULONG_MAX, 0);
+	cpufreq_update_util(time);
 }
 #else
-static inline void cpufreq_update_util(u64 time, unsigned long util, unsigned long max) {}
+static inline void cpufreq_update_util(u64 time) {}
 static inline void cpufreq_trigger_update(u64 time) {}
 #endif /* CONFIG_CPU_FREQ */
 
Index: linux-pm/kernel/sched/core.c
===================================================================
--- linux-pm.orig/kernel/sched/core.c
+++ linux-pm/kernel/sched/core.c
@@ -2438,7 +2438,7 @@ inline struct dl_bw *dl_bw_of(int i)
 	return &cpu_rq(i)->rd->dl_bw;
 }
 
-static inline int dl_bw_cpus(int i)
+int dl_bw_cpus(int i)
 {
 	struct root_domain *rd = cpu_rq(i)->rd;
 	int cpus = 0;
@@ -2456,7 +2456,7 @@ inline struct dl_bw *dl_bw_of(int i)
 	return &cpu_rq(i)->dl.dl_bw;
 }
 
-static inline int dl_bw_cpus(int i)
+int dl_bw_cpus(int i)
 {
 	return 1;
 }

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


#1453421 — Re: [RFC][PATCH 1/7] cpufreq / sched: Make schedutil access utilization data directly

FromSteve Muckle <steve.muckle@linaro.org>
Date2016-08-01 21:40 +0200
SubjectRe: [RFC][PATCH 1/7] cpufreq / sched: Make schedutil access utilization data directly
Message-ID<s1re9-2an-13@gated-at.bofh.it>
In reply to#1452912
On Mon, Aug 01, 2016 at 01:34:36AM +0200, Rafael J. Wysocki wrote:
...
> Index: linux-pm/kernel/sched/cpufreq_schedutil.c
> ===================================================================
> --- linux-pm.orig/kernel/sched/cpufreq_schedutil.c
> +++ linux-pm/kernel/sched/cpufreq_schedutil.c
> @@ -144,17 +144,47 @@ static unsigned int get_next_freq(struct
>  	return cpufreq_driver_resolve_freq(policy, freq);
>  }
>  
> -static void sugov_update_single(struct update_util_data *hook, u64 time,
> -				unsigned long util, unsigned long max)
> +static void sugov_get_util(unsigned long *util, unsigned long *max)
> +{
> +	unsigned long dl_util, dl_max;
> +	unsigned long cfs_util, cfs_max;
> +	int cpu = smp_processor_id();
> +	struct dl_bw *dl_bw = dl_bw_of(cpu);
> +	struct rq *rq = this_rq();
> +
> +	if (rt_prio(current->prio)) {
> +		*util = ULONG_MAX;
> +		return;
> +	}
> +
> +	dl_max = dl_bw_cpus(cpu) << 20;
> +	dl_util = dl_bw->total_bw;
> +
> +	cfs_max = rq->cpu_capacity_orig;
> +	cfs_util = min(rq->cfs.avg.util_avg, cfs_max);
> +
> +	if (cfs_util * dl_max > dl_util * cfs_max) {
> +		*util = cfs_util;
> +		*max  = cfs_max;
> +	} else {
> +		*util = dl_util;
> +		*max  = dl_max;
> +	}
> +}

Last Friday I had put together a similar patch based on Peter's. I need
the flags field for the remote wakeup support. My previous plan,
installing a late callback in check_preempt_curr that gets requested
from the earlier existing CFS callback, was not working out since those
two events don't always match up 1:1.

Anyway one way that my patch differed was that I had used the flags
field to keep the behavior the same for both RT and DL. That happens
later on in this series for RT but the DL policy is modified as above.
Can the DL policy be left as-is and discussed/modified in a separate
series?

thanks,
Steve

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


#1453514 — Re: [RFC][PATCH 1/7] cpufreq / sched: Make schedutil access utilization data directly

From"Rafael J. Wysocki" <rjw@rjwysocki.net>
Date2016-08-02 02:10 +0200
SubjectRe: [RFC][PATCH 1/7] cpufreq / sched: Make schedutil access utilization data directly
Message-ID<s1vrr-5aK-5@gated-at.bofh.it>
In reply to#1453421
On Monday, August 01, 2016 12:28:50 PM Steve Muckle wrote:
> On Mon, Aug 01, 2016 at 01:34:36AM +0200, Rafael J. Wysocki wrote:
> ...
> > Index: linux-pm/kernel/sched/cpufreq_schedutil.c
> > ===================================================================
> > --- linux-pm.orig/kernel/sched/cpufreq_schedutil.c
> > +++ linux-pm/kernel/sched/cpufreq_schedutil.c
> > @@ -144,17 +144,47 @@ static unsigned int get_next_freq(struct
> >  	return cpufreq_driver_resolve_freq(policy, freq);
> >  }
> >  
> > -static void sugov_update_single(struct update_util_data *hook, u64 time,
> > -				unsigned long util, unsigned long max)
> > +static void sugov_get_util(unsigned long *util, unsigned long *max)
> > +{
> > +	unsigned long dl_util, dl_max;
> > +	unsigned long cfs_util, cfs_max;
> > +	int cpu = smp_processor_id();
> > +	struct dl_bw *dl_bw = dl_bw_of(cpu);
> > +	struct rq *rq = this_rq();
> > +
> > +	if (rt_prio(current->prio)) {
> > +		*util = ULONG_MAX;
> > +		return;
> > +	}
> > +
> > +	dl_max = dl_bw_cpus(cpu) << 20;
> > +	dl_util = dl_bw->total_bw;
> > +
> > +	cfs_max = rq->cpu_capacity_orig;
> > +	cfs_util = min(rq->cfs.avg.util_avg, cfs_max);
> > +
> > +	if (cfs_util * dl_max > dl_util * cfs_max) {
> > +		*util = cfs_util;
> > +		*max  = cfs_max;
> > +	} else {
> > +		*util = dl_util;
> > +		*max  = dl_max;
> > +	}
> > +}
> 
> Last Friday I had put together a similar patch based on Peter's. I need
> the flags field for the remote wakeup support. My previous plan,
> installing a late callback in check_preempt_curr that gets requested
> from the earlier existing CFS callback, was not working out since those
> two events don't always match up 1:1.
> 
> Anyway one way that my patch differed was that I had used the flags
> field to keep the behavior the same for both RT and DL. That happens
> later on in this series for RT but the DL policy is modified as above.
> Can the DL policy be left as-is and discussed/modified in a separate
> series?

No problem with that as far as I'm concerned, but in that case it won't be
a Peter's patch any more. :-)

Thanks,
Rafael

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


#1453730 — Re: [RFC][PATCH 1/7] cpufreq / sched: Make schedutil access utilization data directly

FromJuri Lelli <juri.lelli@arm.com>
Date2016-08-02 12:40 +0200
SubjectRe: [RFC][PATCH 1/7] cpufreq / sched: Make schedutil access utilization data directly
Message-ID<s1Fhd-3ao-19@gated-at.bofh.it>
In reply to#1453514
Hi,

On 02/08/16 01:46, Rafael J. Wysocki wrote:
> On Monday, August 01, 2016 12:28:50 PM Steve Muckle wrote:
> > On Mon, Aug 01, 2016 at 01:34:36AM +0200, Rafael J. Wysocki wrote:
> > ...
> > > Index: linux-pm/kernel/sched/cpufreq_schedutil.c
> > > ===================================================================
> > > --- linux-pm.orig/kernel/sched/cpufreq_schedutil.c
> > > +++ linux-pm/kernel/sched/cpufreq_schedutil.c
> > > @@ -144,17 +144,47 @@ static unsigned int get_next_freq(struct
> > >  	return cpufreq_driver_resolve_freq(policy, freq);
> > >  }
> > >  
> > > -static void sugov_update_single(struct update_util_data *hook, u64 time,
> > > -				unsigned long util, unsigned long max)
> > > +static void sugov_get_util(unsigned long *util, unsigned long *max)
> > > +{
> > > +	unsigned long dl_util, dl_max;
> > > +	unsigned long cfs_util, cfs_max;
> > > +	int cpu = smp_processor_id();
> > > +	struct dl_bw *dl_bw = dl_bw_of(cpu);
> > > +	struct rq *rq = this_rq();
> > > +
> > > +	if (rt_prio(current->prio)) {
> > > +		*util = ULONG_MAX;
> > > +		return;
> > > +	}
> > > +
> > > +	dl_max = dl_bw_cpus(cpu) << 20;
> > > +	dl_util = dl_bw->total_bw;
> > > +
> > > +	cfs_max = rq->cpu_capacity_orig;
> > > +	cfs_util = min(rq->cfs.avg.util_avg, cfs_max);
> > > +
> > > +	if (cfs_util * dl_max > dl_util * cfs_max) {
> > > +		*util = cfs_util;
> > > +		*max  = cfs_max;
> > > +	} else {
> > > +		*util = dl_util;
> > > +		*max  = dl_max;
> > > +	}
> > > +}
> > 
> > Last Friday I had put together a similar patch based on Peter's. I need
> > the flags field for the remote wakeup support. My previous plan,
> > installing a late callback in check_preempt_curr that gets requested
> > from the earlier existing CFS callback, was not working out since those
> > two events don't always match up 1:1.
> > 
> > Anyway one way that my patch differed was that I had used the flags
> > field to keep the behavior the same for both RT and DL.

Do you mean "go to max" policy for both, until proper policies will be
implemented in the future?

> That happens
> > later on in this series for RT but the DL policy is modified as above.
> > Can the DL policy be left as-is and discussed/modified in a separate
> > series?

Not that we want to start discussing this point now, if we postpone the
change for later, but I just wanted to point out a difference w.r.t.
what the schedfreq thing was doing: it used to sum contributions from
the different classes, instead of taking the max. We probably never
really discussed on the list what is the right thing to do, though.

Best,

- Juri

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


#1454567 — Re: [RFC][PATCH 1/7] cpufreq / sched: Make schedutil access utilization data directly

FromSteve Muckle <steve.muckle@linaro.org>
Date2016-08-02 16:40 +0200
SubjectRe: [RFC][PATCH 1/7] cpufreq / sched: Make schedutil access utilization data directly
Message-ID<s1J1n-5FG-1@gated-at.bofh.it>
In reply to#1453730
On Tue, Aug 02, 2016 at 11:38:17AM +0100, Juri Lelli wrote:
> > > Anyway one way that my patch differed was that I had used the flags
> > > field to keep the behavior the same for both RT and DL.
> 
> Do you mean "go to max" policy for both, until proper policies will be
> implemented in the future?

Yep.

> > That happens
> > > later on in this series for RT but the DL policy is modified as above.
> > > Can the DL policy be left as-is and discussed/modified in a separate
> > > series?
> 
> Not that we want to start discussing this point now, if we postpone the
> change for later, but I just wanted to point out a difference w.r.t.
> what the schedfreq thing was doing: it used to sum contributions from
> the different classes, instead of taking the max. We probably never
> really discussed on the list what is the right thing to do, though.

Yeah I figured that was worth deferring into its own patchset/thread.

cheers,
Steve

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


#1454654 — Re: [RFC][PATCH 1/7] cpufreq / sched: Make schedutil access utilization data directly

FromJuri Lelli <juri.lelli@arm.com>
Date2016-08-02 17:00 +0200
SubjectRe: [RFC][PATCH 1/7] cpufreq / sched: Make schedutil access utilization data directly
Message-ID<s1JkK-5Nl-29@gated-at.bofh.it>
In reply to#1454567
On 02/08/16 07:28, Steve Muckle wrote:
> On Tue, Aug 02, 2016 at 11:38:17AM +0100, Juri Lelli wrote:
> > > > Anyway one way that my patch differed was that I had used the flags
> > > > field to keep the behavior the same for both RT and DL.
> > 
> > Do you mean "go to max" policy for both, until proper policies will be
> > implemented in the future?
> 
> Yep.
> 

OK, thanks for clarifying.

> > > That happens
> > > > later on in this series for RT but the DL policy is modified as above.
> > > > Can the DL policy be left as-is and discussed/modified in a separate
> > > > series?
> > 
> > Not that we want to start discussing this point now, if we postpone the
> > change for later, but I just wanted to point out a difference w.r.t.
> > what the schedfreq thing was doing: it used to sum contributions from
> > the different classes, instead of taking the max. We probably never
> > really discussed on the list what is the right thing to do, though.
> 
> Yeah I figured that was worth deferring into its own patchset/thread.
> 

Right. Makes sense to me to defer this point.

Best,

- Juri

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


#1457696 — Re: [RFC][PATCH 1/7] cpufreq / sched: Make schedutil access utilization data directly

FromPeter Zijlstra <peterz@infradead.org>
Date2016-08-08 12:40 +0200
SubjectRe: [RFC][PATCH 1/7] cpufreq / sched: Make schedutil access utilization data directly
Message-ID<s3Q8p-ax-5@gated-at.bofh.it>
In reply to#1453514
On Tue, Aug 02, 2016 at 01:46:51AM +0200, Rafael J. Wysocki wrote:
> On Monday, August 01, 2016 12:28:50 PM Steve Muckle wrote:

> > Can the DL policy be left as-is and discussed/modified in a separate
> > series?
> 
> No problem with that as far as I'm concerned, but in that case it won't be
> a Peter's patch any more. :-)

No problem from my side though. I just did them together as an
illustration of the benefit etc.. Rip it up as you see fit ;-)

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


#1452913 — [RFC][PATCH 2/7] cpufreq / sched: Drop cpufreq_trigger_update()

From"Rafael J. Wysocki" <rjw@rjwysocki.net>
Date2016-08-01 01:50 +0200
Subject[RFC][PATCH 2/7] cpufreq / sched: Drop cpufreq_trigger_update()
Message-ID<s18Ex-6NS-13@gated-at.bofh.it>
In reply to#1452908
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

After dropping the util and max arguments of cpufreq_update_util(),
the cpufreq_trigger_update() wrapper around it is pointless, so drop
it and call cpufreq_update_util() directly instead.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 kernel/sched/deadline.c |    4 ++--
 kernel/sched/rt.c       |    4 ++--
 kernel/sched/sched.h    |   22 ++++++----------------
 3 files changed, 10 insertions(+), 20 deletions(-)

Index: linux-pm/kernel/sched/deadline.c
===================================================================
--- linux-pm.orig/kernel/sched/deadline.c
+++ linux-pm/kernel/sched/deadline.c
@@ -732,9 +732,9 @@ static void update_curr_dl(struct rq *rq
 		return;
 	}
 
-	/* kick cpufreq (see the comment in linux/cpufreq.h). */
+	/* kick cpufreq (see the comment in kernel/sched/sched.h). */
 	if (cpu_of(rq) == smp_processor_id())
-		cpufreq_trigger_update(rq_clock(rq));
+		cpufreq_update_util(rq_clock(rq));
 
 	schedstat_set(curr->se.statistics.exec_max,
 		      max(curr->se.statistics.exec_max, delta_exec));
Index: linux-pm/kernel/sched/rt.c
===================================================================
--- linux-pm.orig/kernel/sched/rt.c
+++ linux-pm/kernel/sched/rt.c
@@ -957,9 +957,9 @@ static void update_curr_rt(struct rq *rq
 	if (unlikely((s64)delta_exec <= 0))
 		return;
 
-	/* Kick cpufreq (see the comment in linux/cpufreq.h). */
+	/* Kick cpufreq (see the comment in kernel/sched/sched.h). */
 	if (cpu_of(rq) == smp_processor_id())
-		cpufreq_trigger_update(rq_clock(rq));
+		cpufreq_update_util(rq_clock(rq));
 
 	schedstat_set(curr->se.statistics.exec_max,
 		      max(curr->se.statistics.exec_max, delta_exec));
Index: linux-pm/kernel/sched/sched.h
===================================================================
--- linux-pm.orig/kernel/sched/sched.h
+++ linux-pm/kernel/sched/sched.h
@@ -1766,19 +1766,6 @@ DECLARE_PER_CPU(struct update_util_data
  * update_load_avg() on the CPU whose utilization is being updated.
  *
  * It can only be called from RCU-sched read-side critical sections.
- */
-static inline void cpufreq_update_util(u64 time)
-{
-	struct update_util_data *data;
-
-	data = rcu_dereference_sched(*this_cpu_ptr(&cpufreq_update_util_data));
-	if (data)
-		data->func(data, time);
-}
-
-/**
- * cpufreq_trigger_update - Trigger CPU performance state evaluation if needed.
- * @time: Current time.
  *
  * The way cpufreq is currently arranged requires it to evaluate the CPU
  * performance state (frequency/voltage) on a regular basis to prevent it from
@@ -1792,13 +1779,16 @@ static inline void cpufreq_update_util(u
  * but that really is a band-aid.  Going forward it should be replaced with
  * solutions targeted more specifically at RT and DL tasks.
  */
-static inline void cpufreq_trigger_update(u64 time)
+static inline void cpufreq_update_util(u64 time)
 {
-	cpufreq_update_util(time);
+	struct update_util_data *data;
+
+	data = rcu_dereference_sched(*this_cpu_ptr(&cpufreq_update_util_data));
+	if (data)
+		data->func(data, time);
 }
 #else
 static inline void cpufreq_update_util(u64 time) {}
-static inline void cpufreq_trigger_update(u64 time) {}
 #endif /* CONFIG_CPU_FREQ */
 
 #ifdef arch_scale_freq_capacity

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


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | linux.kernel


csiph-web