Re: [PATCH v3 1/4] locking: Add rwsem_assert_held() and rwsem_assert_held_write()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 11/16/23 11:12, Matthew Wilcox wrote:
On Tue, Nov 14, 2023 at 08:17:32PM -0500, Waiman Long wrote:
There are some inconsistency in the use of WARN_ON() and BUG_ON() in the
assertions. For PREEMPT_RT, held_write is a BUG_ON. For non-PREEMPT_RT, held
is a BUG_ON. It is not clear why one is BUG_ON and other one is WARN_ON. Is
there a rationale for that?
I'll fix that up.
The check for write lock ownership is accurate. OTOH, the locked check can
have false positive and so is less reliable.
When you say 'false positive', do you mean it might report the lock as
being held, when it actually isn't, or report the lock as not being held
when it actually is?  The differing polarities of assert and BUG_ON
make this confusing as usual.
It means there may be no active lock owner even though the count isn't zero. If there is one or more owners, the count will always be non-zero.

Obviously, for an assert, we're OK with it reporting that the lock is
held when actually it's not.  The caller is expected to hold the lock,
so failing to trip the assert when the caller doesn't hold the lock
isn't great, but we can live with it.  OTOH, if the assert fires when
the caller does hold the lock, that is not tolerable.

The second case shouldn't happen. So the assert should be OK.

Cheers,
Longman





[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux