diff options
author | Tejun Heo <tj@kernel.org> | 2014-09-24 13:31:50 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2014-09-24 13:31:50 -0400 |
commit | 1cae13e75b7a7848c03138636d4eb8d8a5054dd5 (patch) | |
tree | 309eaf4b79e7a8e41e17175f3475d46bef57c2a6 /include | |
parent | 2aad2a86f6685c10360ec8a5a55eb9ab7059cb72 (diff) |
percpu_ref: make INIT_ATOMIC and switch_to_atomic() sticky
Currently, a percpu_ref which is initialized with
PERPCU_REF_INIT_ATOMIC or switched to atomic mode via
switch_to_atomic() automatically reverts to percpu mode on the first
percpu_ref_reinit(). This makes the atomic mode difficult to use for
cases where a percpu_ref is used as a persistent on/off switch which
may be cycled multiple times.
This patch makes such atomic state sticky so that it survives through
kill/reinit cycles. After this patch, atomic state is cleared only by
an explicit percpu_ref_switch_to_percpu() call.
Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Kent Overstreet <kmo@daterainc.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/percpu-refcount.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/include/linux/percpu-refcount.h b/include/linux/percpu-refcount.h index b0293f268cd2..00c01fc6d88c 100644 --- a/include/linux/percpu-refcount.h +++ b/include/linux/percpu-refcount.h | |||
@@ -67,7 +67,9 @@ enum { | |||
67 | enum { | 67 | enum { |
68 | /* | 68 | /* |
69 | * Start w/ ref == 1 in atomic mode. Can be switched to percpu | 69 | * Start w/ ref == 1 in atomic mode. Can be switched to percpu |
70 | * operation using percpu_ref_switch_to_percpu(). | 70 | * operation using percpu_ref_switch_to_percpu(). If initialized |
71 | * with this flag, the ref will stay in atomic mode until | ||
72 | * percpu_ref_switch_to_percpu() is invoked on it. | ||
71 | */ | 73 | */ |
72 | PERCPU_REF_INIT_ATOMIC = 1 << 0, | 74 | PERCPU_REF_INIT_ATOMIC = 1 << 0, |
73 | 75 | ||
@@ -87,6 +89,7 @@ struct percpu_ref { | |||
87 | unsigned long percpu_count_ptr; | 89 | unsigned long percpu_count_ptr; |
88 | percpu_ref_func_t *release; | 90 | percpu_ref_func_t *release; |
89 | percpu_ref_func_t *confirm_switch; | 91 | percpu_ref_func_t *confirm_switch; |
92 | bool force_atomic:1; | ||
90 | struct rcu_head rcu; | 93 | struct rcu_head rcu; |
91 | }; | 94 | }; |
92 | 95 | ||