[PATCH 01/53] workqueue: Introduce the create*_workqueue2() macros

From: Bart Van Assche
Date: Sun Jun 30 2024 - 18:29:51 EST


A common pattern in the Linux kernel is that sprintf(), snprintf() or
kasprintf() is used to format the workqueue name that is passed to
create_workqueue(), create_freezable_workqueue() or
create_singlethread_workqueue(). Prepare for simplifying such code by
introducing the create*_workqueue2() macros that accept a printf-style
format string and argument list. A later patch will remove the
create*_workqueue() macros and will rename the create*_workqueue2()
macros into create*_workqueue().

Signed-off-by: Bart Van Assche <bvanassche@xxxxxxx>
---
include/linux/workqueue.h | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
index d9968bfc8eac..762aaedaba56 100644
--- a/include/linux/workqueue.h
+++ b/include/linux/workqueue.h
@@ -525,11 +525,20 @@ alloc_workqueue(const char *fmt, unsigned int flags, int max_active, ...);

#define create_workqueue(name) \
alloc_workqueue("%s", __WQ_LEGACY | WQ_MEM_RECLAIM, 1, (name))
+#define create_workqueue2(fmt, args...) \
+ alloc_workqueue(fmt, __WQ_LEGACY | WQ_MEM_RECLAIM, 1, ##args)
#define create_freezable_workqueue(name) \
alloc_workqueue("%s", __WQ_LEGACY | WQ_FREEZABLE | WQ_UNBOUND | \
WQ_MEM_RECLAIM, 1, (name))
+#define create_freezable_workqueue2(fmt, args...) \
+ alloc_workqueue( \
+ fmt, __WQ_LEGACY | WQ_FREEZABLE | WQ_UNBOUND | WQ_MEM_RECLAIM, \
+ 1, ##args)
#define create_singlethread_workqueue(name) \
alloc_ordered_workqueue("%s", __WQ_LEGACY | WQ_MEM_RECLAIM, name)
+#define create_singlethread_workqueue2(fmt, args...) \
+ alloc_ordered_workqueue(fmt, __WQ_LEGACY | WQ_MEM_RECLAIM, ##args)
+

#define from_work(var, callback_work, work_fieldname) \
container_of(callback_work, typeof(*var), work_fieldname)