|
24 | 24 |
|
25 | 25 | enum work_bits {
|
26 | 26 | WORK_STRUCT_PENDING_BIT = 0, /* work item is pending execution */
|
27 |
| - WORK_STRUCT_INACTIVE_BIT= 1, /* work item is inactive */ |
28 |
| - WORK_STRUCT_PWQ_BIT = 2, /* data points to pwq */ |
29 |
| - WORK_STRUCT_LINKED_BIT = 3, /* next work is linked to this one */ |
| 27 | + WORK_STRUCT_INACTIVE_BIT, /* work item is inactive */ |
| 28 | + WORK_STRUCT_PWQ_BIT, /* data points to pwq */ |
| 29 | + WORK_STRUCT_LINKED_BIT, /* next work is linked to this one */ |
30 | 30 | #ifdef CONFIG_DEBUG_OBJECTS_WORK
|
31 |
| - WORK_STRUCT_STATIC_BIT = 4, /* static initializer (debugobjects) */ |
32 |
| - WORK_STRUCT_COLOR_SHIFT = 5, /* color for workqueue flushing */ |
33 |
| -#else |
34 |
| - WORK_STRUCT_COLOR_SHIFT = 4, /* color for workqueue flushing */ |
| 31 | + WORK_STRUCT_STATIC_BIT, /* static initializer (debugobjects) */ |
35 | 32 | #endif
|
| 33 | + WORK_STRUCT_FLAG_BITS, |
36 | 34 |
|
| 35 | + /* color for workqueue flushing */ |
| 36 | + WORK_STRUCT_COLOR_SHIFT = WORK_STRUCT_FLAG_BITS, |
37 | 37 | WORK_STRUCT_COLOR_BITS = 4,
|
38 | 38 |
|
39 | 39 | /*
|
40 |
| - * Reserve 8 bits off of pwq pointer w/ debugobjects turned off. |
41 |
| - * This makes pwqs aligned to 256 bytes and allows 16 workqueue |
42 |
| - * flush colors. |
| 40 | + * When WORK_STRUCT_PWQ is set, reserve 8 bits off of pwq pointer w/ |
| 41 | + * debugobjects turned off. This makes pwqs aligned to 256 bytes (512 |
| 42 | + * bytes w/ DEBUG_OBJECTS_WORK) and allows 16 workqueue flush colors. |
| 43 | + * |
| 44 | + * MSB |
| 45 | + * [ pwq pointer ] [ flush color ] [ STRUCT flags ] |
| 46 | + * 4 bits 4 or 5 bits |
43 | 47 | */
|
44 |
| - WORK_STRUCT_FLAG_BITS = WORK_STRUCT_COLOR_SHIFT + |
45 |
| - WORK_STRUCT_COLOR_BITS, |
| 48 | + WORK_STRUCT_PWQ_SHIFT = WORK_STRUCT_COLOR_SHIFT + WORK_STRUCT_COLOR_BITS, |
46 | 49 |
|
47 |
| - /* data contains off-queue information when !WORK_STRUCT_PWQ */ |
48 |
| - WORK_OFFQ_FLAG_BASE = WORK_STRUCT_COLOR_SHIFT, |
49 |
| - |
50 |
| - __WORK_OFFQ_CANCELING = WORK_OFFQ_FLAG_BASE, |
| 50 | + /* |
| 51 | + * data contains off-queue information when !WORK_STRUCT_PWQ. |
| 52 | + * |
| 53 | + * MSB |
| 54 | + * [ pool ID ] [ OFFQ flags ] [ STRUCT flags ] |
| 55 | + * 1 bit 4 or 5 bits |
| 56 | + */ |
| 57 | + WORK_OFFQ_FLAG_SHIFT = WORK_STRUCT_FLAG_BITS, |
| 58 | + WORK_OFFQ_CANCELING_BIT = WORK_OFFQ_FLAG_SHIFT, |
| 59 | + WORK_OFFQ_FLAG_END, |
| 60 | + WORK_OFFQ_FLAG_BITS = WORK_OFFQ_FLAG_END - WORK_OFFQ_FLAG_SHIFT, |
51 | 61 |
|
52 | 62 | /*
|
53 |
| - * When a work item is off queue, its high bits point to the last |
54 |
| - * pool it was on. Cap at 31 bits and use the highest number to |
55 |
| - * indicate that no pool is associated. |
| 63 | + * When a work item is off queue, the high bits encode off-queue flags |
| 64 | + * and the last pool it was on. Cap pool ID to 31 bits and use the |
| 65 | + * highest number to indicate that no pool is associated. |
56 | 66 | */
|
57 |
| - WORK_OFFQ_FLAG_BITS = 1, |
58 |
| - WORK_OFFQ_POOL_SHIFT = WORK_OFFQ_FLAG_BASE + WORK_OFFQ_FLAG_BITS, |
| 67 | + WORK_OFFQ_POOL_SHIFT = WORK_OFFQ_FLAG_SHIFT + WORK_OFFQ_FLAG_BITS, |
59 | 68 | WORK_OFFQ_LEFT = BITS_PER_LONG - WORK_OFFQ_POOL_SHIFT,
|
60 | 69 | WORK_OFFQ_POOL_BITS = WORK_OFFQ_LEFT <= 31 ? WORK_OFFQ_LEFT : 31,
|
61 |
| - |
62 | 70 | };
|
63 | 71 |
|
64 | 72 | enum work_flags {
|
@@ -88,12 +96,10 @@ enum wq_misc_consts {
|
88 | 96 | };
|
89 | 97 |
|
90 | 98 | /* Convenience constants - of type 'unsigned long', not 'enum'! */
|
91 |
| -#define WORK_OFFQ_CANCELING (1ul << __WORK_OFFQ_CANCELING) |
| 99 | +#define WORK_OFFQ_CANCELING (1ul << WORK_OFFQ_CANCELING_BIT) |
92 | 100 | #define WORK_OFFQ_POOL_NONE ((1ul << WORK_OFFQ_POOL_BITS) - 1)
|
93 | 101 | #define WORK_STRUCT_NO_POOL (WORK_OFFQ_POOL_NONE << WORK_OFFQ_POOL_SHIFT)
|
94 |
| - |
95 |
| -#define WORK_STRUCT_FLAG_MASK ((1ul << WORK_STRUCT_FLAG_BITS) - 1) |
96 |
| -#define WORK_STRUCT_WQ_DATA_MASK (~WORK_STRUCT_FLAG_MASK) |
| 102 | +#define WORK_STRUCT_PWQ_MASK (~((1ul << WORK_STRUCT_PWQ_SHIFT) - 1)) |
97 | 103 |
|
98 | 104 | #define WORK_DATA_INIT() ATOMIC_LONG_INIT((unsigned long)WORK_STRUCT_NO_POOL)
|
99 | 105 | #define WORK_DATA_STATIC_INIT() \
|
|
0 commit comments