Re: [patch V3 48/64] locking/ww_mutex: Add RT priority to W/W order

From: Peter Zijlstra
Date: Fri Aug 06 2021 - 06:50:36 EST


On Thu, Aug 05, 2021 at 05:13:48PM +0200, Thomas Gleixner wrote:
> static inline bool
> +__ww_ctx_less(struct ww_acquire_ctx *a, struct ww_acquire_ctx *b)
> {
> +/*
> + * Can only do the RT prio for WW_RT because task->prio isn't stable due to PI,
> + * so the wait_list ordering will go wobbly. rt_mutex re-queues the waiter and
> + * isn't affected by this.
> + */
> +#ifdef WW_RT
> + /* kernel prio; less is more */
> + int a_prio = a->task->prio;
> + int b_prio = b->task->prio;
> +
> + if (dl_prio(a_prio) || dl_prio(b_prio)) {

Whoever wrote this was an idiot :-) Both should be rt_prio().

> +
> + if (a_prio > b_prio)
> + return true;
> +
> + if (a_prio < b_prio)
> + return false;
> +
> + /* equal static prio */
> +
> + if (dl_prio(a_prio)) {
> + if (dl_time_before(b->task->dl.deadline,
> + a->task->dl.deadline))
> + return true;
> +
> + if (dl_time_before(a->task->dl.deadline,
> + b->task->dl.deadline))
> + return false;
> + }
> +
> + /* equal prio */
> + }
> +#endif
>
> + /* FIFO order tie break -- bigger is younger */
> return (signed long)(a->stamp - b->stamp) > 0;
> }