sched/core: Provide a method to check if a task is PI-boosted.

Provide a method to check if a task inherited the priority from another
task. This happens if a task owns a lock which is requested by a task
with higher priority. This can be used as a hint to add a preemption
point to the critical section.

Provide a function which reports true if the task is PI-boosted.

Link: https://lore.kernel.org/r/20230804113039.419794-2-bigeasy@linutronix.de
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
This commit is contained in:
Sebastian Andrzej Siewior
2023-08-04 13:30:37 +02:00
parent c15abad8f7
commit c6d3d3b3fe
2 changed files with 16 additions and 0 deletions
+1
View File
@@ -1905,6 +1905,7 @@ static inline int dl_task_check_affinity(struct task_struct *p, const struct cpu
}
#endif
extern bool task_is_pi_boosted(const struct task_struct *p);
extern int yield_to(struct task_struct *p, bool preempt);
extern void set_user_nice(struct task_struct *p, long nice);
extern int task_prio(const struct task_struct *p);
+15
View File
@@ -8922,6 +8922,21 @@ static inline void preempt_dynamic_init(void) { }
#endif /* #ifdef CONFIG_PREEMPT_DYNAMIC */
/*
* task_is_pi_boosted - Check if task has been PI boosted.
* @p: Task to check.
*
* Return true if task is subject to priority inheritance.
*/
bool task_is_pi_boosted(const struct task_struct *p)
{
int prio = p->prio;
if (!rt_prio(prio))
return false;
return prio != p->normal_prio;
}
/**
* yield - yield the current processor to other threads.
*