diff options
author | Tejun Heo <tj@kernel.org> | 2014-06-28 08:10:12 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2014-06-28 08:10:12 -0400 |
commit | d630dc4c9adb41e5bd1e06df2dbeaf622469ddd5 (patch) | |
tree | 4dc8afb3469f6bb27f3737b48d398ea4fa10e3e6 | |
parent | 55c6c814ae0aa896781d3c51e4608de542624f64 (diff) |
percpu-refcount: one bit is enough for REF_STATUS
percpu-refcount currently reserves two lowest bits of its percpu
pointer to indicate its state; however, only one bit is used for
PCPU_REF_DEAD.
Simplify it by removing PCPU_STATUS_BITS/MASK and testing
PCPU_REF_DEAD directly. This also allows the compiler to choose a
more efficient instruction depending on the architecture.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Kent Overstreet <kmo@daterainc.com>
Cc: Christoph Lameter <cl@linux-foundation.org>
-rw-r--r-- | include/linux/percpu-refcount.h | 4 | ||||
-rw-r--r-- | lib/percpu-refcount.c | 2 |
2 files changed, 2 insertions, 4 deletions
diff --git a/include/linux/percpu-refcount.h b/include/linux/percpu-refcount.h index 5d8920e23073..bfdeb0d48e21 100644 --- a/include/linux/percpu-refcount.h +++ b/include/linux/percpu-refcount.h | |||
@@ -88,12 +88,10 @@ static inline void percpu_ref_kill(struct percpu_ref *ref) | |||
88 | return percpu_ref_kill_and_confirm(ref, NULL); | 88 | return percpu_ref_kill_and_confirm(ref, NULL); |
89 | } | 89 | } |
90 | 90 | ||
91 | #define PCPU_STATUS_BITS 2 | ||
92 | #define PCPU_STATUS_MASK ((1 << PCPU_STATUS_BITS) - 1) | ||
93 | #define PCPU_REF_PTR 0 | 91 | #define PCPU_REF_PTR 0 |
94 | #define PCPU_REF_DEAD 1 | 92 | #define PCPU_REF_DEAD 1 |
95 | 93 | ||
96 | #define REF_STATUS(count) (((unsigned long) count) & PCPU_STATUS_MASK) | 94 | #define REF_STATUS(count) (((unsigned long) count) & PCPU_REF_DEAD) |
97 | 95 | ||
98 | /** | 96 | /** |
99 | * percpu_ref_get - increment a percpu refcount | 97 | * percpu_ref_get - increment a percpu refcount |
diff --git a/lib/percpu-refcount.c b/lib/percpu-refcount.c index 963b7034a51b..17bce2bccc14 100644 --- a/lib/percpu-refcount.c +++ b/lib/percpu-refcount.c | |||
@@ -96,7 +96,7 @@ static void percpu_ref_kill_rcu(struct rcu_head *rcu) | |||
96 | 96 | ||
97 | /* Mask out PCPU_REF_DEAD */ | 97 | /* Mask out PCPU_REF_DEAD */ |
98 | pcpu_count = (unsigned __percpu *) | 98 | pcpu_count = (unsigned __percpu *) |
99 | (((unsigned long) pcpu_count) & ~PCPU_STATUS_MASK); | 99 | (((unsigned long) pcpu_count) & ~PCPU_REF_DEAD); |
100 | 100 | ||
101 | for_each_possible_cpu(cpu) | 101 | for_each_possible_cpu(cpu) |
102 | count += *per_cpu_ptr(pcpu_count, cpu); | 102 | count += *per_cpu_ptr(pcpu_count, cpu); |