summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kmo@daterainc.com>2013-08-07 12:52:58 -0700
committerKent Overstreet <kmo@daterainc.com>2013-08-07 12:52:58 -0700
commite2b8016de49c28c0ccbe7849d7254f005c7e2e77 (patch)
treea749ddbd6f58734f2ec8428ec87896f350159c80
parent6bf91199f31bec9e6e3c533bfb7d7ba93d7aa98c (diff)
idr: Use this_cpu_ptr() for percpu_ida
-rw-r--r--lib/idr.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/idr.c b/lib/idr.c
index fb374c3b656f..320ffea9148e 100644
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -748,12 +748,10 @@ int percpu_ida_alloc(struct percpu_ida *pool, gfp_t gfp)
DEFINE_WAIT(wait);
struct percpu_ida_cpu *tags;
unsigned long flags;
- unsigned this_cpu;
int tag;
local_irq_save(flags);
- this_cpu = smp_processor_id();
- tags = per_cpu_ptr(pool->tag_cpu, this_cpu);
+ tags = this_cpu_ptr(pool->tag_cpu);
/* Fastpath */
tag = alloc_local_tag(pool, tags);
@@ -782,7 +780,8 @@ int percpu_ida_alloc(struct percpu_ida *pool, gfp_t gfp)
if (tags->nr_free) {
tag = tags->freelist[--tags->nr_free];
if (tags->nr_free)
- set_bit(this_cpu, pool->cpus_have_tags);
+ set_bit(smp_processor_id(),
+ pool->cpus_have_tags);
}
spin_unlock(&pool->ida.lock);
@@ -794,8 +793,7 @@ int percpu_ida_alloc(struct percpu_ida *pool, gfp_t gfp)
schedule();
local_irq_save(flags);
- this_cpu = smp_processor_id();
- tags = per_cpu_ptr(pool->tag_cpu, this_cpu);
+ tags = this_cpu_ptr(pool->tag_cpu);
}
finish_wait(&pool->wait, &wait);
@@ -814,13 +812,12 @@ void percpu_ida_free(struct percpu_ida *pool, unsigned tag)
{
struct percpu_ida_cpu *tags;
unsigned long flags;
- unsigned nr_free, this_cpu;
+ unsigned nr_free;
BUG_ON(tag >= pool->nr_tags);
local_irq_save(flags);
- this_cpu = smp_processor_id();
- tags = per_cpu_ptr(pool->tag_cpu, this_cpu);
+ tags = this_cpu_ptr(pool->tag_cpu);
spin_lock(&tags->lock);
tags->freelist[tags->nr_free++] = tag;
@@ -829,7 +826,8 @@ void percpu_ida_free(struct percpu_ida *pool, unsigned tag)
spin_unlock(&tags->lock);
if (nr_free == 1) {
- set_bit(this_cpu, pool->cpus_have_tags);
+ set_bit(smp_processor_id(),
+ pool->cpus_have_tags);
wake_up(&pool->wait);
}