Re: [RT WARNING] DEBUG_LOCKS_WARN_ON(rt_mutex_owner(lock) != current) with fsfreeze (4.19.25-rt16)

From: Sebastian Andrzej Siewior
Date: Thu Mar 28 2019 - 06:17:32 EST


On 2019-03-26 10:34:21 [+0100], Juri Lelli wrote:
> Hi,
Hi,

â
> # for I in `seq 10`; do fsfreeze -f ./testmount; sleep 1; fsfreeze -u ./testmount; done
>
> ------------[ cut here ]------------
> DEBUG_LOCKS_WARN_ON(rt_mutex_owner(lock) != current)
> WARNING: CPU: 10 PID: 1226 at kernel/locking/rtmutex-debug.c:145 debug_rt_mutex_unlock+0x9b/0xb0
> Modules linked in: xfs [...]
> CPU: 10 PID: 1226 Comm: fsfreeze Not tainted 4.19.25-rt16 #2
> Hardware name: LENOVO 30B6S2F900/1030, BIOS S01KT61A 09/28/2018
> RIP: 0010:debug_rt_mutex_unlock+0x9b/0xb0
â
> __rt_mutex_unlock+0x45/0x80
> percpu_up_write+0x4b/0x60
> thaw_super_locked+0xdb/0x110
â
> AFAIU, this is a legit warning, since
>
> fsfreeze -f ./testmount grabs rt_mutexes embedded into
> sb->s_writers.rw_sem[SB_FREEZE_LEVELS] (rt-rwsem) as part of executing
> sb_wait_write() (for each FREEZE_LEVEL) in freeze_super().
>
> We then return to userspace.
>
> fsfreeze -u ./testmount unlocks the rt_mutexes while doing
> sb_freeze_unlock() in thaw_super_locked(). This is a different process
> w.r.t. the one that did the freeze above.
>
> I noticed that a very similar problem was fixed (for !rt rwsem) by
> 5a817641f68a ("locking/percpu-rwsem: Annotate rwsem ownership transfer
> by setting RWSEM_OWNER_UNKNOWN"). However, RT has of course to deal with
> PI, so I wonder if there is an easy fix for this problem.
>
> Suggestions?

So we leave to userland with an acquired rtmutex. And lockdep doesn't
complain because lockdep_sb_freeze_release() /
lockdep_sb_freeze_acquire() informs that everything is okay.
I have no idea, PeterZ? The rwsem is not ownerless afaik.

> Thanks,
>
> - Juri

Sebastian