Skip to content

Commit

Permalink
workqueue: use percpu allocator for cwq on UP
Browse files Browse the repository at this point in the history
I notice that the commit bbddff makes percpu allocator can work on UP,
So we don't need the magic way for UP.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
  • Loading branch information
Lai Jiangshan authored and Tejun Heo committed Mar 12, 2012
1 parent fde7d90 commit e06ffa1
Showing 1 changed file with 3 additions and 19 deletions.
22 changes: 3 additions & 19 deletions kernel/workqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -474,13 +474,8 @@ static struct cpu_workqueue_struct *get_cwq(unsigned int cpu,
struct workqueue_struct *wq)
{
if (!(wq->flags & WQ_UNBOUND)) {
if (likely(cpu < nr_cpu_ids)) {
#ifdef CONFIG_SMP
if (likely(cpu < nr_cpu_ids))
return per_cpu_ptr(wq->cpu_wq.pcpu, cpu);
#else
return wq->cpu_wq.single;
#endif
}
} else if (likely(cpu == WORK_CPU_UNBOUND))
return wq->cpu_wq.single;
return NULL;
Expand Down Expand Up @@ -2897,13 +2892,8 @@ static int alloc_cwqs(struct workqueue_struct *wq)
const size_t size = sizeof(struct cpu_workqueue_struct);
const size_t align = max_t(size_t, 1 << WORK_STRUCT_FLAG_BITS,
__alignof__(unsigned long long));
#ifdef CONFIG_SMP
bool percpu = !(wq->flags & WQ_UNBOUND);
#else
bool percpu = false;
#endif

if (percpu)
if (!(wq->flags & WQ_UNBOUND))
wq->cpu_wq.pcpu = __alloc_percpu(size, align);
else {
void *ptr;
Expand All @@ -2927,13 +2917,7 @@ static int alloc_cwqs(struct workqueue_struct *wq)

static void free_cwqs(struct workqueue_struct *wq)
{
#ifdef CONFIG_SMP
bool percpu = !(wq->flags & WQ_UNBOUND);
#else
bool percpu = false;
#endif

if (percpu)
if (!(wq->flags & WQ_UNBOUND))
free_percpu(wq->cpu_wq.pcpu);
else if (wq->cpu_wq.single) {
/* the pointer to free is stored right after the cwq */
Expand Down

0 comments on commit e06ffa1

Please sign in to comment.