From: Peter Zijlstra <peterz@infradead.org>
To: mingo@kernel.org, linux-kernel@vger.kernel.org
Cc: brendan.jackman@arm.com, vincent.guittot@linaro.org,
dietmar.eggemann@arm.com, peterz@infradead.org,
morten.rasmussen@arm.com
Subject: [RFC PATCH 5/5] sched: Update blocked load from NEWIDLE
Date: Thu, 21 Dec 2017 11:21:44 +0100 [thread overview]
Message-ID: <20171221102235.236646281@infradead.org> (raw)
In-Reply-To: <20171221102139.177253391@infradead.org>
[-- Attachment #1: peterz-sched-nohz-newidle.patch --]
[-- Type: text/plain, Size: 3751 bytes --]
Suggested-by: Brendan Jackman <brendan.jackman@arm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
kernel/sched/core.c | 1 +
kernel/sched/fair.c | 47 +++++++++++++++++++++++++++++++++++++++++------
kernel/sched/sched.h | 1 +
3 files changed, 43 insertions(+), 6 deletions(-)
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -6002,6 +6002,7 @@ void __init sched_init(void)
rq_attach_root(rq, &def_root_domain);
#ifdef CONFIG_NO_HZ_COMMON
rq->last_load_update_tick = jiffies;
+ rq->last_blocked_load_update_tick = jiffies;
atomic_set(&rq->nohz_flags, 0);
#endif
#ifdef CONFIG_NO_HZ_FULL
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -5379,6 +5379,14 @@ decay_load_missed(unsigned long load, un
}
return load;
}
+
+static struct {
+ cpumask_var_t idle_cpus_mask;
+ atomic_t nr_cpus;
+ unsigned long next_balance; /* in jiffy units */
+ unsigned long next_stats;
+} nohz ____cacheline_aligned;
+
#endif /* CONFIG_NO_HZ_COMMON */
/**
@@ -6942,6 +6950,7 @@ enum fbq_type { regular, remote, all };
#define LBF_NEED_BREAK 0x02
#define LBF_DST_PINNED 0x04
#define LBF_SOME_PINNED 0x08
+#define LBF_NOHZ_STATS 0x10
struct lb_env {
struct sched_domain *sd;
@@ -7380,6 +7389,10 @@ static void update_blocked_averages(int
if (cfs_rq_is_decayed(cfs_rq))
list_del_leaf_cfs_rq(cfs_rq);
}
+
+#ifdef CONFIG_NO_HZ_COMMON
+ rq->last_blocked_load_update_tick = jiffies;
+#endif
rq_unlock_irqrestore(rq, &rf);
}
@@ -7439,6 +7452,9 @@ static inline void update_blocked_averag
rq_lock_irqsave(rq, &rf);
update_rq_clock(rq);
update_cfs_rq_load_avg(cfs_rq_clock_task(cfs_rq), cfs_rq);
+#ifdef CONFIG_NO_HZ_COMMON
+ rq->last_blocked_load_update_tick = jiffies;
+#endif
rq_unlock_irqrestore(rq, &rf);
}
@@ -7773,6 +7789,19 @@ group_type group_classify(struct sched_g
return group_other;
}
+static void update_nohz_stats(struct rq *rq)
+{
+ unsigned int cpu = rq->cpu;
+
+ if (!cpumask_test_cpu(cpu, nohz.idle_cpus_mask))
+ return;
+
+ if (!time_after(jiffies, rq->last_blocked_load_update_tick))
+ return;
+
+ update_blocked_averages(cpu);
+}
+
/**
* update_sg_lb_stats - Update sched_group's statistics for load balancing.
* @env: The load balancing environment.
@@ -7795,6 +7824,9 @@ static inline void update_sg_lb_stats(st
for_each_cpu_and(i, sched_group_span(group), env->cpus) {
struct rq *rq = cpu_rq(i);
+ if (env->flags & LBF_NOHZ_STATS)
+ update_nohz_stats(rq);
+
/* Bias balancing toward cpus of our domain */
if (local_group)
load = target_load(i, load_idx);
@@ -7950,6 +7982,15 @@ static inline void update_sd_lb_stats(st
if (child && child->flags & SD_PREFER_SIBLING)
prefer_sibling = 1;
+#ifdef CONFIG_NO_HZ_COMMON
+ if (env->idle == CPU_NEWLY_IDLE) {
+ env->flags |= LBF_NOHZ_STATS;
+
+ if (cpumask_subset(nohz.idle_cpus_mask, sched_domain_span(env->sd)))
+ nohz.next_stats = jiffies + msecs_to_jiffies(LOAD_AVG_PERIOD);
+ }
+#endif
+
load_idx = get_sd_load_idx(env->sd, env->idle);
do {
@@ -8968,12 +9009,6 @@ static inline int on_null_domain(struct
* needed, they will kick the idle load balancer, which then does idle
* load balancing for all the idle CPUs.
*/
-static struct {
- cpumask_var_t idle_cpus_mask;
- atomic_t nr_cpus;
- unsigned long next_balance; /* in jiffy units */
- unsigned long next_stats;
-} nohz ____cacheline_aligned;
static inline int find_new_ilb(void)
{
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -722,6 +722,7 @@ struct rq {
#ifdef CONFIG_NO_HZ_COMMON
#ifdef CONFIG_SMP
unsigned long last_load_update_tick;
+ unsigned long last_blocked_load_update_tick;
#endif /* CONFIG_SMP */
atomic_t nohz_flags;
#endif /* CONFIG_NO_HZ_COMMON */
prev parent reply other threads:[~2017-12-21 10:24 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-21 10:21 [RFC PATCH 0/5] sched: On remote stats updates Peter Zijlstra
2017-12-21 10:21 ` [RFC PATCH 1/5] sched: Convert nohz_flags to atomic_t Peter Zijlstra
2017-12-21 10:21 ` [RFC PATCH 2/5] sched: Add NOHZ_STATS_KICK Peter Zijlstra
2017-12-21 16:23 ` Vincent Guittot
2017-12-21 16:56 ` Vincent Guittot
2017-12-22 7:59 ` Peter Zijlstra
2017-12-22 8:05 ` Vincent Guittot
2017-12-22 8:29 ` Peter Zijlstra
2017-12-22 9:12 ` Peter Zijlstra
2017-12-22 14:31 ` Peter Zijlstra
2017-12-22 14:34 ` Vincent Guittot
2017-12-22 14:32 ` Vincent Guittot
2017-12-22 18:56 ` Peter Zijlstra
2017-12-22 20:42 ` Peter Zijlstra
2018-01-02 15:44 ` Morten Rasmussen
2018-01-15 9:43 ` Peter Zijlstra
2018-01-18 10:32 ` Morten Rasmussen
2018-01-03 9:16 ` Vincent Guittot
2018-01-15 8:26 ` Vincent Guittot
2018-01-18 10:38 ` Morten Rasmussen
2018-01-24 8:25 ` Vincent Guittot
2018-01-29 18:43 ` Dietmar Eggemann
2018-01-30 8:00 ` Vincent Guittot
2018-01-29 19:31 ` Valentin Schneider
2018-01-30 8:32 ` Vincent Guittot
2018-01-30 11:41 ` Valentin Schneider
2018-01-30 13:05 ` Vincent Guittot
2018-02-05 22:18 ` Valentin Schneider
2018-02-06 9:22 ` Vincent Guittot
2018-02-01 18:16 ` Peter Zijlstra
2018-02-01 16:57 ` Peter Zijlstra
2018-02-01 17:26 ` Vincent Guittot
2018-02-01 18:10 ` Peter Zijlstra
2018-02-01 19:11 ` Vincent Guittot
2018-02-06 8:32 ` [PATCH 1/3] sched: Stop nohz stats when decayed Vincent Guittot
2018-02-06 8:32 ` [PATCH 2/3] sched: reduce the periodic update duration Vincent Guittot
2018-02-06 8:32 ` [PATCH 3/3] sched: update blocked load when newly idle Vincent Guittot
2018-02-06 14:32 ` Valentin Schneider
2018-02-06 16:17 ` Vincent Guittot
2018-02-06 16:32 ` Valentin Schneider
2018-02-06 8:55 ` [PATCH 1/3] sched: Stop nohz stats when decayed Vincent Guittot
2018-02-06 14:16 ` Valentin Schneider
2018-02-06 14:31 ` Vincent Guittot
2018-02-01 16:55 ` [RFC PATCH 2/5] sched: Add NOHZ_STATS_KICK Peter Zijlstra
2018-01-22 9:40 ` Dietmar Eggemann
2018-01-22 10:23 ` Vincent Guittot
2018-02-01 16:52 ` Peter Zijlstra
2018-02-01 17:25 ` Vincent Guittot
2017-12-22 7:56 ` Peter Zijlstra
2017-12-22 8:04 ` Vincent Guittot
2017-12-21 10:21 ` [RFC PATCH 3/5] sched: Restructure nohz_balance_kick Peter Zijlstra
2017-12-21 10:21 ` [RFC PATCH 4/5] sched: Add nohz stats balancing Peter Zijlstra
2017-12-21 10:21 ` Peter Zijlstra [this message]
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=20171221102235.236646281@infradead.org \
--to=peterz@infradead.org \
--cc=brendan.jackman@arm.com \
--cc=dietmar.eggemann@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=morten.rasmussen@arm.com \
--cc=vincent.guittot@linaro.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
Powered by JetHome