mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-26 14:17:26 -04:00
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. Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lore.kernel.org/r/20211203075935.136808-2-wangkefeng.wang@huawei.com
This commit is contained in:
parent
9a75bd0c52
commit
c0bed69daf
4 changed files with 13 additions and 21 deletions
|
@ -2171,6 +2171,15 @@ extern long sched_getaffinity(pid_t pid, struct cpumask *mask);
|
|||
#endif
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
static inline bool owner_on_cpu(struct task_struct *owner)
|
||||
{
|
||||
/*
|
||||
* As lock holder preemption issue, we both skip spinning if
|
||||
* task is not on cpu or its cpu is preempted
|
||||
*/
|
||||
return owner->on_cpu && !vcpu_is_preempted(task_cpu(owner));
|
||||
}
|
||||
|
||||
/* Returns effective CPU energy utilization, as seen by the scheduler */
|
||||
unsigned long sched_cpu_util(int cpu, unsigned long max);
|
||||
#endif /* CONFIG_SMP */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue