mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Frederic Weisbecker <frederic@kernel.org>
To: Waiman Long <longman@redhat.com>
Cc: Quchaosheng <quchaosheng000406@163.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>, Will Deacon <will@kernel.org>,
	Boqun Feng <boqun@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] kthread: Drop warning on cpumask allocation failure in kthread_affine_node()
Date: Tue, 15 Sep 2026 12:45:03 +0200	[thread overview]
Message-ID: <aqkhrxXXIm43mqfs@localhost.localdomain> (raw)
In-Reply-To: <deab3ef5-e63f-474f-9a1b-fb4f4b65be2a@redhat.com>

Le Mon, Sep 14, 2026 at 01:04:22PM -0400, Waiman Long a écrit :
> cc: Frederic Weisbecker <frederic@kernel.org> for his input.
> 
> -Longman
> 
> On 9/14/26 8:09 AM, Quchaosheng 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 other two callers of zalloc_cpumask_var() in this file, in the kthread
> > preferred affinity and kthreads_online_cpu() paths, return -ENOMEM without
> > a warning.  kthread_affine_node() returns void, so it cannot report the
> > error either, and it only skips the affinity setup for this thread.  Return
> > early without warning, matching those callers.

Unfortunately there is no way to handle that correctly. It's the thread main
function and making it return early without executing the associated callback
doesn't sound like a better idea over what we do now.

A warning is the only way at this stage to tell that the affinity of the kthread
will be mishandled.

Thanks.

-- 
Frederic Weisbecker
SUSE Labs

  reply	other threads:[~2026-09-15 10:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-14 12:09 Quchaosheng
2026-09-14 16:52 ` Bradley Morgan
2026-09-14 17:04 ` Waiman Long
2026-09-15 10:45   ` Frederic Weisbecker [this message]
2026-09-16  1:59     ` [PATCH] kthread: Report cpumask allocation failure without warning Quchaosheng
2026-09-16 16:40       ` Bradley Morgan
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
  -- strict thread matches above, loose matches on Subject: below --
2026-09-14 12:09 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=aqkhrxXXIm43mqfs@localhost.localdomain \
    --to=frederic@kernel.org \
    --cc=boqun@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=quchaosheng000406@163.com \
    --cc=will@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

all inboxes | Powered by JetHome®