Re: [PATCH 10/13] rust: kernel: add doclinks

From: Trevor Gross
Date: Wed Jan 17 2024 - 20:42:59 EST


On Tue, Jan 16, 2024 at 6:11 PM Valentin Obst <kernel@xxxxxxxxxxxxxxx> wrote:
>
> Add doclinks to existing documentation.
>
> Signed-off-by: Valentin Obst <kernel@xxxxxxxxxxxxxxx>
> ---
> rust/kernel/sync/arc.rs | 6 +++---
> rust/kernel/sync/lock.rs | 13 +++++++++---
> rust/kernel/workqueue.rs | 45 ++++++++++++++++++++++++----------------
> 3 files changed, 40 insertions(+), 24 deletions(-)
>
> diff --git a/rust/kernel/sync/arc.rs b/rust/kernel/sync/arc.rs
> index 6c46b1affca5..936bc549a082 100644
> --- a/rust/kernel/sync/arc.rs
> +++ b/rust/kernel/sync/arc.rs
> @@ -365,12 +365,12 @@ fn from(item: Pin<UniqueArc<T>>) -> Self {
> /// A borrowed reference to an [`Arc`] instance.
> ///
> /// For cases when one doesn't ever need to increment the refcount on the allocation, it is simpler
> -/// to use just `&T`, which we can trivially get from an `Arc<T>` instance.
> +/// to use just `&T`, which we can trivially get from an [`Arc<T>`] instance.
> ///
> /// However, when one may need to increment the refcount, it is preferable to use an `ArcBorrow<T>`
> /// over `&Arc<T>` because the latter results in a double-indirection: a pointer (shared reference)
> -/// to a pointer (`Arc<T>`) to the object (`T`). An [`ArcBorrow`] eliminates this double
> -/// indirection while still allowing one to increment the refcount and getting an `Arc<T>` when/if
> +/// to a pointer ([`Arc<T>`]) to the object (`T`). An [`ArcBorrow`] eliminates this double
> +/// indirection while still allowing one to increment the refcount and getting an [`Arc<T>`] when/if
> /// needed.

I think it is usually okay to only link the first usage in a section
or paragraph. No harm having more of course.

> /// # Invariants
> diff --git a/rust/kernel/sync/lock.rs b/rust/kernel/sync/lock.rs
> index 467249b39f71..f14179d19d4e 100644
> --- a/rust/kernel/sync/lock.rs
> +++ b/rust/kernel/sync/lock.rs
> @@ -21,14 +21,21 @@
> /// # Safety
> ///
> /// - Implementers must ensure that only one thread/CPU may access the protected data once the lock
> -/// is owned, that is, between calls to `lock` and `unlock`.
> -/// - Implementers must also ensure that `relock` uses the same locking method as the original
> +/// is owned, that is, between calls to [`lock`] and [`unlock`].
> +/// - Implementers must also ensure that [`relock`] uses the same locking method as the original
> /// lock operation.

The second lines of these list items should probably be indented
(doesn't have to be in this patch).

> [...]
> @@ -290,10 +294,11 @@ unsafe fn __enqueue<F>(self, queue_work_on: F) -> Self::EnqueueOutput
>
> /// Defines the method that should be called directly when a work item is executed.
> ///
> -/// This trait is implemented by `Pin<Box<T>>` and `Arc<T>`, and is mainly intended to be
> +/// This trait is implemented by `Pin<Box<T>>` and [`Arc<T>`], and is mainly intended to be

`Pin` could be linked too.

> [...]

Just a few nits for this one, nothing blocking.

Reviewed-by: Trevor Gross <tmgross@xxxxxxxxx>