From: Peter Zijlstra <peterz@infradead.org>
To: mingo@kernel.org, umgwanakikbuti@gmail.com
Cc: linux-kernel@vger.kernel.org, torvalds@linux-foundation.org,
"Peter Zijlstra" <peterz@infradead.org>
Subject: [RFC][PATCH 1/3] sched: Validate rq_clock*() serialization
Date: Mon, 05 Jan 2015 11:18:10 +0100 [thread overview]
Message-ID: <20150105103554.361872747@infradead.org> (raw)
In-Reply-To: <20150105101809.860964488@infradead.org>
[-- Attachment #1: peterz-sched-rq_clock-locking.patch --]
[-- Type: text/plain, Size: 1270 bytes --]
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 32bit is affected)
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
kernel/sched/fair.c | 2 +-
kernel/sched/sched.h | 7 +++++++
2 files changed, 8 insertions(+), 1 deletion(-)
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -5945,8 +5945,8 @@ static unsigned long scale_rt_capacity(i
*/
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;
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -687,13 +687,20 @@ DECLARE_PER_CPU_SHARED_ALIGNED(struct rq
#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;
}
next prev parent reply other threads:[~2015-01-05 10:38 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 ` Peter Zijlstra [this message]
2015-01-14 14:03 ` [tip:sched/core] sched/core: Validate rq_clock*() serialization tip-bot for Peter Zijlstra
2015-05-30 1:03 ` 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=20150105103554.361872747@infradead.org \
--to=peterz@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=umgwanakikbuti@gmail.com \
/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