Messages in this thread | | | Date | Thu, 18 May 2023 11:51:17 -0300 | From | Martin Rodriguez Reboredo <> | Subject | Re: [PATCH v1 1/7] rust: workqueue: add low-level workqueue bindings |
| |
On 5/17/23 17:31, Alice Ryhl wrote: > Define basic low-level bindings to a kernel workqueue. The API defined > here can only be used unsafely. Later commits will provide safe > wrappers. > > Signed-off-by: Alice Ryhl <aliceryhl@google.com> > --- > [...] > + > +impl Queue { > + /// Use the provided `struct workqueue_struct` with Rust. > + /// > + /// # Safety > + /// > + /// The caller must ensure that the provided raw pointer is not dangling, that it points at a > + /// valid workqueue, and that it remains valid until the end of 'a. > + pub unsafe fn from_raw<'a>(ptr: *const bindings::workqueue_struct) -> &'a Queue { > + // SAFETY: The `Queue` type is `#[repr(transparent)]`, so the pointer cast is valid. The > + // caller promises that the pointer is not dangling. > + unsafe { &*(ptr as *const Queue) } > + } > + > + /// Enqueues a work item. > + /// > + /// This may fail if the work item is already enqueued in a workqueue.
Wouldn't be worth to mention that, if not implied, the item it's going to be worked on an unbound CPU?
> + pub fn enqueue<T: WorkItem + Send + 'static>(&self, w: T) -> T::EnqueueOutput { > + let queue_ptr = self.0.get(); > [...]
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
| |