]> asedeno.scripts.mit.edu Git - linux.git/commit
srcu: Implement more-efficient reader counts
authorLance Roy <ldr709@gmail.com>
Mon, 23 Jan 2017 21:35:18 +0000 (13:35 -0800)
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Wed, 25 Jan 2017 20:53:20 +0000 (12:53 -0800)
commitf2c4689640e9a34bc45c013032185ed4ce47e7ff
treeb83abdbccba941253a9296379e00d09ce355ec2d
parent52d7e48b86fc108e45a656d8e53e4237993c481d
srcu: Implement more-efficient reader counts

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: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Lance 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: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
include/linux/srcu.h
kernel/rcu/rcutorture.c
kernel/rcu/srcu.c