diff options
author | Tejun Heo <tj@kernel.org> | 2010-06-29 04:07:13 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2010-06-29 04:07:13 -0400 |
commit | 7a22ad757ec75186ad43a5b4670fa7423ee8f480 (patch) | |
tree | 698807765421a46dcb5e2daa609336a61d1cdea5 /include/linux/workqueue.h | |
parent | 8cca0eea3964b72b14e8c3f88e3a40bef7b9113e (diff) |
workqueue: carry cpu number in work data once execution starts
To implement non-reentrant workqueue, the last gcwq a work was
executed on must be reliably obtainable as long as the work structure
is valid even if the previous workqueue has been destroyed.
To achieve this, work->data will be overloaded to carry the last cpu
number once execution starts so that the previous gcwq can be located
reliably. This means that cwq can't be obtained from work after
execution starts but only gcwq.
Implement set_work_{cwq|cpu}(), get_work_[g]cwq() and
clear_work_data() to set work data to the cpu number when starting
execution, access the overloaded work data and clear it after
cancellation.
queue_delayed_work_on() is updated to preserve the last cpu while
in-flight in timer and other callers which depended on getting cwq
from work after execution starts are converted to depend on gcwq
instead.
* Anton Blanchard fixed compile error on powerpc due to missing
linux/threads.h include.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Anton Blanchard <anton@samba.org>
Diffstat (limited to 'include/linux/workqueue.h')
-rw-r--r-- | include/linux/workqueue.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h index 10611f7fc809..0a7814131e66 100644 --- a/include/linux/workqueue.h +++ b/include/linux/workqueue.h | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <linux/linkage.h> | 9 | #include <linux/linkage.h> |
10 | #include <linux/bitops.h> | 10 | #include <linux/bitops.h> |
11 | #include <linux/lockdep.h> | 11 | #include <linux/lockdep.h> |
12 | #include <linux/threads.h> | ||
12 | #include <asm/atomic.h> | 13 | #include <asm/atomic.h> |
13 | 14 | ||
14 | struct workqueue_struct; | 15 | struct workqueue_struct; |
@@ -59,6 +60,7 @@ enum { | |||
59 | 60 | ||
60 | WORK_STRUCT_FLAG_MASK = (1UL << WORK_STRUCT_FLAG_BITS) - 1, | 61 | WORK_STRUCT_FLAG_MASK = (1UL << WORK_STRUCT_FLAG_BITS) - 1, |
61 | WORK_STRUCT_WQ_DATA_MASK = ~WORK_STRUCT_FLAG_MASK, | 62 | WORK_STRUCT_WQ_DATA_MASK = ~WORK_STRUCT_FLAG_MASK, |
63 | WORK_STRUCT_NO_CPU = NR_CPUS << WORK_STRUCT_FLAG_BITS, | ||
62 | }; | 64 | }; |
63 | 65 | ||
64 | struct work_struct { | 66 | struct work_struct { |
@@ -70,8 +72,9 @@ struct work_struct { | |||
70 | #endif | 72 | #endif |
71 | }; | 73 | }; |
72 | 74 | ||
73 | #define WORK_DATA_INIT() ATOMIC_LONG_INIT(0) | 75 | #define WORK_DATA_INIT() ATOMIC_LONG_INIT(WORK_STRUCT_NO_CPU) |
74 | #define WORK_DATA_STATIC_INIT() ATOMIC_LONG_INIT(WORK_STRUCT_STATIC) | 76 | #define WORK_DATA_STATIC_INIT() \ |
77 | ATOMIC_LONG_INIT(WORK_STRUCT_NO_CPU | WORK_STRUCT_STATIC) | ||
75 | 78 | ||
76 | struct delayed_work { | 79 | struct delayed_work { |
77 | struct work_struct work; | 80 | struct work_struct work; |