lkml.org 
[lkml]   [2011]   [Apr]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[PATCH 10/21] 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.

    Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
    Reviewed-by: Frank Rowand <frank.rowand@am.sony.com>
    ---
    kernel/sched.c | 3 +++
    kernel/sched_fair.c | 19 +++++++++++++++++--
    2 files changed, 20 insertions(+), 2 deletions(-)

    Index: linux-2.6/kernel/sched.c
    ===================================================================
    --- linux-2.6.orig/kernel/sched.c
    +++ linux-2.6/kernel/sched.c
    @@ -313,6 +313,9 @@ struct cfs_rq {

    u64 exec_clock;
    u64 min_vruntime;
    +#ifndef CONFIG_64BIT
    + u64 min_vruntime_copy;
    +#endif

    struct rb_root tasks_timeline;
    struct rb_node *rb_leftmost;
    Index: linux-2.6/kernel/sched_fair.c
    ===================================================================
    --- linux-2.6.orig/kernel/sched_fair.c
    +++ linux-2.6/kernel/sched_fair.c
    @@ -365,6 +365,10 @@ static void update_min_vruntime(struct c
    }

    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
    }

    /*
    @@ -1342,10 +1346,21 @@ static void task_waking_fair(struct task
    {
    struct sched_entity *se = &p->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



    \
     
     \ /
      Last update: 2011-04-05 17:35    [W:4.363 / U:0.148 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site