hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/include/linux/workqueue.h
....@@ -63,7 +63,7 @@
6363 WORK_CPU_UNBOUND = NR_CPUS,
6464
6565 /*
66
- * Reserve 7 bits off of pwq pointer w/ debugobjects turned off.
66
+ * Reserve 8 bits off of pwq pointer w/ debugobjects turned off.
6767 * This makes pwqs aligned to 256 bytes and allows 15 workqueue
6868 * flush colors.
6969 */
....@@ -74,7 +74,6 @@
7474 WORK_OFFQ_FLAG_BASE = WORK_STRUCT_COLOR_SHIFT,
7575
7676 __WORK_OFFQ_CANCELING = WORK_OFFQ_FLAG_BASE,
77
- WORK_OFFQ_CANCELING = (1 << __WORK_OFFQ_CANCELING),
7877
7978 /*
8079 * When a work item is off queue, its high bits point to the last
....@@ -85,12 +84,6 @@
8584 WORK_OFFQ_POOL_SHIFT = WORK_OFFQ_FLAG_BASE + WORK_OFFQ_FLAG_BITS,
8685 WORK_OFFQ_LEFT = BITS_PER_LONG - WORK_OFFQ_POOL_SHIFT,
8786 WORK_OFFQ_POOL_BITS = WORK_OFFQ_LEFT <= 31 ? WORK_OFFQ_LEFT : 31,
88
- WORK_OFFQ_POOL_NONE = (1LU << WORK_OFFQ_POOL_BITS) - 1,
89
-
90
- /* convenience constants */
91
- WORK_STRUCT_FLAG_MASK = (1UL << WORK_STRUCT_FLAG_BITS) - 1,
92
- WORK_STRUCT_WQ_DATA_MASK = ~WORK_STRUCT_FLAG_MASK,
93
- WORK_STRUCT_NO_POOL = (unsigned long)WORK_OFFQ_POOL_NONE << WORK_OFFQ_POOL_SHIFT,
9487
9588 /* bit mask for work_busy() return values */
9689 WORK_BUSY_PENDING = 1 << 0,
....@@ -99,6 +92,14 @@
9992 /* maximum string length for set_worker_desc() */
10093 WORKER_DESC_LEN = 24,
10194 };
95
+
96
+/* Convenience constants - of type 'unsigned long', not 'enum'! */
97
+#define WORK_OFFQ_CANCELING (1ul << __WORK_OFFQ_CANCELING)
98
+#define WORK_OFFQ_POOL_NONE ((1ul << WORK_OFFQ_POOL_BITS) - 1)
99
+#define WORK_STRUCT_NO_POOL (WORK_OFFQ_POOL_NONE << WORK_OFFQ_POOL_SHIFT)
100
+
101
+#define WORK_STRUCT_FLAG_MASK ((1ul << WORK_STRUCT_FLAG_BITS) - 1)
102
+#define WORK_STRUCT_WQ_DATA_MASK (~WORK_STRUCT_FLAG_MASK)
102103
103104 struct work_struct {
104105 atomic_long_t data;
....@@ -396,43 +397,23 @@
396397 extern struct workqueue_struct *system_power_efficient_wq;
397398 extern struct workqueue_struct *system_freezable_power_efficient_wq;
398399
399
-extern struct workqueue_struct *
400
-__alloc_workqueue_key(const char *fmt, unsigned int flags, int max_active,
401
- struct lock_class_key *key, const char *lock_name, ...) __printf(1, 6);
402
-
403400 /**
404401 * alloc_workqueue - allocate a workqueue
405402 * @fmt: printf format for the name of the workqueue
406403 * @flags: WQ_* flags
407404 * @max_active: max in-flight work items, 0 for default
408
- * @args...: args for @fmt
405
+ * remaining args: args for @fmt
409406 *
410407 * Allocate a workqueue with the specified parameters. For detailed
411408 * information on WQ_* flags, please refer to
412409 * Documentation/core-api/workqueue.rst.
413410 *
414
- * The __lock_name macro dance is to guarantee that single lock_class_key
415
- * doesn't end up with different namesm, which isn't allowed by lockdep.
416
- *
417411 * RETURNS:
418412 * Pointer to the allocated workqueue on success, %NULL on failure.
419413 */
420
-#ifdef CONFIG_LOCKDEP
421
-#define alloc_workqueue(fmt, flags, max_active, args...) \
422
-({ \
423
- static struct lock_class_key __key; \
424
- const char *__lock_name; \
425
- \
426
- __lock_name = "(wq_completion)"#fmt#args; \
427
- \
428
- __alloc_workqueue_key((fmt), (flags), (max_active), \
429
- &__key, __lock_name, ##args); \
430
-})
431
-#else
432
-#define alloc_workqueue(fmt, flags, max_active, args...) \
433
- __alloc_workqueue_key((fmt), (flags), (max_active), \
434
- NULL, NULL, ##args)
435
-#endif
414
+struct workqueue_struct *alloc_workqueue(const char *fmt,
415
+ unsigned int flags,
416
+ int max_active, ...);
436417
437418 /**
438419 * alloc_ordered_workqueue - allocate an ordered workqueue
....@@ -461,7 +442,7 @@
461442
462443 extern void destroy_workqueue(struct workqueue_struct *wq);
463444
464
-struct workqueue_attrs *alloc_workqueue_attrs(gfp_t gfp_mask);
445
+struct workqueue_attrs *alloc_workqueue_attrs(void);
465446 void free_workqueue_attrs(struct workqueue_attrs *attrs);
466447 int apply_workqueue_attrs(struct workqueue_struct *wq,
467448 const struct workqueue_attrs *attrs);
....@@ -469,6 +450,8 @@
469450
470451 extern bool queue_work_on(int cpu, struct workqueue_struct *wq,
471452 struct work_struct *work);
453
+extern bool queue_work_node(int node, struct workqueue_struct *wq,
454
+ struct work_struct *work);
472455 extern bool queue_delayed_work_on(int cpu, struct workqueue_struct *wq,
473456 struct delayed_work *work, unsigned long delay);
474457 extern bool mod_delayed_work_on(int cpu, struct workqueue_struct *wq,
....@@ -511,6 +494,19 @@
511494 *
512495 * We queue the work to the CPU on which it was submitted, but if the CPU dies
513496 * it can be processed by another CPU.
497
+ *
498
+ * Memory-ordering properties: If it returns %true, guarantees that all stores
499
+ * preceding the call to queue_work() in the program order will be visible from
500
+ * the CPU which will execute @work by the time such work executes, e.g.,
501
+ *
502
+ * { x is initially 0 }
503
+ *
504
+ * CPU0 CPU1
505
+ *
506
+ * WRITE_ONCE(x, 1); [ @work is being executed ]
507
+ * r0 = queue_work(wq, work); r1 = READ_ONCE(x);
508
+ *
509
+ * Forbids: r0 == true && r1 == 0
514510 */
515511 static inline bool queue_work(struct workqueue_struct *wq,
516512 struct work_struct *work)
....@@ -570,6 +566,9 @@
570566 * This puts a job in the kernel-global workqueue if it was not already
571567 * queued and leaves it in the same position on the kernel-global
572568 * workqueue otherwise.
569
+ *
570
+ * Shares the same memory-ordering properties of queue_work(), cf. the
571
+ * DocBook header of queue_work().
573572 */
574573 static inline bool schedule_work(struct work_struct *work)
575574 {
....@@ -673,7 +672,7 @@
673672 int workqueue_offline_cpu(unsigned int cpu);
674673 #endif
675674
676
-int __init workqueue_init_early(void);
677
-int __init workqueue_init(void);
675
+void __init workqueue_init_early(void);
676
+void __init workqueue_init(void);
678677
679678 #endif