@@ -1612,6 +1612,7 @@ static int run_osnoise(void)
1612
1612
1613
1613
static struct cpumask osnoise_cpumask ;
1614
1614
static struct cpumask save_cpumask ;
1615
+ static struct cpumask kthread_cpumask ;
1615
1616
1616
1617
/*
1617
1618
* osnoise_sleep - sleep until the next period
@@ -1675,6 +1676,7 @@ static inline int osnoise_migration_pending(void)
1675
1676
*/
1676
1677
mutex_lock (& interface_lock );
1677
1678
this_cpu_osn_var ()-> kthread = NULL ;
1679
+ cpumask_clear_cpu (smp_processor_id (), & kthread_cpumask );
1678
1680
mutex_unlock (& interface_lock );
1679
1681
1680
1682
return 1 ;
@@ -1947,9 +1949,10 @@ static void stop_kthread(unsigned int cpu)
1947
1949
1948
1950
kthread = per_cpu (per_cpu_osnoise_var , cpu ).kthread ;
1949
1951
if (kthread ) {
1950
- if (test_bit (OSN_WORKLOAD , & osnoise_options )) {
1952
+ if (cpumask_test_and_clear_cpu (cpu , & kthread_cpumask ) &&
1953
+ !WARN_ON (!test_bit (OSN_WORKLOAD , & osnoise_options ))) {
1951
1954
kthread_stop (kthread );
1952
- } else {
1955
+ } else if (! WARN_ON ( test_bit ( OSN_WORKLOAD , & osnoise_options ))) {
1953
1956
/*
1954
1957
* This is a user thread waiting on the timerlat_fd. We need
1955
1958
* to close all users, and the best way to guarantee this is
@@ -2021,6 +2024,7 @@ static int start_kthread(unsigned int cpu)
2021
2024
}
2022
2025
2023
2026
per_cpu (per_cpu_osnoise_var , cpu ).kthread = kthread ;
2027
+ cpumask_set_cpu (cpu , & kthread_cpumask );
2024
2028
2025
2029
return 0 ;
2026
2030
}
@@ -2048,8 +2052,16 @@ static int start_per_cpu_kthreads(void)
2048
2052
*/
2049
2053
cpumask_and (current_mask , cpu_online_mask , & osnoise_cpumask );
2050
2054
2051
- for_each_possible_cpu (cpu )
2055
+ for_each_possible_cpu (cpu ) {
2056
+ if (cpumask_test_and_clear_cpu (cpu , & kthread_cpumask )) {
2057
+ struct task_struct * kthread ;
2058
+
2059
+ kthread = per_cpu (per_cpu_osnoise_var , cpu ).kthread ;
2060
+ if (!WARN_ON (!kthread ))
2061
+ kthread_stop (kthread );
2062
+ }
2052
2063
per_cpu (per_cpu_osnoise_var , cpu ).kthread = NULL ;
2064
+ }
2053
2065
2054
2066
for_each_cpu (cpu , current_mask ) {
2055
2067
retval = start_kthread (cpu );
0 commit comments