linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Alice Ryhl <alice@ryhl.io>
To: John Hubbard <jhubbard@nvidia.com>, Miguel Ojeda <ojeda@kernel.org>
Cc: "Alex Gaynor" <alex.gaynor@gmail.com>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <benno.lossin@proton.me>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Trevor Gross" <tmgross@umich.edu>,
	linux-mm@kvack.org, rust-for-linux@vger.kernel.org,
	linux-kernel@vger.kernel.org, "Alice Ryhl" <aliceryhl@google.com>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Matthew Wilcox (Oracle)" <willy@infradead.org>
Subject: Re: [PATCH v2] rust: page: add Rust version of PAGE_ALIGN
Date: Mon, 21 Oct 2024 20:32:11 +0200	[thread overview]
Message-ID: <56169ee4-321c-4546-bb89-2f9530adb01c@ryhl.io> (raw)
In-Reply-To: <81e9b289-b95c-4671-b442-1a0ac3dae466@nvidia.com>

On 10/21/24 8:20 PM, John Hubbard wrote:
> On 10/16/24 4:34 AM, Alice Ryhl wrote:
>> This is a useful for helper for working with indices into buffers that
>> consist of several pages. I forgot to include it when I added PAGE_SIZE
>> and PAGE_MASK for the same purpose in commit fc6e66f4696b ("rust: add
>> abstraction for `struct page`").
>>
>> Reviewed-by: Boqun Feng <boqun.feng@gmail.com>
>> Signed-off-by: Alice Ryhl <aliceryhl@google.com>
>> ---
>> Changes in v2:
>> - Make the function const.
>> - Address integer overflow in docs.
>> - Link to v1: https://lore.kernel.org/r/20241015-page-align- 
>> v1-1-68fbd8b6d10c@google.com
>> ---
>>   rust/kernel/page.rs | 9 +++++++++
>>   1 file changed, 9 insertions(+)
>>
>> diff --git a/rust/kernel/page.rs b/rust/kernel/page.rs
>> index 208a006d587c..9ef01929e7d0 100644
>> --- a/rust/kernel/page.rs
>> +++ b/rust/kernel/page.rs
>> @@ -20,6 +20,15 @@
>>   /// A bitmask that gives the page containing a given address.
>>   pub const PAGE_MASK: usize = !(PAGE_SIZE - 1);
>> +/// Round up the given number to the next multiple of `PAGE_SIZE`.
>> +///
>> +/// It is incorrect to pass an address where the next multiple of 
>> `PAGE_SIZE` doesn't fit in a
>> +/// `usize`.
>> +pub const fn page_align(addr: usize) -> usize {
>> +    // Brackets around PAGE_SIZE-1 to avoid triggering overflow 
>> sanitizers in the wrong cases.
> 
> Silly nit, but I did start looking for brackets that aren't there, so:
> 
> s/Brackets/parentheses/
This isn't a distinction that exists in my vocabulary, shrug.

Miguel, feel free to reword when you pick this.

Alice


  parent reply	other threads:[~2024-10-21 18:29 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-16 11:34 Alice Ryhl
2024-10-21 18:13 ` Miguel Ojeda
2024-10-21 18:20 ` John Hubbard
2024-10-21 18:29   ` Miguel Ojeda
2024-10-21 18:34     ` John Hubbard
2024-10-21 18:37       ` Miguel Ojeda
2024-10-21 18:41         ` John Hubbard
2024-10-21 18:59           ` Alice Ryhl
2024-10-21 19:08             ` John Hubbard
2024-10-21 19:26               ` Alice Ryhl
2024-10-21 19:34                 ` John Hubbard
2024-10-21 19:49                   ` Alice Ryhl
2024-10-21 19:51                     ` John Hubbard
2024-10-21 18:32   ` Alice Ryhl [this message]
2024-10-21 18:36     ` Miguel Ojeda

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=56169ee4-321c-4546-bb89-2f9530adb01c@ryhl.io \
    --to=alice@ryhl.io \
    --cc=a.hindborg@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=benno.lossin@proton.me \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=gary@garyguo.net \
    --cc=jhubbard@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tmgross@umich.edu \
    --cc=willy@infradead.org \
    /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