From: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
To: Andrew Ballance <andrewjballance@gmail.com>
Cc: Liam.Howlett@oracle.com, ojeda@kernel.org, alex.gaynor@gmail.com,
boqun.feng@gmail.com, gary@garyguo.net,
bjorn3_gh@protonmail.com, benno.lossin@proton.me,
a.hindborg@kernel.org, aliceryhl@google.com, tmgross@umich.edu,
dakr@kernel.org, akpm@linux-foundation.org,
gregkh@linuxfoundation.org, wedsonaf@gmail.com,
brauner@kernel.org, dingxiangfei2009@gmail.com,
linux-kernel@vger.kernel.org, maple-tree@lists.infradead.org,
linux-mm@kvack.org, rust-for-linux@vger.kernel.org
Subject: Re: [RFC PATCH 2/2] rust: add maple tree abstractions
Date: Sat, 5 Apr 2025 17:23:39 +0200 [thread overview]
Message-ID: <CANiq72=KqZ6pOj62ofmv0yRfqy3HjZkDHanyvFbDvb+ECcjgTQ@mail.gmail.com> (raw)
In-Reply-To: <20250405060154.1550858-3-andrewjballance@gmail.com>
Hi Andrew,
Some doc-related notes for future submissions... I hope this helps.
On Sat, Apr 5, 2025 at 8:03 AM Andrew Ballance
<andrewjballance@gmail.com> wrote:
>
> +#include <linux/maple_tree.h>
> +
> +
Nit: double newline.
> +//! # Examples
> +//! ```
There should be an empty doc line between these.
> +// TODO and missing features
> +// - the C version suports external locking this only supports the internal spinlock
(Multiple instances) Typo -- you may want to use e.g. `checkpatch.pl`
with `--codespell`.
> +// SAFETY:
> +// we cannot derefrence any pointers without holding the spinlock because
> +// all returned pointers are guaranteed to have been inserted by the user
> +// but the pointers are not guaranteed to be still be valid
> +// another thread may have already removed and dropped the pointers
> +// so to safely deref the returned pointers the user must
> +// have exclusive write access to the `MapleTree`
> +// or rcu_read_lock() is held and updater side uses a synchronize_rcu()
`SAFETY` comments are intended to go attached to an `unsafe` block or
implementation, explaining why they satisfy the requirements.
Clippy should be warning here, but it doesn't likely due to this
Clippy issue I just filed:
https://github.com/rust-lang/rust-clippy/issues/14554
(plus other three I filed while looking into this one).
> +/// A `MapleTree` is a tree like data structure that is optimized for storing
(Multiple instances) Please use intra-doc links wherever they work.
> +// # Invariants
(Multiple instances) Please make this section part of the docs. We may
change how we document private invariants in the future (or we may
expose private fields so that it is clearer) -- for the moment, please
add a note if you really want users to never rely on a particular
invariant.
> + /// creates a new `MapleTree` with the specified `flags`
(Multiple instances) Please follow the usual style, e.g. Markdown and
intra-doc links where possible, start with uppercase, period at the
end of sentences, etc.
> + // SAFETY:
> + // - mt is valid because of ffi_init
> + // - maple_tree contains a lock which should be pinned
(Multiple instances) Please format with Markdown in comments.
> + /// helper for internal use.
> + /// returns an iterator through the maple tree
> + /// # Safety
(Multiple instances) Newlines are needed here -- `rustdoc` uses the
first paragraph as the "short description", too.
> +#[derive(Clone, Copy, PartialEq)]
> +/// flags to be used with [`MapleTree::new`].
We write attributes below the documentation.
> + if ptr.is_null() {
> + return None;
> + }
> + // SAFETY:
We typically leave a newline after a loop or a branch.
Thanks for the patch!
Cheers,
Miguel
next prev parent reply other threads:[~2025-04-05 15:23 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-05 6:01 [RFC PATCH 0/2] rust: add support for maple trees Andrew Ballance
2025-04-05 6:01 ` [RFC PATCH 1/2] maple_tree: add __mtree_insert_range function Andrew Ballance
2025-04-05 15:22 ` Matthew Wilcox
2025-04-05 18:38 ` Boqun Feng
2025-04-06 9:30 ` Andrew Ballance
2025-04-05 6:01 ` [RFC PATCH 2/2] rust: add maple tree abstractions Andrew Ballance
2025-04-05 15:23 ` Miguel Ojeda [this message]
2025-04-07 13:59 ` Liam R. Howlett
2025-04-07 20:02 ` Andrew Ballance
2025-04-08 1:36 ` Liam R. Howlett
2025-04-14 18:27 ` Danilo Krummrich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CANiq72=KqZ6pOj62ofmv0yRfqy3HjZkDHanyvFbDvb+ECcjgTQ@mail.gmail.com' \
--to=miguel.ojeda.sandonis@gmail.com \
--cc=Liam.Howlett@oracle.com \
--cc=a.hindborg@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=andrewjballance@gmail.com \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=brauner@kernel.org \
--cc=dakr@kernel.org \
--cc=dingxiangfei2009@gmail.com \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=maple-tree@lists.infradead.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
--cc=wedsonaf@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox