From: Bradley Morgan <brads@mainlining.org>
To: quchaosheng000406@163.com
Cc: linux-kernel@vger.kernel.org,
syzbot+37ca7ae3e98cb65c3209@syzkaller.appspotmail.com
Subject: Re: [PATCH] kthread: Report cpumask allocation failure without warning
Date: Wed, 16 Sep 2026 17:40:07 +0100 [thread overview]
Message-ID: <B6BD0B30-6E75-49ED-A13D-33FED28AD032@mainlining.org> (raw)
In-Reply-To: <20260916015948.113062-1-quchaosheng000406@163.com>
On 16 September 2026 02:59:48 BST, Quchaosheng <quchaosheng000406@163.com>
wrote:
>kthread_affine_node() warns when zalloc_cpumask_var() fails:
>
> if (!zalloc_cpumask_var(&affinity, GFP_KERNEL)) {
> WARN_ON_ONCE(1);
> return;
> }
>
>The allocation uses GFP_KERNEL, so it can fail under memory pressure or
>fault injection. A failed allocation is a recoverable condition and not a
>kernel bug, so the warning is noise. syzbot reports it for a WireGuard
>NAPI thread:
>
> WARNING: kernel/kthread.c:359 at kthread_affine_node+0x200/0x2e8
> CPU: 0 PID: 5207 Comm: napi/wg2-0
> Call Trace:
> alloc_cpumask_var_node+0xfc/0x138
> zalloc_cpumask_var
> kthread_affine_node+0x148/0x2e8
> kthread+0x29c/0x3d4
> ret_from_fork+0x10/0x20
>
>The failure is not silent though: the early return also skips
>list_add_tail() of kthread::affinity_node, so the thread never joins
>kthread_affinity_list and kthreads_online_cpu() will not fix up its
>affinity on a later CPU hotplug. Keep the failure visible with
>pr_warn_once() instead of dropping the message.
I swear there was a patch for this I kinda NAKed.
>
>Reported-by: syzbot+37ca7ae3e98cb65c3209@syzkaller.appspotmail.com
>Closes: https://syzkaller.appspot.com/bug?extid=37ca7ae3e98cb65c3209
>Signed-off-by: Quchaosheng <quchaosheng000406@163.com>
>---
> kernel/kthread.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
>diff --git a/kernel/kthread.c b/kernel/kthread.c
>index a3f95c904..b59fa7c7e 100644
>--- a/kernel/kthread.c
>+++ b/kernel/kthread.c
>@@ -356,7 +356,14 @@ static void kthread_affine_node(void)
> return;
>
> if (!zalloc_cpumask_var(&affinity, GFP_KERNEL)) {
>- WARN_ON_ONCE(1);
>+ /*
>+ * The thread stays out of kthread_affinity_list, so a later
>+ * CPU hotplug will not fix up its affinity. Report it, but do
>+ * not warn: the allocation can fail under memory pressure or
>+ * fault injection, and that is not a kernel bug.
>+ */
For the comment length, I have to ask did you use AI to develop this?
>+ pr_warn_once("kthread: %s: no cpumask, node affinity not set\n",
>+ current->comm);
Ummmmmm. I mean, okay then? But what effect does this make? (Except from
the message).
Under memory pressure I presume
1: your memory needs replacing, you get what you get
2: you did this on purpose, you deserve whatever you get.
And under fault injection is just a test.
I really think this code is sane as is,
NAK.
> return;
> }
>
>
--- Thanks!
https://lore.kernel.org/all/EE579805-42F2-4C58-B752-F28779EEB717@grrlz.net/
next prev parent reply other threads:[~2026-09-16 16:40 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-14 12:09 [PATCH 2/2] kthread: Drop warning on cpumask allocation failure in kthread_affine_node() Quchaosheng
2026-09-14 16:52 ` Bradley Morgan
2026-09-14 17:04 ` Waiman Long
2026-09-15 10:45 ` Frederic Weisbecker
2026-09-16 1:59 ` [PATCH] kthread: Report cpumask allocation failure without warning Quchaosheng
2026-09-16 16:40 ` Bradley Morgan [this message]
2026-09-17 5:15 ` Quchaosheng
2026-09-16 8:10 ` [PATCH 2/2] kthread: Drop warning on cpumask allocation failure in kthread_affine_node() Quchaosheng
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=B6BD0B30-6E75-49ED-A13D-33FED28AD032@mainlining.org \
--to=brads@mainlining.org \
--cc=linux-kernel@vger.kernel.org \
--cc=quchaosheng000406@163.com \
--cc=syzbot+37ca7ae3e98cb65c3209@syzkaller.appspotmail.com \
/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
all inboxes | Powered by JetHome®