* [PATCH] sched: Fix calc_cfs_shares() to consider blocked_load_avg also
@ 2013-02-28 6:26 Namhyung Kim
2013-03-04 9:13 ` Paul Turner
0 siblings, 1 reply; 2+ messages in thread
From: Namhyung Kim @ 2013-02-28 6:26 UTC (permalink / raw)
To: Ingo Molnar, Peter Zijlstra
Cc: LKML, Alex Shi, Preeti U Murthy, Vincent Guittot, Joonsoo Kim,
Namhyung Kim, Paul Turner
From: Namhyung Kim <namhyung.kim@lge.com>
The calc_tg_weight() and calc_cfs_shares() used cfs_rq->load.weight
but this is no longer valid for per-entity load tracking since
cfs_rq->tg_load_contrib consists of runnable_load_avg and blocked_
load_avg. Simply using load.weight here will lose blocked_load_avg
part so will result in an inaccurate share.
Cc: Paul Turner <pjt@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
kernel/sched/fair.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 7a33e5986fc5..add7440bd02f 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -1032,13 +1032,13 @@ static inline long calc_tg_weight(struct task_group *tg, struct cfs_rq *cfs_rq)
long tg_weight;
/*
- * Use this CPU's actual weight instead of the last load_contribution
- * to gain a more accurate current total weight. See
- * update_cfs_rq_load_contribution().
+ * Use this CPU's actual load instead of the last load_contribution
+ * to gain a more accurate current total load. See
+ * __update_cfs_rq_tg_load_contrib().
*/
tg_weight = atomic64_read(&tg->load_avg);
tg_weight -= cfs_rq->tg_load_contrib;
- tg_weight += cfs_rq->load.weight;
+ tg_weight += cfs_rq->runnable_load_avg + cfs_rq->blocked_load_avg;
return tg_weight;
}
@@ -1048,7 +1048,7 @@ static long calc_cfs_shares(struct cfs_rq *cfs_rq, struct task_group *tg)
long tg_weight, load, shares;
tg_weight = calc_tg_weight(tg, cfs_rq);
- load = cfs_rq->load.weight;
+ load = cfs_rq->runnable_load_avg + cfs_rq->blocked_load_avg;
shares = (tg->shares * load);
if (tg_weight)
--
1.7.11.7
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] sched: Fix calc_cfs_shares() to consider blocked_load_avg also
2013-02-28 6:26 [PATCH] sched: Fix calc_cfs_shares() to consider blocked_load_avg also Namhyung Kim
@ 2013-03-04 9:13 ` Paul Turner
0 siblings, 0 replies; 2+ messages in thread
From: Paul Turner @ 2013-03-04 9:13 UTC (permalink / raw)
To: Namhyung Kim
Cc: Ingo Molnar, Peter Zijlstra, LKML, Alex Shi, Preeti U Murthy,
Vincent Guittot, Joonsoo Kim, Namhyung Kim
(I'm still in New Zealand and won't be on regular email until March
6th, but I just saw this and wanted to comment quickly)
On Thu, Feb 28, 2013 at 7:26 PM, Namhyung Kim <namhyung@kernel.org> wrote:
> From: Namhyung Kim <namhyung.kim@lge.com>
>
> The calc_tg_weight() and calc_cfs_shares() used cfs_rq->load.weight
> but this is no longer valid for per-entity load tracking since
> cfs_rq->tg_load_contrib consists of runnable_load_avg and blocked_
> load_avg. Simply using load.weight here will lose blocked_load_avg
> part so will result in an inaccurate share.
>
> Cc: Paul Turner <pjt@google.com>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
> kernel/sched/fair.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 7a33e5986fc5..add7440bd02f 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -1032,13 +1032,13 @@ static inline long calc_tg_weight(struct task_group *tg, struct cfs_rq *cfs_rq)
> long tg_weight;
>
> /*
> - * Use this CPU's actual weight instead of the last load_contribution
> - * to gain a more accurate current total weight. See
> - * update_cfs_rq_load_contribution().
> + * Use this CPU's actual load instead of the last load_contribution
> + * to gain a more accurate current total load. See
> + * __update_cfs_rq_tg_load_contrib().
> */
> tg_weight = atomic64_read(&tg->load_avg);
> tg_weight -= cfs_rq->tg_load_contrib;
> - tg_weight += cfs_rq->load.weight;
> + tg_weight += cfs_rq->runnable_load_avg + cfs_rq->blocked_load_avg;
No -- we _really_ do want to use the instantaneous weight, the
maintained averages are back-wards looking and do not always predict
future usage. We played with allocation strategies like the above
during this development and it ends up being a big loss for latency.
In particular:
tasks with a low runnable averages are almost always going to be
_under_ their fair share; using the current runnable average here then
harshly penalizes their ability to pre-empt when the calculated weight
is subsequently used for emplacement. Stronger: Such tasks are
typically interactive (having to wait for us slow humans and all).
Consider what the above would do to a while(1) versus interactive
thread in the same cgroup; the cpu holding the while(1) thread is
always going to wholly dominate share allocation.
> return tg_weight;
> }
> @@ -1048,7 +1048,7 @@ static long calc_cfs_shares(struct cfs_rq *cfs_rq, struct task_group *tg)
> long tg_weight, load, shares;
>
> tg_weight = calc_tg_weight(tg, cfs_rq);
> - load = cfs_rq->load.weight;
> + load = cfs_rq->runnable_load_avg + cfs_rq->blocked_load_avg;
>
> shares = (tg->shares * load);
> if (tg_weight)
> --
> 1.7.11.7
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-03-04 9:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-28 6:26 [PATCH] sched: Fix calc_cfs_shares() to consider blocked_load_avg also Namhyung Kim
2013-03-04 9:13 ` Paul Turner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).