Re: [PATCH] locking/rtmutex: Provide proper spin_is_contended

From: Sebastian Andrzej Siewior
Date: Tue Jun 07 2022 - 05:25:26 EST


On 2022-06-07 17:15:14 [+0800], Zhipeng Shi wrote:
> Commit d89c70356acf ("locking/core: Remove break_lock field when
> CONFIG_GENERIC_LOCKBREAK=y") removed GENERIC_LOCKBREAK, which caused
> spin_is_contended depend on the implementation of arch_spin_is_contended.
> But now in rt-spinlock, spin_is_contended returns 0 directly.
>
> This causes cond_resched_lock to fail to correctly detect lock contention
> in RT-linux. In some scenarios (such as __purge_vmap_area_lazy in vmalloc),
> this will cause a large latency.
>
> This patch provides the implementation of spin_is_contended for
> rt-spinlock.

Do you have a test-case or an example?

The thing if _this_ task has higher priority than other tasks waiting on
this lock then a simple unlock+lock won't do a thing. That is why I
ripped it all out while it was half way done.

> Signed-off-by: Zhipeng Shi <zhipeng.shi0@xxxxxxxxx>

Sebastian