public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Paul Turner <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@kernel.org,
	peterz@infradead.org, pjt@google.com, tglx@linutronix.de
Subject: [tip:sched/core] sched: Guarantee new group-entities always have weight
Date: Tue, 29 Oct 2013 07:07:40 -0700	[thread overview]
Message-ID: <tip-0ac9b1c21874d2490331233b3242085f8151e166@git.kernel.org> (raw)
In-Reply-To: <20131016181627.22647.47543.stgit@sword-of-the-dawn.mtv.corp.google.com>

Commit-ID:  0ac9b1c21874d2490331233b3242085f8151e166
Gitweb:     http://git.kernel.org/tip/0ac9b1c21874d2490331233b3242085f8151e166
Author:     Paul Turner <pjt@google.com>
AuthorDate: Wed, 16 Oct 2013 11:16:27 -0700
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 29 Oct 2013 12:02:23 +0100

sched: Guarantee new group-entities always have weight

Currently, group entity load-weights are initialized to zero. This
admits some races with respect to the first time they are re-weighted in
earlty use. ( Let g[x] denote the se for "g" on cpu "x". )

Suppose that we have root->a and that a enters a throttled state,
immediately followed by a[0]->t1 (the only task running on cpu[0])
blocking:

  put_prev_task(group_cfs_rq(a[0]), t1)
  put_prev_entity(..., t1)
  check_cfs_rq_runtime(group_cfs_rq(a[0]))
  throttle_cfs_rq(group_cfs_rq(a[0]))

Then, before unthrottling occurs, let a[0]->b[0]->t2 wake for the first
time:

  enqueue_task_fair(rq[0], t2)
  enqueue_entity(group_cfs_rq(b[0]), t2)
  enqueue_entity_load_avg(group_cfs_rq(b[0]), t2)
  account_entity_enqueue(group_cfs_ra(b[0]), t2)
  update_cfs_shares(group_cfs_rq(b[0]))
  < skipped because b is part of a throttled hierarchy >
  enqueue_entity(group_cfs_rq(a[0]), b[0])
  ...

We now have b[0] enqueued, yet group_cfs_rq(a[0])->load.weight == 0
which violates invariants in several code-paths. Eliminate the
possibility of this by initializing group entity weight.

Signed-off-by: Paul Turner <pjt@google.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20131016181627.22647.47543.stgit@sword-of-the-dawn.mtv.corp.google.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/sched/fair.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index f6308cb..0923ab2 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -7198,7 +7198,8 @@ void init_tg_cfs_entry(struct task_group *tg, struct cfs_rq *cfs_rq,
 		se->cfs_rq = parent->my_q;
 
 	se->my_q = cfs_rq;
-	update_load_set(&se->load, 0);
+	/* guarantee group entities always have weight */
+	update_load_set(&se->load, NICE_0_LOAD);
 	se->parent = parent;
 }
 

  parent reply	other threads:[~2013-10-29 14:10 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-16 18:16 [PATCH 0/5] Fix several races in CFS_BANDWIDTH Ben Segall
2013-10-16 18:16 ` [PATCH 1/5] sched: Fix race on toggling cfs_bandwidth_used Ben Segall
2013-10-29 14:07   ` [tip:sched/core] " tip-bot for Ben Segall
2013-10-16 18:16 ` [PATCH 2/5] sched: Fix cfs_bandwidth misuse of hrtimer_expires_remaining Ben Segall
2013-10-16 18:41   ` Peter Zijlstra
2013-10-16 19:12     ` bsegall
2013-10-29 14:07   ` [tip:sched/core] " tip-bot for Ben Segall
2013-10-16 18:16 ` [PATCH 3/5] sched: Fix hrtimer_cancel/rq->lock deadlock Ben Segall
2013-10-29 14:07   ` [tip:sched/core] sched: Fix hrtimer_cancel()/rq->lock deadlock tip-bot for Ben Segall
2013-10-16 18:16 ` [PATCH 4/5] sched: Guarantee new group-entities always have weight Ben Segall
2013-10-16 22:01   ` Peter Zijlstra
2013-10-16 22:16     ` Paul Turner
2013-10-16 22:22       ` Peter Zijlstra
2013-10-16 22:40     ` bsegall
2013-10-29 14:07   ` tip-bot for Paul Turner [this message]
2013-10-16 18:16 ` [PATCH 5/5] sched: Avoid throttle_cfs_rq racing with period_timer stopping Ben Segall
2013-10-16 22:06   ` Peter Zijlstra
2013-10-29 14:07   ` [tip:sched/core] sched: Avoid throttle_cfs_rq() " tip-bot for Ben Segall

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=tip-0ac9b1c21874d2490331233b3242085f8151e166@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=pjt@google.com \
    --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