@@ -1902,12 +1902,28 @@ int freeze_secondary_cpus(int primary)
1902
1902
1903
1903
cpu_maps_update_begin ();
1904
1904
if (primary == -1 ) {
1905
- primary = cpumask_first (cpu_online_mask );
1906
- if (!housekeeping_cpu (primary , HK_TYPE_TIMER ))
1907
- primary = housekeeping_any_cpu (HK_TYPE_TIMER );
1905
+ primary = cpumask_first_and_and (cpu_online_mask ,
1906
+ housekeeping_cpumask (HK_TYPE_TIMER ),
1907
+ housekeeping_cpumask (HK_TYPE_DOMAIN ));
1908
+ if (primary >= nr_cpu_ids ) {
1909
+ error = - ENODEV ;
1910
+ pr_err ("No suitable primary CPU found. Ensure at least one non-isolated, non-nohz_full CPU is online\n" );
1911
+ goto abort ;
1912
+ }
1908
1913
} else {
1909
- if (!cpu_online (primary ))
1910
- primary = cpumask_first (cpu_online_mask );
1914
+ if (!cpu_online (primary )) {
1915
+ primary = cpumask_first_and (cpu_online_mask ,
1916
+ housekeeping_cpumask (HK_TYPE_DOMAIN ));
1917
+ if (primary >= nr_cpu_ids ) {
1918
+ error = - ENODEV ;
1919
+ pr_err ("No suitable primary CPU found. Ensure at least one non-isolated CPU is online\n" );
1920
+ goto abort ;
1921
+ }
1922
+ } else if (!housekeeping_cpu (primary , HK_TYPE_DOMAIN )) {
1923
+ error = - ENODEV ;
1924
+ pr_err ("Primary CPU %d should not be isolated\n" , primary );
1925
+ goto abort ;
1926
+ }
1911
1927
}
1912
1928
1913
1929
/*
@@ -1943,6 +1959,7 @@ int freeze_secondary_cpus(int primary)
1943
1959
else
1944
1960
pr_err ("Non-boot CPUs are not disabled\n" );
1945
1961
1962
+ abort :
1946
1963
/*
1947
1964
* Make sure the CPUs won't be enabled by someone else. We need to do
1948
1965
* this even in case of failure as all freeze_secondary_cpus() users are
0 commit comments