mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Arjan van de Ven <arjan@linux.intel.com>
Cc: Morten Rasmussen <morten.rasmussen@arm.com>,
	Nicolas Pitre <nicolas.pitre@linaro.org>,
	Daniel Lezcano <daniel.lezcano@linaro.org>,
	Preeti U Murthy <preeti@linux.vnet.ibm.com>,
	Len Brown <len.brown@intel.com>,
	Preeti Murthy <preeti.lkml@gmail.com>,
	"mingo@redhat.com" <mingo@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	LKML <linux-kernel@vger.kernel.org>,
	"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
	Lists linaro-kernel <linaro-kernel@lists.linaro.org>
Subject: Re: [RFC PATCH 3/3] idle: store the idle state index in the struct rq
Date: Tue, 11 Feb 2014 17:41:36 +0100	[thread overview]
Message-ID: <20140211164136.GT27965@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <52EFC12B.50704@linux.intel.com>

On Mon, Feb 03, 2014 at 08:17:47AM -0800, Arjan van de Ven wrote:
> On 2/3/2014 6:56 AM, Peter Zijlstra wrote:
> if there's a simple api like
> 
> sched_cpu_cache_wiped(int llc)
> 
> that would be very nice for this; the menuidle side knows this
> for some cases and thus can just call it. This would be a very
> small and minimal change
> 
> * if you don't care about llc vs core local caches then that
>   parameter can go away
> 
> * I assume this is also called for the local cpu... if not then we
>   need to add a cpu number argument
> 
> * we can also call this from architecture code when wbinvd or the
>   arm equivalent is called etc

A little something like so?

---
 kernel/sched/core.c  | 21 +++++++++++++++++++++
 kernel/sched/fair.c  | 13 ++++++++++---
 kernel/sched/sched.h |  1 +
 3 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index fb9764fbc537..b06bcadc6d71 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -5466,6 +5466,27 @@ static void update_top_cache_domain(int cpu)
 }
 
 /*
+ * Mark the current LLC as empty.
+ */
+void sched_llc_wipe_cache(void)
+{
+	struct sched_domain *sd;
+
+	rcu_read_lock();
+	sd = rcu_dereference(__get_cpu_var(sd_llc));
+	if (sd) {
+		int cpu;
+
+		for_each_cpu(cpu, sched_domain_span(sd)) {
+			struct rq *rq = cpu_rq(cpu);
+
+			rq->llc_wiped = sched_clock_cpu(cpu);
+		}
+	}
+	rcu_read_unlock();
+}
+
+/*
  * Attach the domain 'sd' to 'cpu' as its base domain. Callers must
  * hold the hotplug lock.
  */
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 235cfa7ad8fc..9f8ce98f8131 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -5025,9 +5025,10 @@ static void move_task(struct task_struct *p, struct lb_env *env)
 /*
  * Is this task likely cache-hot:
  */
-static int
-task_hot(struct task_struct *p, u64 now, struct sched_domain *sd)
+static int task_hot(struct task_struct *p, struct lb_env *env)
 {
+	u64 now = rq_clock_task(env->src_rq);
+	struct sched_domain *sd = env->sd;
 	s64 delta;
 
 	if (p->sched_class != &fair_sched_class)
@@ -5049,6 +5050,12 @@ task_hot(struct task_struct *p, u64 now, struct sched_domain *sd)
 	if (sysctl_sched_migration_cost == 0)
 		return 0;
 
+	/*
+	 * If its LLC got wiped after it ran last, we're as cold as it gets.
+	 */
+	if ((s64)(p->se.exec_start - env->src_rq->llc_wiped) < 0)
+		return 0;
+
 	delta = now - p->se.exec_start;
 
 	return delta < (s64)sysctl_sched_migration_cost;
@@ -5187,7 +5194,7 @@ int can_migrate_task(struct task_struct *p, struct lb_env *env)
 	 * 2) task is cache cold, or
 	 * 3) too many balance attempts have failed.
 	 */
