In case percpu_max_size is 1 percpu_ida_free() sets bit in
the cpumask and immediately transfers the tag to the pool.
As result, the very next call to percpu_ida_alloc() on the
same CPU will have to pull a tag from the pool to the local
cache and so on. Hence, positive effects of local caching
become largely negated.
This update assumes stealing tags is faster than ping-ponging
between local caches and the pool and prevents returning tags
to the pool in case percpu_max_size is 1.
Signed-off-by: Alexander Gordeev <[email protected]>
---
lib/percpu_ida.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/lib/percpu_ida.c b/lib/percpu_ida.c
index 9dd8741..4adc3e5 100644
--- a/lib/percpu_ida.c
+++ b/lib/percpu_ida.c
@@ -243,9 +243,8 @@ void percpu_ida_free(struct percpu_ida *pool, unsigned tag)
*/
smp_wmb();
wake_up = true;
- }
-
- if (nr_free == pool->percpu_max_size) {
+ } else if ((nr_free == pool->percpu_max_size) &&
+ (pool->percpu_max_size > 1)) {
spin_lock(&pool->lock);
/*
--
1.7.7.6
--
Regards,
Alexander Gordeev
[email protected]