• Lance Roy's avatar
    srcu: Implement more-efficient reader counts · f2c46896
    Lance Roy authored
    SRCU uses two per-cpu counters: a nesting counter to count the number of
    active critical sections, and a sequence counter to ensure that the nesting
    counters don't change while they are being added together in
    srcu_readers_active_idx_check().
    
    This patch instead uses per-cpu lock and unlock counters. Because both
    counters only increase and srcu_readers_active_idx_check() reads the unlock
    counter before the lock counter, this achieves the same end without having
    to increment two different counters in srcu_read_lock(). This also saves a
    smp_mb() in srcu_readers_active_idx_check().
    
    Possible bug: There is no guarantee that the lock counter won't overflow
    during srcu_readers_active_idx_check(), as there are no memory barriers
    around srcu_flip() (see comment in srcu_readers_active_idx_check() for
    details). However, this problem was already present before this patch.
    Suggested-by: default avatarMathieu Desnoyers <mathieu.desnoyers@efficios.com>
    Signed-off-by: default avatarLance Roy <ldr709@gmail.com>
    Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
    Cc: Lai Jiangshan <jiangshanlai@gmail.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Signed-off-by: default avatarPaul E. McKenney <paulmck@linux.vnet.ibm.com>
    f2c46896
rcutorture.c 54.2 KB