Page MenuHomeFreeBSD

pbuf_ctor(): Stop using LK_NOWAIT, use LK_NOWITNESS
ClosedPublic

Authored by rlibby on May 25 2024, 7:45 AM.
Tags
None
Referenced Files
Unknown Object (File)
Nov 30 2024, 3:36 PM
Unknown Object (File)
Nov 25 2024, 9:40 PM
Unknown Object (File)
Nov 25 2024, 4:19 AM
Unknown Object (File)
Nov 23 2024, 8:22 PM
Unknown Object (File)
Nov 22 2024, 7:53 AM
Unknown Object (File)
Nov 21 2024, 6:36 AM
Unknown Object (File)
Nov 20 2024, 4:12 AM
Unknown Object (File)
Nov 19 2024, 10:29 AM
Subscribers

Details

Summary

The LK_NOWAIT was added to suppress a witness warning, but LK_NOWITNESS
is more what we mean. This makes pbuf_ctor() more consistent with
buf_alloc(), although, unlike buf_alloc(), for pbuf there should not be
any danger of a wild locker relying on the type stability of the buf to
attempt a lock. That is, this is essentially cosmetic.

Relevant history:

Sponsored by: Dell EMC Isilon

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 57911
Build 54799: arc lint + arc unit

Event Timeline

I'm fine with this change as it semantically makes sense and mimics original behavior of pbuf_ctor()

...that and LK_NOWAIT, in theory, could return an unhandled error from pbuf_ctor()

This revision is now accepted and ready to land.May 25 2024, 7:28 PM

LK_NOWAIT is the common pattern for this situation. Besides buffers, another immediate example is the vm_map lock in vmspace_fork() (look for the new_map locking and comment).

In D45360#1034889, @kib wrote:

LK_NOWAIT is the common pattern for this situation. Besides buffers, another immediate example is the vm_map lock in vmspace_fork() (look for the new_map locking and comment).

Thanks for the pointer. Yeah, that case makes sense. We don't really have a more expressive API there like we do with lockmgr's flags. I wonder if we might want a way to say explicitly that this is a lock that no one else can know about, e.g. LK_INITIAL, that would avoid reporting a LOR when taken second, but also can KASSERT that the lock was not contended.

In D45360#1034889, @kib wrote:

LK_NOWAIT is the common pattern for this situation. Besides buffers, another immediate example is the vm_map lock in vmspace_fork() (look for the new_map locking and comment).

Thanks for the pointer. Yeah, that case makes sense. We don't really have a more expressive API there like we do with lockmgr's flags. I wonder if we might want a way to say explicitly that this is a lock that no one else can know about, e.g. LK_INITIAL, that would avoid reporting a LOR when taken second, but also can KASSERT that the lock was not contended.

This is an interesting proposal, I like it.