Fix a bug where dynamic CPU isolation through cpuset isolated partitions

can move a kthread out of the housekeeping range. For example in a
 system with 3 CPUs:
 
 _ kthread K has preferred affinity to CPUs 1 et 2 and is affine to them
 _ CPU 1 goes offline
 _ An isolated cpuset partition is created on CPU 2 (so the only
   remaining online housekeeper is CPU 0)
 _ K is affine to CPU 2 but this CPU is offline so it fails and goes back
   to its previous affinity where only CPU 3 is online. Yet it is
   isolated.
 
 The fix makes sure the fallback affinity is always a set of online
 housekeeper.
 -----BEGIN PGP SIGNATURE-----
 
 iQJPBAABCAA5FiEEd76+gtGM8MbftQlOhSRUR1COjHcFAmreV2gbFIAAAAAABAAO
 bWFudTIsMi41KzEuMTIsMiwyAAoJEIUkVEdQjox3CkEQAJNNA0cH5PCT7JmqtRT2
 VgBMw2o6Xw7JSHB2dYirrVaBmTDUgzsN2UlrNVw8Q1+3BsxXvLeOs/oqKBxkCsod
 GwhmTBK3/i8WlEf8+1CkQD3sv/rZu62IVLtTpL+/89mO0soWewCEWXEoc0LrNhJW
 KZC/gHTlRbrn2b54DZFCiVSGl8ET2IFWm3ds8/k/kvTsNji9cOBoFJsANcM8j0JN
 PV5JZmfjPSEW7pZGP9ri+wIfWnjBxw9ylABEbDbHJXF3Lg94todIlkfFT3hWyTGI
 NyRkjpGxP/fXOTdPugYCH4mz1TpsODr9UiyUrNURKSsTTCIoWr4JL2p3yPv9sZ6c
 PuSFK6Mer19Z3NPb+8wLbe+WOUPT6lOMq2WRpJCoG72Ma3BCGcIjXNzU6oxMCplp
 m3AgZ/I/lAMv+OdeVeYZrvqSTv80ya6T6TZ87qwhbUVbV6s4KvgQxhZKSdvviHV3
 ol9TUf/SWYn2wanNKAGN67fwuclFM0owk3ywLxdF1oO+LkelCutdNcAyk0bZ7y1F
 37uKMVp/GgBkyOSG7LyDIh8NmwXTCkWopTBs1vcBjXZla0sPa5bUcQ21hTHJYj0N
 4lQ/W3gixJJSI+qctsuX+E+oyRQam3IBVS7TLtkh0u/AoY69dU6XtSBF9P2RItFn
 JzRUBzeHhDA+eZ3wrw4FQQKw
 =rlAK
 -----END PGP SIGNATURE-----

Merge tag 'kthread-fix-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/frederic/linux-dynticks

Pull kthread fix from Frederic Weisbecker:
 "Fix a bug where dynamic CPU isolation through cpuset isolated
  partitions can move a kthread out of the housekeeping range.

  The fix makes sure the fallback affinity is always a set of online
  housekeeper"

* tag 'kthread-fix-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/frederic/linux-dynticks:
  kthread: Fall back when no preferred housekeeping CPU is online
This commit is contained in:
Linus Torvalds 2026-10-29 07:49:07 -10:00
commit d011f648a7

View File

@ -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));
}