Skip to content

Commit e563d0a

Browse files
committed
workqueue: Break up enum definitions and give names to the types
workqueue is collecting different sorts of enums into a single unnamed enum type which can increase confusion around enum width. Also, unnamed enums can't be accessed from BPF. Let's break up enum definitions according to their purposes and give them type names. Signed-off-by: Tejun Heo <tj@kernel.org>
1 parent 6a229b0 commit e563d0a

2 files changed

Lines changed: 29 additions & 18 deletions

File tree

include/linux/workqueue.h

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
#define work_data_bits(work) ((unsigned long *)(&(work)->data))
2424

25-
enum {
25+
enum work_bits {
2626
WORK_STRUCT_PENDING_BIT = 0, /* work item is pending execution */
2727
WORK_STRUCT_INACTIVE_BIT= 1, /* work item is inactive */
2828
WORK_STRUCT_PWQ_BIT = 2, /* data points to pwq */
@@ -36,21 +36,6 @@ enum {
3636

3737
WORK_STRUCT_COLOR_BITS = 4,
3838

39-
WORK_STRUCT_PENDING = 1 << WORK_STRUCT_PENDING_BIT,
40-
WORK_STRUCT_INACTIVE = 1 << WORK_STRUCT_INACTIVE_BIT,
41-
WORK_STRUCT_PWQ = 1 << WORK_STRUCT_PWQ_BIT,
42-
WORK_STRUCT_LINKED = 1 << WORK_STRUCT_LINKED_BIT,
43-
#ifdef CONFIG_DEBUG_OBJECTS_WORK
44-
WORK_STRUCT_STATIC = 1 << WORK_STRUCT_STATIC_BIT,
45-
#else
46-
WORK_STRUCT_STATIC = 0,
47-
#endif
48-
49-
WORK_NR_COLORS = (1 << WORK_STRUCT_COLOR_BITS),
50-
51-
/* not bound to any CPU, prefer the local CPU */
52-
WORK_CPU_UNBOUND = NR_CPUS,
53-
5439
/*
5540
* Reserve 8 bits off of pwq pointer w/ debugobjects turned off.
5641
* This makes pwqs aligned to 256 bytes and allows 16 workqueue
@@ -74,6 +59,26 @@ enum {
7459
WORK_OFFQ_LEFT = BITS_PER_LONG - WORK_OFFQ_POOL_SHIFT,
7560
WORK_OFFQ_POOL_BITS = WORK_OFFQ_LEFT <= 31 ? WORK_OFFQ_LEFT : 31,
7661

62+
};
63+
64+
enum work_flags {
65+
WORK_STRUCT_PENDING = 1 << WORK_STRUCT_PENDING_BIT,
66+
WORK_STRUCT_INACTIVE = 1 << WORK_STRUCT_INACTIVE_BIT,
67+
WORK_STRUCT_PWQ = 1 << WORK_STRUCT_PWQ_BIT,
68+
WORK_STRUCT_LINKED = 1 << WORK_STRUCT_LINKED_BIT,
69+
#ifdef CONFIG_DEBUG_OBJECTS_WORK
70+
WORK_STRUCT_STATIC = 1 << WORK_STRUCT_STATIC_BIT,
71+
#else
72+
WORK_STRUCT_STATIC = 0,
73+
#endif
74+
};
75+
76+
enum wq_misc_consts {
77+
WORK_NR_COLORS = (1 << WORK_STRUCT_COLOR_BITS),
78+
79+
/* not bound to any CPU, prefer the local CPU */
80+
WORK_CPU_UNBOUND = NR_CPUS,
81+
7782
/* bit mask for work_busy() return values */
7883
WORK_BUSY_PENDING = 1 << 0,
7984
WORK_BUSY_RUNNING = 1 << 1,
@@ -347,7 +352,7 @@ static inline unsigned int work_static(struct work_struct *work) { return 0; }
347352
* Workqueue flags and constants. For details, please refer to
348353
* Documentation/core-api/workqueue.rst.
349354
*/
350-
enum {
355+
enum wq_flags {
351356
WQ_UNBOUND = 1 << 1, /* not bound to any cpu */
352357
WQ_FREEZABLE = 1 << 2, /* freeze during suspend */
353358
WQ_MEM_RECLAIM = 1 << 3, /* may be used for memory reclaim */
@@ -387,7 +392,9 @@ enum {
387392
__WQ_ORDERED = 1 << 17, /* internal: workqueue is ordered */
388393
__WQ_LEGACY = 1 << 18, /* internal: create*_workqueue() */
389394
__WQ_ORDERED_EXPLICIT = 1 << 19, /* internal: alloc_ordered_workqueue() */
395+
};
390396

397+
enum wq_consts {
391398
WQ_MAX_ACTIVE = 512, /* I like 512, better ideas? */
392399
WQ_UNBOUND_MAX_ACTIVE = WQ_MAX_ACTIVE,
393400
WQ_DFL_ACTIVE = WQ_MAX_ACTIVE / 2,

kernel/workqueue.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656

5757
#include "workqueue_internal.h"
5858

59-
enum {
59+
enum worker_pool_flags {
6060
/*
6161
* worker_pool flags
6262
*
@@ -75,7 +75,9 @@ enum {
7575
*/
7676
POOL_MANAGER_ACTIVE = 1 << 0, /* being managed */
7777
POOL_DISASSOCIATED = 1 << 2, /* cpu can't serve workers */
78+
};
7879

80+
enum worker_flags {
7981
/* worker flags */
8082
WORKER_DIE = 1 << 1, /* die die die */
8183
WORKER_IDLE = 1 << 2, /* is idle */
@@ -86,7 +88,9 @@ enum {
8688

8789
WORKER_NOT_RUNNING = WORKER_PREP | WORKER_CPU_INTENSIVE |
8890
WORKER_UNBOUND | WORKER_REBOUND,
91+
};
8992

93+
enum wq_internal_consts {
9094
NR_STD_WORKER_POOLS = 2, /* # standard pools per cpu */
9195

9296
UNBOUND_POOL_HASH_ORDER = 6, /* hashed by pool->attrs */

0 commit comments

Comments
 (0)