From: Rafael Aquini <aquini@redhat.com>
To: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Cc: Audra Mitchell <audra@redhat.com>,
linux-kernel@vger.kernel.org, tj@kernel.org,
jiangshanlai@gmail.com, hirokazu.yamauchi.hk@hitachi.com,
ddouwsma@redhat.com, loberman@redhat.com, raquini@redhat.com
Subject: Re: [PATCH v2] workqueue.c: Increase workqueue name length
Date: Wed, 10 Jan 2024 16:52:53 -0500 [thread overview]
Message-ID: <ZZ8RtfKCmOQqj5KC@optiplex-fbsd> (raw)
In-Reply-To: <2f0efed5-f9f3-4a5c-9fd4-a4837cada298@prevas.dk>
On Wed, Jan 10, 2024 at 09:47:56PM +0100, Rasmus Villemoes wrote:
> On 10/01/2024 21.29, Audra Mitchell wrote:
>
> > @@ -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);
>
> Eh, why not just _not_ throw away the return value from the existing
> vsnprintf() and do "len >= sizeof(wq->name)" to know if truncation
> happened? There's really no need need to do vsnprintf() twice. (And yes,
> you want >=, not >).
>
The extra vsnprintf call is required because the return of the existing
vsnprintf() is going to be already capped by sizeof(wq->name).
> Oh, and definitely not WARN, pr_warn() or pr_warn_once() please.
>
Then you lose the ability to figure out what was trying to create the
wq with the inflated name. Also, the _once variants don't seem to do
good here, because alloc_workqueue() can be called by different
drivers.
-- Rafael
next prev parent reply other threads:[~2024-01-10 21:52 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-15 19:39 [PATCH] workqueue.c: Change workqueue to accept variable length name Audra Mitchell
2023-12-21 21:39 ` 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 [this message]
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=ZZ8RtfKCmOQqj5KC@optiplex-fbsd \
--to=aquini@redhat.com \
--cc=audra@redhat.com \
--cc=ddouwsma@redhat.com \
--cc=hirokazu.yamauchi.hk@hitachi.com \
--cc=jiangshanlai@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=loberman@redhat.com \
--cc=raquini@redhat.com \
--cc=rasmus.villemoes@prevas.dk \
--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 read-only IMAP folder(s) and NNTP newsgroup(s).