Re: [PATCH v7 5/6] rust: ww_mutex: implement LockSet
From: Daniel Almeida
Date: Thu Nov 27 2025 - 08:47:05 EST
> On 27 Nov 2025, at 07:16, Onur Özkan <work@xxxxxxxxxxxxx> wrote:
>
> On Tue, 25 Nov 2025 16:35:21 -0500
> Lyude Paul <lyude@xxxxxxxxxx> wrote:
>
>> On Mon, 2025-11-24 at 18:49 +0300, Onur Özkan wrote:
>>>>
>>>> I wonder if there's some way we can get rid of the safety contract
>>>> here and verify this at compile time, it would be a shame if every
>>>> single lock invocation needed to be unsafe.
>>>>
>>>
>>> Yeah :(. We could get rid of them easily by keeping the class that
>>> was passed to the constructor functions but that becomes a problem
>>> for the from_raw implementations.
>>>
>>> I think the best solution would be to expose ww_class type from
>>> ww_acquire_ctx and ww_mutex unconditionally (right now it depends on
>>> DEBUG_WW_MUTEXES). That way we can just access the class and verify
>>> that the mutex and acquire_ctx classes match.
>>>
>>> What do you think? I can submit a patch for the C-side
>>> implementation. It should be straightforward and shouldn't have any
>>> runtime impact.
>>
>> I would be fine with this, and think this is definitely the right way
>> to go
>>
>
> It would be great to reach a consensus on this (whether we should send a
> patch to the C side or instead pass the Class to the from_raw functions
> without modifying the C code).
>
> -Onur
>
+1 from me on changing the C side, Onur.
— Daniel