History

workqueue: introduce WORK_OFFQ_CPU_NONE

Currently, when a work item is off queue, high bits of its data encodes the last CPU it was on. This is scheduled to be changed to pool ID, which will make it impossible to use WORK_CPU_NONE to indicate no association. This patch limits the number of bits which are used for off-queue cpu number to 31 (so that the max fits in an int) and uses the highest possible value - WORK_OFFQ_CPU_NONE - to indicate no association.

Tejun Heo committed 13 years ago

Commit 715b06b1 parent 35b6bb62 files · +11 −3Browse files

Showing the changes to kernel/workqueue.c (1 of 2 files). Show all

Unified · Split

kernel/workqueue.c+2−2
@@ -573,7 +573,7 @@ static struct global_cwq *get_work_gcwq(struct work_struct *work) · 572 unmodified lines
573 (data & WORK_STRUCT_WQ_DATA_MASK))->pool->gcwq;573 (data & WORK_STRUCT_WQ_DATA_MASK))->pool->gcwq;
574 574
575 cpu = data >> WORK_OFFQ_CPU_SHIFT;575 cpu = data >> WORK_OFFQ_CPU_SHIFT;
576 if (cpu == WORK_CPU_NONE)576 if (cpu == WORK_OFFQ_CPU_NONE)
577 return NULL;577 return NULL;
578 578
579 BUG_ON(cpu >= nr_cpu_ids && cpu != WORK_CPU_UNBOUND);579 BUG_ON(cpu >= nr_cpu_ids && cpu != WORK_CPU_UNBOUND);
@@ -583,7 +583,7 @@ static struct global_cwq *get_work_gcwq(struct work_struct *work) · 3 unmodified lines
583static void mark_work_canceling(struct work_struct *work)583static void mark_work_canceling(struct work_struct *work)
584{584{
585 struct global_cwq *gcwq = get_work_gcwq(work);585 struct global_cwq *gcwq = get_work_gcwq(work);
586 unsigned long cpu = gcwq ? gcwq->cpu : WORK_CPU_NONE;586 unsigned long cpu = gcwq ? gcwq->cpu : WORK_OFFQ_CPU_NONE;
587 587
588 set_work_data(work, (cpu << WORK_OFFQ_CPU_SHIFT) | WORK_OFFQ_CANCELING,588 set_work_data(work, (cpu << WORK_OFFQ_CPU_SHIFT) | WORK_OFFQ_CANCELING,
589 WORK_STRUCT_PENDING);589 WORK_STRUCT_PENDING);