public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Peter Zijlstra <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: torvalds@linux-foundation.org, linux-kernel@vger.kernel.org,
	mingo@kernel.org, peterz@infradead.org, tglx@linutronix.de,
	hpa@zytor.com
Subject: [tip:sched/core] sched/core: Validate rq_clock*() serialization
Date: Wed, 14 Jan 2015 06:03:07 -0800	[thread overview]
Message-ID: <tip-cebde6d681aa45f96111cfcffc1544cf2a0454ff@git.kernel.org> (raw)
In-Reply-To: <20150105103554.361872747@infradead.org>

Commit-ID:  cebde6d681aa45f96111cfcffc1544cf2a0454ff
Gitweb:     http://git.kernel.org/tip/cebde6d681aa45f96111cfcffc1544cf2a0454ff
Author:     Peter Zijlstra <peterz@infradead.org>
AuthorDate: Mon, 5 Jan 2015 11:18:10 +0100
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 14 Jan 2015 13:34:19 +0100

sched/core: Validate rq_clock*() serialization

rq->clock{,_task} are serialized by rq->lock, verify this.

One immediate fail is the usage in scale_rt_capability, so 'annotate'
that for now, there's more 'funny' there. Maybe change rq->lock into a
raw_seqlock_t?

(Only 32-bit is affected)

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20150105103554.361872747@infradead.org
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: umgwanakikbuti@gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/sched/fair.c  | 2 +-
 kernel/sched/sched.h | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 2a0b302..50ff902 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -5948,8 +5948,8 @@ static unsigned long scale_rt_capacity(int cpu)
 	 */
 	age_stamp = ACCESS_ONCE(rq->age_stamp);
 	avg = ACCESS_ONCE(rq->rt_avg);
+	delta = __rq_clock_broken(rq) - age_stamp;
 
-	delta = rq_clock(rq) - age_stamp;
 	if (unlikely(delta < 0))
 		delta = 0;
 
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 9a2a45c..bd23732 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -687,13 +687,20 @@ DECLARE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues);
 #define cpu_curr(cpu)		(cpu_rq(cpu)->curr)
 #define raw_rq()		raw_cpu_ptr(&runqueues)
 
+static inline u64 __rq_clock_broken(struct rq *rq)
+{
+	return ACCESS_ONCE(rq->clock);
+}
+
 static inline u64 rq_clock(struct rq *rq)
 {
+	lockdep_assert_held(&rq->lock);
 	return rq->clock;
 }
 
 static inline u64 rq_clock_task(struct rq *rq)
 {
+	lockdep_assert_held(&rq->lock);
 	return rq->clock_task;
 }
 

  reply	other threads:[~2015-01-14 14:03 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-05 10:18 [RFC][PATCH 0/3] sched: skip_clock_update madness Peter Zijlstra
2015-01-05 10:18 ` [RFC][PATCH 1/3] sched: Validate rq_clock*() serialization Peter Zijlstra
2015-01-14 14:03   ` tip-bot for Peter Zijlstra [this message]
2015-05-30  1:03     ` [tip:sched/core] sched/core: " Sasha Levin
2015-06-04  2:28       ` Wanpeng Li
2015-01-05 10:18 ` [RFC][PATCH 2/3] sched: Rework rq->clock update skips Peter Zijlstra
2015-01-14 14:03   ` [tip:sched/core] sched/core: " tip-bot for Peter Zijlstra
2015-01-05 10:18 ` [RFC][PATCH 3/3] sched,debug: Print clock_task Peter Zijlstra
2015-01-14 14:03   ` [tip:sched/core] sched/debug: Print rq->clock_task tip-bot for Peter Zijlstra
2015-01-05 10:49 ` [RFC][PATCH 0/3] sched: skip_clock_update madness Mike Galbraith
2015-01-05 11:50   ` Peter Zijlstra
2015-01-05 12:07     ` Mike Galbraith
2015-01-05 13:59   ` Peter Zijlstra
2015-01-06  5:55     ` Mike Galbraith

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-cebde6d681aa45f96111cfcffc1544cf2a0454ff@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=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.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