Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 327157
b: refs/heads/master
c: b549007
h: refs/heads/master
i:
  327155: d060274
v: v3
  • Loading branch information
Tejun Heo committed Aug 3, 2012
1 parent 59d1ab8 commit f2e89e1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: bf4ede014ea886b71ef71368738da35b316cb7c0
refs/heads/master: b5490077274482efde57a50b060b99bc839acd45
8 changes: 7 additions & 1 deletion trunk/include/linux/workqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,15 @@ enum {
WORK_STRUCT_FLAG_BITS = WORK_STRUCT_COLOR_SHIFT +
WORK_STRUCT_COLOR_BITS,

/* data contains off-queue information when !WORK_STRUCT_CWQ */
WORK_OFFQ_FLAG_BASE = WORK_STRUCT_FLAG_BITS,
WORK_OFFQ_FLAG_BITS = 0,
WORK_OFFQ_CPU_SHIFT = WORK_OFFQ_FLAG_BASE + WORK_OFFQ_FLAG_BITS,

/* convenience constants */
WORK_STRUCT_FLAG_MASK = (1UL << WORK_STRUCT_FLAG_BITS) - 1,
WORK_STRUCT_WQ_DATA_MASK = ~WORK_STRUCT_FLAG_MASK,
WORK_STRUCT_NO_CPU = WORK_CPU_NONE << WORK_STRUCT_FLAG_BITS,
WORK_STRUCT_NO_CPU = (unsigned long)WORK_CPU_NONE << WORK_OFFQ_CPU_SHIFT,

/* bit mask for work_busy() return values */
WORK_BUSY_PENDING = 1 << 0,
Expand Down
14 changes: 9 additions & 5 deletions trunk/kernel/workqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -533,9 +533,9 @@ static int work_next_color(int color)
}

/*
* A work's data points to the cwq with WORK_STRUCT_CWQ set while the
* work is on queue. Once execution starts, WORK_STRUCT_CWQ is
* cleared and the work data contains the cpu number it was last on.
* While queued, %WORK_STRUCT_CWQ is set and non flag bits of a work's data
* contain the pointer to the queued cwq. Once execution starts, the flag
* is cleared and the high bits contain OFFQ flags and CPU number.
*
* set_work_cwq(), set_work_cpu_and_clear_pending() and clear_work_data()
* can be used to set the cwq, cpu or clear work->data. These functions
Expand Down Expand Up @@ -565,7 +565,7 @@ static void set_work_cwq(struct work_struct *work,
static void set_work_cpu_and_clear_pending(struct work_struct *work,
unsigned int cpu)
{
set_work_data(work, cpu << WORK_STRUCT_FLAG_BITS, 0);
set_work_data(work, (unsigned long)cpu << WORK_OFFQ_CPU_SHIFT, 0);
}

static void clear_work_data(struct work_struct *work)
Expand All @@ -592,7 +592,7 @@ static struct global_cwq *get_work_gcwq(struct work_struct *work)
return ((struct cpu_workqueue_struct *)
(data & WORK_STRUCT_WQ_DATA_MASK))->pool->gcwq;

cpu = data >> WORK_STRUCT_FLAG_BITS;
cpu = data >> WORK_OFFQ_CPU_SHIFT;
if (cpu == WORK_CPU_NONE)
return NULL;

Expand Down Expand Up @@ -3724,6 +3724,10 @@ static int __init init_workqueues(void)
unsigned int cpu;
int i;

/* make sure we have enough bits for OFFQ CPU number */
BUILD_BUG_ON((1LU << (BITS_PER_LONG - WORK_OFFQ_CPU_SHIFT)) <
WORK_CPU_LAST);

cpu_notifier(workqueue_cpu_up_callback, CPU_PRI_WORKQUEUE_UP);
cpu_notifier(workqueue_cpu_down_callback, CPU_PRI_WORKQUEUE_DOWN);

Expand Down

0 comments on commit f2e89e1

Please sign in to comment.