Commit 3fe1698b authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Ingo Molnar

sched: Deal with non-atomic min_vruntime reads on 32bits

In order to avoid reading partial updated min_vruntime values on 32bit
implement a seqcount like solution.
Reviewed-by: default avatarFrank Rowand <frank.rowand@am.sony.com>
Signed-off-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Nick Piggin <npiggin@kernel.dk>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Link: http://lkml.kernel.org/r/20110405152729.111378493@chello.nlSigned-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 74f8e4b2
...@@ -312,6 +312,9 @@ struct cfs_rq { ...@@ -312,6 +312,9 @@ struct cfs_rq {
u64 exec_clock; u64 exec_clock;
u64 min_vruntime; u64 min_vruntime;
#ifndef CONFIG_64BIT
u64 min_vruntime_copy;
#endif
struct rb_root tasks_timeline; struct rb_root tasks_timeline;
struct rb_node *rb_leftmost; struct rb_node *rb_leftmost;
......
...@@ -358,6 +358,10 @@ static void update_min_vruntime(struct cfs_rq *cfs_rq) ...@@ -358,6 +358,10 @@ static void update_min_vruntime(struct cfs_rq *cfs_rq)
} }
cfs_rq->min_vruntime = max_vruntime(cfs_rq->min_vruntime, vruntime); cfs_rq->min_vruntime = max_vruntime(cfs_rq->min_vruntime, vruntime);
#ifndef CONFIG_64BIT
smp_wmb();
cfs_rq->min_vruntime_copy = cfs_rq->min_vruntime;
#endif
} }
/* /*
...@@ -1376,10 +1380,21 @@ static void task_waking_fair(struct task_struct *p) ...@@ -1376,10 +1380,21 @@ static void task_waking_fair(struct task_struct *p)
{ {
struct sched_entity *se = &p->se; struct sched_entity *se = &p->se;
struct cfs_rq *cfs_rq = cfs_rq_of(se); struct cfs_rq *cfs_rq = cfs_rq_of(se);
u64 min_vruntime;
lockdep_assert_held(&task_rq(p)->lock); #ifndef CONFIG_64BIT
u64 min_vruntime_copy;
se->vruntime -= cfs_rq->min_vruntime; do {
min_vruntime_copy = cfs_rq->min_vruntime_copy;
smp_rmb();
min_vruntime = cfs_rq->min_vruntime;
} while (min_vruntime != min_vruntime_copy);
#else
min_vruntime = cfs_rq->min_vruntime;
#endif
se->vruntime -= min_vruntime;
} }
#ifdef CONFIG_FAIR_GROUP_SCHED #ifdef CONFIG_FAIR_GROUP_SCHED
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment