From 78ff77ded78f2d3d6040705a3ab5a83cc45275e3 Mon Sep 17 00:00:00 2001 From: Avi Weiss Date: Tue, 20 Oct 2026 15:55:18 +0300 Subject: [PATCH] kthread: Fall back when no preferred housekeeping CPU is online kthread_fetch_affinity() falls back to the housekeeping mask only when the intersection with the preferred mask is empty. If the intersection contains only offline CPUs, set_cpus_allowed_ptr() returns -EINVAL and the kthread keeps its previous affinity, which may still include an isolated CPU. Check whether the intersection contains an online CPU instead. Fall back to the full housekeeping mask when none are online. Fixes: e894f6339808 ("kthread: Honour kthreads preferred affinity after cpuset changes") Signed-off-by: Avi Weiss Reviewed-by: Bradley Morgan Signed-off-by: Frederic Weisbecker --- kernel/kthread.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/kthread.c b/kernel/kthread.c index a3f95c90456b..0dbff3b68ffb 100644 --- a/kernel/kthread.c +++ b/kernel/kthread.c @@ -343,7 +343,7 @@ static void kthread_fetch_affinity(struct kthread *kthread, struct cpumask *cpum } cpumask_and(cpumask, pref, housekeeping_cpumask(HK_TYPE_DOMAIN)); - if (cpumask_empty(cpumask)) + if (!cpumask_intersects(cpumask, cpu_online_mask)) cpumask_copy(cpumask, housekeeping_cpumask(HK_TYPE_DOMAIN)); }