lkml.org 
[lkml]   [2012]   [Mar]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 2/6] Don't touch the snap in srcu_readers_active()
    Date
    srcu_readers_active() is called without the mutex, but it touch the snap.
    also achieve better cache locality a little

    Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
    ---
    kernel/srcu.c | 9 ++++++++-
    1 files changed, 8 insertions(+), 1 deletions(-)

    diff --git a/kernel/srcu.c b/kernel/srcu.c
    index b6b9ea2..fbe2d5f 100644
    --- a/kernel/srcu.c
    +++ b/kernel/srcu.c
    @@ -181,7 +181,14 @@ static bool srcu_readers_active_idx_check(struct srcu_struct *sp, int idx)
    */
    static int srcu_readers_active(struct srcu_struct *sp)
    {
    - return srcu_readers_active_idx(sp, 0) + srcu_readers_active_idx(sp, 1);
    + int cpu;
    + unsigned long sum = 0;
    +
    + for_each_possible_cpu(cpu) {
    + sum += ACCESS_ONCE(per_cpu_ptr(sp->per_cpu_ref, cpu)->c[0]);
    + sum += ACCESS_ONCE(per_cpu_ptr(sp->per_cpu_ref, cpu)->c[1]);
    + }
    + return sum & SRCU_REF_MASK;
    }

    /**
    --
    1.7.4.4


    \
     
     \ /
      Last update: 2012-03-06 10:55    [W:0.021 / U:2.976 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site