linux/kernel/rcu
Oleg Nesterov cc44ca848f rcu: Create rcu_sync infrastructure
The rcu_sync infrastructure can be thought of as infrastructure to be
used to implement reader-writer primitives having extremely lightweight
readers during times when there are no writers.  The first use is in
the percpu_rwsem used by the VFS subsystem.

This infrastructure is functionally equivalent to

        struct rcu_sync_struct {
                atomic_t counter;
        };

	/* Check possibility of fast-path read-side operations. */
        static inline bool rcu_sync_is_idle(struct rcu_sync_struct *rss)
        {
                return atomic_read(&rss->counter) == 0;
        }

	/* Tell readers to use slowpaths. */
        static inline void rcu_sync_enter(struct rcu_sync_struct *rss)
        {
                atomic_inc(&rss->counter);
                synchronize_sched();
        }

	/* Allow readers to once again use fastpaths. */
        static inline void rcu_sync_exit(struct rcu_sync_struct *rss)
        {
                synchronize_sched();
                atomic_dec(&rss->counter);
        }

The main difference is that it records the state and only calls
synchronize_sched() if required.  At least some of the calls to
synchronize_sched() will be optimized away when rcu_sync_enter() and
rcu_sync_exit() are invoked repeatedly in quick succession.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
2015-10-06 11:25:04 -07:00
..
Makefile rcu: Create rcu_sync infrastructure 2015-10-06 11:25:04 -07:00
rcu.h tiny_rcu: Directly force QS when call_rcu_[bh|sched]() on idle_task 2015-01-06 11:01:12 -08:00
rcutorture.c torture: Consolidate cond_resched_rcu_qs() into stutter_wait() 2015-10-06 11:25:01 -07:00
srcu.c rcu: Rename rcu_lockdep_assert() to RCU_LOCKDEP_WARN() 2015-07-22 15:27:32 -07:00
sync.c rcu: Create rcu_sync infrastructure 2015-10-06 11:25:04 -07:00
tiny_plugin.h rcu: Convert ACCESS_ONCE() to READ_ONCE() and WRITE_ONCE() 2015-05-27 12:56:15 -07:00
tiny.c rcu: Rename rcu_lockdep_assert() to RCU_LOCKDEP_WARN() 2015-07-22 15:27:32 -07:00
tree_plugin.h Merge branches 'fixes.2015.07.22a' and 'initexp.2015.08.04a' into HEAD 2015-08-04 08:40:58 -07:00
tree_trace.c rcu: Add fastpath bypassing funnel locking 2015-07-17 14:59:06 -07:00
tree.c rcu: Suppress lockdep false positive for rcp->exp_funnel_mutex 2015-09-20 21:01:22 -07:00
tree.h rcu,locking: Privatize smp_mb__after_unlock_lock() 2015-08-04 08:49:21 -07:00
update.c rcu: Fix backwards RCU_LOCKDEP_WARN() in synchronize_rcu_tasks() 2015-07-22 15:27:33 -07:00