-	tsk_cache_hot = task_hot(p, rq_clock_task(env->src_rq), env->sd);
+	tsk_cache_hot = task_hot(p, env);
 	if (!tsk_cache_hot)
 		tsk_cache_hot = migrate_degrades_locality(p, env);
 
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 1bf34c257d3b..c98793112614 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -582,6 +582,7 @@ struct rq {
 
 	struct list_head cfs_tasks;
 
+	u64 llc_wiped;
 	u64 rt_avg;
 	u64 age_stamp;
 	u64 idle_stamp;

  reply	other threads:[~2014-02-11 16:42 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-30 14:09 [RFC PATCH 0/3] cpuidle/sched: move main idle function in the idle.c Daniel Lezcano
2014-01-30 14:09 ` [RFC PATCH 1/3] cpuidle: split cpuidle_idle_call main function into functions Daniel Lezcano
2014-01-30 15:27   ` Peter Zijlstra
2014-01-30 15:39     ` Daniel Lezcano
2014-01-30 19:39   ` Nicolas Pitre
2014-01-31 14:10     ` Daniel Lezcano
2014-01-30 14:09 ` [RFC PATCH 2/3] cpuidle: move the cpuidle_idle_call function to idle.c Daniel Lezcano
2014-01-30 19:42   ` Nicolas Pitre
2014-01-30 14:09 ` [RFC PATCH 3/3] idle: store the idle state index in the struct rq Daniel Lezcano
2014-01-30 15:31   ` Peter Zijlstra
2014-01-30 16:27     ` Daniel Lezcano
2014-01-30 16:35       ` Peter Zijlstra
2014-01-30 17:25         ` Daniel Lezcano
2014-01-30 17:50           ` Lorenzo Pieralisi
2014-01-30 21:02             ` Nicolas Pitre
2014-01-31  9:46               ` Vincent Guittot
2014-01-31 10:04               ` Lorenzo Pieralisi
2014-01-31 10:44               ` Daniel Lezcano
2014-01-31  8:45           ` Preeti Murthy
2014-01-31  9:02             ` Peter Zijlstra
2014-01-31  9:39               ` Preeti U Murthy
2014-01-31 10:24                 ` Peter Zijlstra
2014-01-31 14:04                 ` Daniel Lezcano
2014-01-31 14:12                   ` Dietmar Eggemann
2014-01-31 15:07                 ` Arjan van de Ven
2014-01-31 15:37                   ` Daniel Lezcano
2014-01-31 15:50                     ` Arjan van de Ven
2014-01-31 16:35                       ` Daniel Lezcano
2014-01-31 16:42                         ` Arjan van de Ven
2014-01-31 18:19                       ` Nicolas Pitre
2014-02-01  6:00                         ` Brown, Len
2014-02-01 15:31                           ` Nicolas Pitre
2014-02-01 19:39                             ` Brown, Len
2014-02-01 20:13                               ` Nicolas Pitre
2014-02-01 15:40                           ` Lorenzo Pieralisi
2014-02-03 12:54                         ` Morten Rasmussen
2014-02-03 14:38                           ` Arjan van de Ven
2014-02-03 14:56                             ` Peter Zijlstra
2014-02-03 16:17                               ` Arjan van de Ven
2014-02-11 16:41                                 ` Peter Zijlstra [this message]
2014-02-11 17:12                                   ` Arjan van de Ven
2014-02-11 19:47                                     ` Peter Zijlstra
2014-02-12 15:16                                 ` Lorenzo Pieralisi
2014-02-12 16:14                                   ` Arjan van de Ven
2014-02-12 17:37                                     ` Lorenzo Pieralisi
2014-02-12 19:05                                       ` Nicolas Pitre
2014-02-04  9:14                               ` Ingo Molnar
2014-02-04 14:53                                 ` Arjan van de Ven
2014-02-04 14:56                                 ` Arjan van de Ven
2014-02-03 14:58                           ` Nicolas Pitre
2014-01-31 10:15             ` Daniel Lezcano
2014-02-03  6:33               ` Preeti U Murthy

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=20140211164136.GT27965@twins.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=arjan@linux.intel.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=len.brown@intel.com \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=morten.rasmussen@arm.com \
    --cc=nicolas.pitre@linaro.org \
    --cc=preeti.lkml@gmail.com \
    --cc=preeti@linux.vnet.ibm.com \
    --cc=rjw@rjwysocki.net \
    --cc=tglx@linutronix.de \
    /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

Powered by JetHome