OSDN Git Service

rcu: Create rcu_sync infrastructure
authorOleg Nesterov <oleg@redhat.com>
Fri, 21 Aug 2015 17:42:44 +0000 (19:42 +0200)
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Sat, 22 Aug 2015 16:31:38 +0000 (09:31 -0700)
commit114b7fd4b1c1d470046b63885251cd1f161fc7d2
tree009b107c7f14d8e2c4818f3abdbeee757f6e400e
parent12d560f4ea87030667438a169912380be00cea4b
rcu: Create rcu_sync infrastructure

It is functionally equivalent to

        struct rcu_sync_struct {
                atomic_t counter;
        };

        static inline bool rcu_sync_is_idle(struct rcu_sync_struct *rss)
        {
                return atomic_read(&rss->counter) == 0;
        }

        static inline void rcu_sync_enter(struct rcu_sync_struct *rss)
        {
                atomic_inc(&rss->counter);
                synchronize_sched();
        }

        static inline void rcu_sync_exit(struct rcu_sync_struct *rss)
        {
                synchronize_sched();
                atomic_dec(&rss->counter);
        }

except: it records the state and synchronize_sched() is only called by
rcu_sync_enter() and only if necessary.

Reviewed-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
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>
include/linux/rcusync.h [new file with mode: 0644]
kernel/rcu/Makefile
kernel/rcu/sync.c [new file with mode: 0644]