Re: [PATCH 2/2] kthread: Drop warning on cpumask allocation failure in kthread_affine_node()

From: Quchaosheng

Date: Wed Sep 16 2026 - 04:17:55 EST


Hi Frederic,

Thanks for looking at this.

The posting you are responding to is v1, which dropped the message entirely.
That one was wrong and I have not resent it. v2 replaced WARN_ON_ONCE(1) with
pr_warn_once(), so the thread still reports the condition:

if (!zalloc_cpumask_var(&affinity, GFP_KERNEL)) {
pr_warn_once("kthread: %s: no cpumask, node affinity not set\n",
current->comm);
return;
}

One correction to the v1 description, though, because I think it changes the
picture: kthread_affine_node() is not the thread main function. It is called
from kthread() before threadfn(), and returning from it only skips the affinity
setup for this thread -- threadfn(data) is still run either way, so no callback
is skipped. The early return is also not something the patch adds; it is already
there in the current code, above the warning. The patch only changes how the
failure is reported.

The reason I would like to keep it visible in some form is the point you make:
the thread does not join kthread_affinity_list, so a later CPU hotplug will not
fix up its affinity, and that state is worth telling someone about.

That said, if your position is that WARN_ON_ONCE(1) is the right severity and
pr_warn_once() would let it go unnoticed, just say so and I will drop the patch.
I would rather not push something you have already said no to.

Thanks,
Quchaosheng