From: Audra Mitchell <audra@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: raquini@redhat.com, tj@kernel.org, jiangshanlai@gmail.com
Subject: [PATCH] workqueue.c: Change workqueue to accept variable length name
Date: Fri, 15 Dec 2023 14:39:54 -0500 [thread overview]
Message-ID: <20231215193954.1785069-1-audra@redhat.com> (raw)
Currently we limit the size of the workqueue name to 24 characters due to
commit ecf6881ff349 ("workqueue: make workqueue->name[] fixed len")
As device names increase in size a static size for the workqueue name no
longer satisfies the size requirement, leading to truncated workqueue
names as we append the device name to the workqueue name. Truncation of
the workqueue names can cause issues when debugging as each is unique to
the associated device. Bring back the flexibility of a variable length
workqueue name to prevent truncation.
Signed-off-by: Audra Mitchell <audra@redhat.com>
---
kernel/workqueue.c | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 2989b57e154a..6e9e332d1cf4 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -107,8 +107,6 @@ enum {
*/
RESCUER_NICE_LEVEL = MIN_NICE,
HIGHPRI_NICE_LEVEL = MIN_NICE,
-
- WQ_NAME_LEN = 24,
};
/*
@@ -311,7 +309,7 @@ struct workqueue_struct {
struct lock_class_key key;
struct lockdep_map lockdep_map;
#endif
- char name[WQ_NAME_LEN]; /* I: workqueue name */
+ char *name; /* I: workqueue name */
/*
* Destruction of workqueue_struct is RCU protected to allow walking
@@ -3929,6 +3927,7 @@ static void rcu_free_wq(struct rcu_head *rcu)
wq_free_lockdep(wq);
free_percpu(wq->cpu_pwq);
free_workqueue_attrs(wq->unbound_attrs);
+ kfree(wq->name);
kfree(wq);
}
@@ -4670,9 +4669,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;
+ size_t namelen;
/*
* Unbound && max_active == 1 used to imply ordered, which is no longer
@@ -4699,8 +4699,16 @@ struct workqueue_struct *alloc_workqueue(const char *fmt,
}
va_start(args, max_active);
- vsnprintf(wq->name, sizeof(wq->name), fmt, args);
+ va_copy(args_copy, args);
+ namelen = vsnprintf(NULL, 0, fmt, args) + 1;
+ namelen = (namelen < PAGE_SIZE) ? namelen : PAGE_SIZE;
va_end(args);
+ wq->name = kzalloc(namelen, GFP_KERNEL);
+ if (!wq->name)
+ goto err_free_wq;
+
+ vsnprintf(wq->name, namelen, fmt, args_copy);
+ va_end(args_copy);
max_active = max_active ?: WQ_DFL_ACTIVE;
max_active = wq_clamp_max_active(max_active, flags, wq->name);
@@ -4746,6 +4754,7 @@ struct workqueue_struct *alloc_workqueue(const char *fmt,
return wq;
err_unreg_lockdep:
+ kfree(wq->name);
wq_unregister_lockdep(wq);
wq_free_lockdep(wq);
err_free_wq:
@@ -5038,7 +5047,7 @@ EXPORT_SYMBOL_GPL(set_worker_desc);
void print_worker_info(const char *log_lvl, struct task_struct *task)
{
work_func_t *fn = NULL;
- char name[WQ_NAME_LEN] = { };
+ char *name;
char desc[WORKER_DESC_LEN] = { };
struct pool_workqueue *pwq = NULL;
struct workqueue_struct *wq = NULL;
@@ -5060,7 +5069,7 @@ void print_worker_info(const char *log_lvl, struct task_struct *task)
copy_from_kernel_nofault(&fn, &worker->current_func, sizeof(fn));
copy_from_kernel_nofault(&pwq, &worker->current_pwq, sizeof(pwq));
copy_from_kernel_nofault(&wq, &pwq->wq, sizeof(wq));
- copy_from_kernel_nofault(name, wq->name, sizeof(name) - 1);
+ copy_from_kernel_nofault(&name, &wq->name, sizeof(wq->name));
copy_from_kernel_nofault(desc, worker->desc, sizeof(desc) - 1);
if (fn || name[0] || desc[0]) {
--
2.43.0
next reply other threads:[~2023-12-15 19:40 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-15 19:39 Audra Mitchell [this message]
2023-12-21 21:39 ` [PATCH] workqueue.c: Change workqueue to accept variable length name Tejun Heo
[not found] ` <CA+bDH-v6T5vvyOwsphseHwgihdGQta7TZ9tOtt-Fnij92kvU6A@mail.gmail.com>
2023-12-22 17:53 ` Tejun Heo
2024-01-09 13:29 ` Audra Mitchell
2024-01-10 20:29 ` [PATCH v2] workqueue.c: Increase workqueue name length Audra Mitchell
2024-01-10 20:47 ` Rasmus Villemoes
2024-01-10 21:52 ` Rafael Aquini
2024-01-10 22:06 ` Rasmus Villemoes
2024-01-10 22:31 ` Rafael Aquini
2024-01-10 22:45 ` Rafael Aquini
2024-01-10 22:58 ` Rasmus Villemoes
2024-01-10 22:52 ` Rasmus Villemoes
2024-01-10 23:08 ` Rafael Aquini
2024-01-15 17:08 ` [PATCH v3] " Audra Mitchell
2024-01-16 18:31 ` Tejun Heo
2024-01-17 14:40 ` Audra Mitchell
2024-01-17 17:09 ` Tejun Heo
2024-01-19 20:30 ` Audra Mitchell
2024-01-19 23:44 ` Tejun Heo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231215193954.1785069-1-audra@redhat.com \
--to=audra@redhat.com \
--cc=jiangshanlai@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=raquini@redhat.com \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).