Re: [PATCH 3/5] rust: sync: add WaitQueue infrastructure

"Gary Guo" <[email protected]> Mon, 27 Jul 2026 14:21:24 +0100
Newsgroups org.kernel.vger.rust-for-linux,org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On Mon Jul 27, 2026 at 1:46 PM BST, Danilo Krummrich wrote:
> On Mon Jul 27, 2026 at 2:02 PM CEST, Gary Guo wrote:
>>> @@ -0,0 +1,388 @@
>>> +// SPDX-License-Identifier: GPL-2.0
>>> +
>>> +//! Wait queue.
>>> +//!
>>> +//! C header: [`include/linux/wait.h`](srctree/include/linux/wait.h)
>>> +
>>> +use super::LockClassKey;
>>> +use crate::{
>>> +    prelude::*,
>>> +    str::CStr,
>>> +    task::{
>>> +        self,
>>> +        TASK_INTERRUPTIBLE,
>>> +        TASK_NORMAL,
>>> +        TASK_UNINTERRUPTIBLE, //
>>
>> Hmm, I am not sure why we are exposing these as constants from kernel::task.
>> Regardless, Given that you're using them for bindings, you should probably get
>> them from bindings::TASK_* instead.
>
> See commit f090f0d0eea9 ("rust: sync: update integer types in CondVar");
> personally I don't mind either way.

We should probably find a way to do type casting in bindings crate for these
instead.

I suppose the C API is also being inconsistent there, given that `__state` is
`unsigned int`, while `prepare_to_wait_event` and friends use `int`. Not really
an issue because TASK_ANY is 0xFFFF. But it does feel to me that we should
actually be using `unsigned int` here.

Best,
Gary