Move the owner_on_cpu() from kernel/locking/rwsem.c into include/linux/sched.h with under CONFIG_SMP, then use it in the mutex/rwsem/rtmutex to simplify the code.
Showing the changes to include (1 of 4 files). Show all
Unified · Split
| @@ -2171,6 +2171,15 @@ extern long sched_getaffinity(pid_t pid, struct cpumask *mask); · 2170 unmodified lines | |||
| 2171 | #endif | 2171 | #endif |
| 2172 | 2172 | ||
| 2173 | #ifdef CONFIG_SMP | 2173 | #ifdef CONFIG_SMP |
| 2174 | static inline bool owner_on_cpu(struct task_struct *owner) | ||
| 2175 | { | ||
| 2176 | /* | ||
| 2177 | * As lock holder preemption issue, we both skip spinning if | ||
| 2178 | * task is not on cpu or its cpu is preempted | ||
| 2179 | */ | ||
| 2180 | return owner->on_cpu && !vcpu_is_preempted(task_cpu(owner)); | ||
| 2181 | } | ||
| 2182 | |||
| 2174 | /* Returns effective CPU energy utilization, as seen by the scheduler */ | 2183 | /* Returns effective CPU energy utilization, as seen by the scheduler */ |
| 2175 | unsigned long sched_cpu_util(int cpu, unsigned long max); | 2184 | unsigned long sched_cpu_util(int cpu, unsigned long max); |
| 2176 | #endif /* CONFIG_SMP */ | 2185 | #endif /* CONFIG_SMP */ |