hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
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,10 +442,16 @@
461442
462443 extern void destroy_workqueue(struct workqueue_struct *wq);
463444
445
+struct workqueue_attrs *alloc_workqueue_attrs(void);
446
+void free_workqueue_attrs(struct workqueue_attrs *attrs);
447
+int apply_workqueue_attrs(struct workqueue_struct *wq,
448
+ const struct workqueue_attrs *attrs);
464449 int workqueue_set_unbound_cpumask(cpumask_var_t cpumask);
465450
466451 extern bool queue_work_on(int cpu, struct workqueue_struct *wq,
467452 struct work_struct *work);
453
+extern bool queue_work_node(int node, struct workqueue_struct *wq,
454
+ struct work_struct *work);
468455 extern bool queue_delayed_work_on(int cpu, struct workqueue_struct *wq,
469456 struct delayed_work *work, unsigned long delay);
470457 extern bool mod_delayed_work_on(int cpu, struct workqueue_struct *wq,
....@@ -507,6 +494,19 @@
507494 *
508495 * We queue the work to the CPU on which it was submitted, but if the CPU dies
509496 * 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
510510 */
511511 static inline bool queue_work(struct workqueue_struct *wq,
512512 struct work_struct *work)
....@@ -566,6 +566,9 @@
566566 * This puts a job in the kernel-global workqueue if it was not already
567567 * queued and leaves it in the same position on the kernel-global
568568 * workqueue otherwise.
569
+ *
570
+ * Shares the same memory-ordering properties of queue_work(), cf. the
571
+ * DocBook header of queue_work().
569572 */
570573 static inline bool schedule_work(struct work_struct *work)
571574 {
....@@ -669,7 +672,7 @@
669672 int workqueue_offline_cpu(unsigned int cpu);
670673 #endif
671674
672
-int __init workqueue_init_early(void);
673
-int __init workqueue_init(void);
675
+void __init workqueue_init_early(void);
676
+void __init workqueue_init(void);
674677
675678 #endif