Hi all,

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

  rust/kernel/alloc/allocator.rs

between commit:

  fde578c86281 ("rust: alloc: replace aligned_size() with 
Kmalloc::aligned_layout()")

from the drm-misc-fixes tree and commit:

  cda097b07bce ("rust: support large alignments in allocations")

from the mm-unstable 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.

-- 
Cheers,
Stephen Rothwell

diff --cc rust/kernel/alloc/allocator.rs
index 2692cf90c948,63f271624428..000000000000
--- a/rust/kernel/alloc/allocator.rs
+++ b/rust/kernel/alloc/allocator.rs
@@@ -43,11 -42,28 +42,17 @@@ pub struct Vmalloc
  /// For more details see [self].
  pub struct KVmalloc;
  
 -/// Returns a proper size to alloc a new object aligned to `new_layout`'s 
alignment.
 -fn aligned_size(new_layout: Layout) -> usize {
 -    // Customized layouts from `Layout::from_size_align()` can have size < 
align, so pad first.
 -    let layout = new_layout.pad_to_align();
 -
 -    // Note that `layout.size()` (after padding) is guaranteed to be a 
multiple of `layout.align()`
 -    // which together with the slab guarantees means the `krealloc` will 
return a properly aligned
 -    // object (see comments in `kmalloc()` for more information).
 -    layout.size()
 -}
 -
  /// # Invariants
  ///
- /// One of the following: `krealloc`, `vrealloc`, `kvrealloc`.
+ /// One of the following: `krealloc_node_align`, `vrealloc_node_align`, 
`kvrealloc_node_align`.
  struct ReallocFunc(
-     unsafe extern "C" fn(*const crate::ffi::c_void, usize, u32) -> *mut 
crate::ffi::c_void,
+     unsafe extern "C" fn(
+         *const crate::ffi::c_void,
+         usize,
+         crate::ffi::c_ulong,
+         u32,
+         crate::ffi::c_int,
+     ) -> *mut crate::ffi::c_void,
  );
  
  impl ReallocFunc {
@@@ -76,8 -92,9 +81,9 @@@
          layout: Layout,
          old_layout: Layout,
          flags: Flags,
+         nid: NumaNode,
      ) -> Result<NonNull<[u8]>, AllocError> {
 -        let size = aligned_size(layout);
 +        let size = layout.size();
          let ptr = match ptr {
              Some(ptr) => {
                  if old_layout.size() == 0 {
@@@ -134,11 -140,10 +140,12 @@@ unsafe impl Allocator for Kmalloc 
          layout: Layout,
          old_layout: Layout,
          flags: Flags,
+         nid: NumaNode,
      ) -> Result<NonNull<[u8]>, AllocError> {
 +        let layout = Kmalloc::aligned_layout(layout);
 +
          // SAFETY: `ReallocFunc::call` has the same safety requirements as 
`Allocator::realloc`.
-         unsafe { ReallocFunc::KREALLOC.call(ptr, layout, old_layout, flags) }
+         unsafe { ReallocFunc::KREALLOC.call(ptr, layout, old_layout, flags, 
nid) }
      }
  }
  
@@@ -177,19 -177,10 +179,14 @@@ unsafe impl Allocator for KVmalloc 
          layout: Layout,
          old_layout: Layout,
          flags: Flags,
+         nid: NumaNode,
      ) -> Result<NonNull<[u8]>, AllocError> {
 +        // `KVmalloc` may use the `Kmalloc` backend, hence we have to enforce 
a `Kmalloc`
 +        // compatible layout.
 +        let layout = Kmalloc::aligned_layout(layout);
 +
-         // TODO: Support alignments larger than PAGE_SIZE.
-         if layout.align() > bindings::PAGE_SIZE {
-             pr_warn!("KVmalloc does not support alignments larger than 
PAGE_SIZE yet.\n");
-             return Err(AllocError);
-         }
- 
          // SAFETY: If not `None`, `ptr` is guaranteed to point to valid 
memory, which was previously
          // allocated with this `Allocator`.
-         unsafe { ReallocFunc::KVREALLOC.call(ptr, layout, old_layout, flags) }
+         unsafe { ReallocFunc::KVREALLOC.call(ptr, layout, old_layout, flags, 
nid) }
      }
  }

Attachment: pgpigg9hYgoiE.pgp
Description: OpenPGP digital signature

Reply via email to