Re: [PATCH v6 5/7] rust: ww_mutex: add context-free locking functions

Daniel Almeida
2025-10-21T13:32:35Z

> On 6 Sep 2025, at 08:20, Onur <work@onurozkan.dev> wrote:
>
> On Fri, 5 Sep 2025 16:14:59 -0300
> Daniel Almeida <daniel.almeida@collabora.com> wrote:
>
>> Hi Onur
>>
>>> On 3 Sep 2025, at 10:13, Onur Özkan <work@onurozkan.dev> wrote:
>>>
>>> Adds new `WwMutex` functions (`lock`, `lock_interruptible`,
>>> `lock_slow`, `lock_slow_interruptible` and `try_lock`) that
>>> can be used without `WwAcquireCtx`. This provides simpler API
>>> when deadlock avoidance grouping is not needed.
>>>
>>> Signed-off-by: Onur Özkan <work@onurozkan.dev>
>>> ---
>>> rust/kernel/sync/lock/ww_mutex.rs | 162
>>> ++++++++++++++++++++++-------- 1 file changed, 122 insertions(+),
>>> 40 deletions(-)
>>>
>>> diff --git a/rust/kernel/sync/lock/ww_mutex.rs
>>> b/rust/kernel/sync/lock/ww_mutex.rs index
>>> d289718d2c98..b415d6deae9b 100644 ---
>>> a/rust/kernel/sync/lock/ww_mutex.rs +++
>>> b/rust/kernel/sync/lock/ww_mutex.rs @@ -138,6 +138,75 @@ pub fn
>>> new_wound_wait(name: &'static CStr) -> impl PinInit<Self> { }
>>> }
>>>
>>> +/// Locking kinds used by [`lock_common`] to unify internal FFI
>>> locking logic.
>>
>> Can you please mention how this is not exposed to the outside world?
>>
>> It should be obvious from its private visibility, but still.
>>
>
> I would like to keep this private and force users to go through the
> public ones. This function contains the entire internal locking logic
> and its signature may need to change if we update any of the internals.
> Since it's private, we can safely make breaking changes without
> affecting external calls.
>
> The public functions on the other hand are much more stable (at worst,
> only one or two of them might need a breaking change).
>

That’s fine, what I mean is that you should mention that users aren’t
expected to use it directly.

Again, this is obvious (given that the visibility is private) but it
doesn’t hurt to explain things a bit more on the docs.

— Daniel