From ce6e7c9bfb15a0fd2d151a265cae60a7161a4b07 Mon Sep 17 00:00:00 2001 From: Christoph Lameter Date: Tue, 6 Nov 2007 11:33:57 -0800 Subject: [PATCH] cpu alloc: Use for infiniband Signed-off-by: Christoph Lameter --- drivers/infiniband/hw/ehca/ehca_irq.c | 22 +++++++++++----------- 1 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/infiniband/hw/ehca/ehca_irq.c b/drivers/infiniband/hw/ehca/ehca_irq.c index 3f617b2..292971a 100644 --- a/drivers/infiniband/hw/ehca/ehca_irq.c +++ b/drivers/infiniband/hw/ehca/ehca_irq.c @@ -646,7 +646,7 @@ static void queue_comp_task(struct ehca_cq *__cq) cpu_id = find_next_online_cpu(pool); BUG_ON(!cpu_online(cpu_id)); - cct = per_cpu_ptr(pool->cpu_comp_tasks, cpu_id); + cct = CPU_PTR(pool->cpu_comp_tasks, cpu_id); BUG_ON(!cct); spin_lock_irqsave(&cct->task_lock, flags); @@ -654,7 +654,7 @@ static void queue_comp_task(struct ehca_cq *__cq) spin_unlock_irqrestore(&cct->task_lock, flags); if (cq_jobs > 0) { cpu_id = find_next_online_cpu(pool); - cct = per_cpu_ptr(pool->cpu_comp_tasks, cpu_id); + cct = CPU_PTR(pool->cpu_comp_tasks, cpu_id); BUG_ON(!cct); } @@ -727,7 +727,7 @@ static struct task_struct *create_comp_task(struct ehca_comp_pool *pool, { struct ehca_cpu_comp_task *cct; - cct = per_cpu_ptr(pool->cpu_comp_tasks, cpu); + cct = CPU_PTR(pool->cpu_comp_tasks, cpu); spin_lock_init(&cct->task_lock); INIT_LIST_HEAD(&cct->cq_list); init_waitqueue_head(&cct->wait_queue); @@ -743,7 +743,7 @@ static void destroy_comp_task(struct ehca_comp_pool *pool, struct task_struct *task; unsigned long flags_cct; - cct = per_cpu_ptr(pool->cpu_comp_tasks, cpu); + cct = CPU_PTR(pool->cpu_comp_tasks, cpu); spin_lock_irqsave(&cct->task_lock, flags_cct); @@ -759,7 +759,7 @@ static void destroy_comp_task(struct ehca_comp_pool *pool, static void __cpuinit take_over_work(struct ehca_comp_pool *pool, int cpu) { - struct ehca_cpu_comp_task *cct = per_cpu_ptr(pool->cpu_comp_tasks, cpu); + struct ehca_cpu_comp_task *cct = CPU_PTR(pool->cpu_comp_tasks, cpu); LIST_HEAD(list); struct ehca_cq *cq; unsigned long flags_cct; @@ -772,8 +772,7 @@ static void __cpuinit take_over_work(struct ehca_comp_pool *pool, int cpu) cq = list_entry(cct->cq_list.next, struct ehca_cq, entry); list_del(&cq->entry); - __queue_comp_task(cq, per_cpu_ptr(pool->cpu_comp_tasks, - smp_processor_id())); + __queue_comp_task(cq, THIS_CPU(pool->cpu_comp_tasks)); } spin_unlock_irqrestore(&cct->task_lock, flags_cct); @@ -799,14 +798,14 @@ static int __cpuinit comp_pool_callback(struct notifier_block *nfb, case CPU_UP_CANCELED: case CPU_UP_CANCELED_FROZEN: ehca_gen_dbg("CPU: %x (CPU_CANCELED)", cpu); - cct = per_cpu_ptr(pool->cpu_comp_tasks, cpu); + cct = CPU_PTR(pool->cpu_comp_tasks, cpu); kthread_bind(cct->task, any_online_cpu(cpu_online_map)); destroy_comp_task(pool, cpu); break; case CPU_ONLINE: case CPU_ONLINE_FROZEN: ehca_gen_dbg("CPU: %x (CPU_ONLINE)", cpu); - cct = per_cpu_ptr(pool->cpu_comp_tasks, cpu); + cct = CPU_PTR(pool->cpu_comp_tasks, cpu); kthread_bind(cct->task, cpu); wake_up_process(cct->task); break; @@ -849,7 +848,8 @@ int ehca_create_comp_pool(void) spin_lock_init(&pool->last_cpu_lock); pool->last_cpu = any_online_cpu(cpu_online_map); - pool->cpu_comp_tasks = alloc_percpu(struct ehca_cpu_comp_task); + pool->cpu_comp_tasks = CPU_ALLOC(struct ehca_cpu_comp_task, + GFP_KERNEL | __GFP_ZERO); if (pool->cpu_comp_tasks == NULL) { kfree(pool); return -EINVAL; @@ -883,6 +883,6 @@ void ehca_destroy_comp_pool(void) if (cpu_online(i)) destroy_comp_task(pool, i); } - free_percpu(pool->cpu_comp_tasks); + CPU_FREE(pool->cpu_comp_tasks); kfree(pool); } -- 1.5.3.4