[PATCH v2] workqueue.c: Increase workqueue name length
From: Audra Mitchell
Date: Wed Jan 10 2024 - 15:30:24 EST
Currently we limit the size of the workqueue name to 24 characters due to
commit ecf6881ff349 ("workqueue: make workqueue->name[] fixed len")
Increase the size to 32 characters and print a warning in the event
the requested name is larger than the limit of 32 characters.
Signed-off-by: Audra Mitchell <audra@xxxxxxxxxx>
---
kernel/workqueue.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 76e60faed892..cac3b8895c16 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -108,7 +108,7 @@ enum {
RESCUER_NICE_LEVEL = MIN_NICE,
HIGHPRI_NICE_LEVEL = MIN_NICE,
- WQ_NAME_LEN = 24,
+ WQ_NAME_LEN = 32,
};
/*
@@ -4663,9 +4663,10 @@ struct workqueue_struct *alloc_workqueue(const char *fmt,
unsigned int flags,
int max_active, ...)
{
- va_list args;
+ va_list args, args_copy;
struct workqueue_struct *wq;
struct pool_workqueue *pwq;
+ int len;
/*
* Unbound && max_active == 1 used to imply ordered, which is no longer
@@ -4692,6 +4693,13 @@ struct workqueue_struct *alloc_workqueue(const char *fmt,
}
va_start(args, max_active);
+ va_copy(args_copy, args);
+ len = vsnprintf(NULL, 0, fmt, args_copy);
+ WARN(len > WQ_NAME_LEN,
+ "workqueue: wq->name too long (%d). Truncated to WQ_NAME_LEN (%d)\n",
+ len, WQ_NAME_LEN);
+
+ va_end(args_copy);
vsnprintf(wq->name, sizeof(wq->name), fmt, args);
va_end(args);
--
2.43.0