public inbox for linux-next@vger.kernel.org
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Miguel Ojeda <ojeda@kernel.org>
Cc: Danilo Krummrich <dakr@kernel.org>, Gary Guo <gary@garyguo.net>,
	John Hubbard <jhubbard@nvidia.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux Next Mailing List <linux-next@vger.kernel.org>
Subject: linux-next: manual merge of the rust tree with the origin tree
Date: Fri, 3 Apr 2026 13:35:29 +0100	[thread overview]
Message-ID: <ac-0Eb8leHb-h3FE@sirena.org.uk> (raw)

[-- Attachment #1: Type: text/plain, Size: 2934 bytes --]

Hi all,

Today's linux-next merge of the rust tree got a conflict in:

  rust/kernel/ptr.rs

between commit:

  08da98f18f4f9 ("rust: ptr: add `KnownSize` trait to support DST size info extraction")

from the origin tree and commit:

  0a51b384e0dec ("rust: ptr: add const_align_up()")

from the rust tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

diff --cc rust/kernel/ptr.rs
index bdc2d79ff6699,c7788656a1621..0000000000000
--- a/rust/kernel/ptr.rs
+++ b/rust/kernel/ptr.rs
@@@ -2,15 -2,11 +2,17 @@@
  
  //! Types and functions to work with pointers and addresses.
  
 -use core::mem::align_of;
 +pub mod projection;
 +pub use crate::project_pointer as project;
 +
 +use core::mem::{
 +    align_of,
 +    size_of, //
 +};
  use core::num::NonZero;
  
+ use crate::const_assert;
+ 
  /// Type representing an alignment, which is always a power of two.
  ///
  /// It is used to validate that a given value is a valid alignment, and to perform masking and
@@@ -232,24 -226,31 +232,53 @@@ macro_rules! impl_alignable_uint 
  
  impl_alignable_uint!(u8, u16, u32, u64, usize);
  
 +/// Trait to represent compile-time known size information.
 +///
 +/// This is a generalization of [`size_of`] that works for dynamically sized types.
 +pub trait KnownSize {
 +    /// Get the size of an object of this type in bytes, with the metadata of the given pointer.
 +    fn size(p: *const Self) -> usize;
 +}
 +
 +impl<T> KnownSize for T {
 +    #[inline(always)]
 +    fn size(_: *const Self) -> usize {
 +        size_of::<T>()
 +    }
 +}
 +
 +impl<T> KnownSize for [T] {
 +    #[inline(always)]
 +    fn size(p: *const Self) -> usize {
 +        p.len() * size_of::<T>()
 +    }
 +}
++
+ /// Aligns `value` up to `align`.
+ ///
+ /// This is the const-compatible equivalent of [`Alignable::align_up`].
+ ///
+ /// Returns [`None`] on overflow.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// use kernel::{
+ ///     ptr::{
+ ///         const_align_up,
+ ///         Alignment, //
+ ///     },
+ ///     sizes::SZ_4K, //
+ /// };
+ ///
+ /// assert_eq!(const_align_up(0x4f, Alignment::new::<16>()), Some(0x50));
+ /// assert_eq!(const_align_up(0x40, Alignment::new::<16>()), Some(0x40));
+ /// assert_eq!(const_align_up(1, Alignment::new::<SZ_4K>()), Some(SZ_4K));
+ /// ```
+ #[inline(always)]
+ pub const fn const_align_up(value: usize, align: Alignment) -> Option<usize> {
+     match value.checked_add(align.as_usize() - 1) {
+         Some(v) => Some(v & align.mask()),
+         None => None,
+     }
+ }

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

             reply	other threads:[~2026-04-03 12:35 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-03 12:35 Mark Brown [this message]
2026-04-03 12:53 ` linux-next: manual merge of the rust tree with the origin tree Miguel Ojeda
  -- strict thread matches above, loose matches on Subject: below --
2026-04-06 13:13 Mark Brown
2026-04-06 13:16 ` Miguel Ojeda
2026-04-06 13:12 Mark Brown
2026-04-06 13:15 ` Miguel Ojeda
2026-04-06 13:02 Mark Brown
2026-04-06 13:11 ` Miguel Ojeda
2026-04-06 13:14   ` Mark Brown
2026-03-30 13:17 Mark Brown
2026-03-30 13:26 ` Gary Guo
2026-03-30 13:30   ` Miguel Ojeda
2026-03-30 13:32     ` Miguel Ojeda
2021-12-13 22:33 broonie

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=ac-0Eb8leHb-h3FE@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=dakr@kernel.org \
    --cc=gary@garyguo.net \
    --cc=jhubbard@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=ojeda@kernel.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