History

locking: Make owner_on_cpu() into <linux/sched.h>

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.

Kefeng Wang committed 4 years ago

Commit c0bed691 parent 9a75bd04 files · +13 −21Browse files

Showing the changes to include (1 of 4 files). Show all

Unified · Split

include/linux/sched.h+9−0
@@ -2171,6 +2171,15 @@ extern long sched_getaffinity(pid_t pid, struct cpumask *mask); · 2170 unmodified lines
21712171 #endif
21722172
21732173 #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+
21742183 /* Returns effective CPU energy utilization, as seen by the scheduler */
21752184 unsigned long sched_cpu_util(int cpu, unsigned long max);
21762185 #endif /* CONFIG_SMP */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t