linux-next: manual merge of the driver-core tree with the rust-alloc tree
Subsystems (3)
Mark Brown
maintainerHi all,
Today's linux-next merge of the driver-core tree got a conflict in:
rust/kernel/alloc/kbox.rs
between commit:
9b25d4111e913 ("rust: alloc: cleanup imports and use "kernel vertical" style")
from the rust-alloc tree and commit:
abb21500e7e5d ("rust: alloc: add Box::zeroed()")
from the driver-core 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.
rust/kernel/alloc/kbox.rs +0 -0
@@@ -3,47 -3,25 +3,47 @@@//! Implementation of [`Box`]. #[allow(unused_imports)] // Used in doc comments. -use super::allocator::{KVmalloc, Kmalloc, Vmalloc, VmallocPageIter}; -use super::{AllocError, Allocator, Flags, NumaNode}; -use core::alloc::Layout; -use core::borrow::{Borrow, BorrowMut}; -use core::marker::PhantomData; -use core::mem::ManuallyDrop; -use core::mem::MaybeUninit; -use core::ops::{Deref, DerefMut}; -use core::pin::Pin; -use core::ptr::NonNull; -use core::result::Result; +use super::allocator::{ + KVmalloc, + Kmalloc, + Vmalloc, + VmallocPageIter, // +}; -use crate::ffi::c_void; -use crate::fmt; -use crate::init::InPlaceInit; -use crate::page::AsPageIter; -use crate::prelude::*; -use crate::types::ForeignOwnable; -use pin_init::{InPlaceWrite, Init, PinInit, ZeroableOption}; +use super::{ + AllocError, + Allocator, + Flags, + NumaNode, // +}; + +use crate::{ + fmt, + page::AsPageIter, + prelude::*, + types::ForeignOwnable, // +}; + +use core::{ + alloc::Layout, + borrow::{ + Borrow, + BorrowMut, // + }, + marker::PhantomData, + mem::{ + ManuallyDrop, + MaybeUninit, // + }, + ops::{ + Deref, + DerefMut, // + }, + ptr::NonNull, + result::Result, // +}; + +use pin_init::ZeroableOption;/// The kernel's [`Box`] type -- a heap allocation for a single value of type `T`. /// Ok (Box (ptr.cast (),PhantomData )) } +/// Creates a new zero-initialized `Box<T, A>`. +/// +/// New memory is allocated with `A` and the [`__GFP_ZERO`] flag. The allocation may fail, in +/// which case an error is returned. For ZSTs no memory is allocated. +/// +/// # Examples +/// +/// ``` +/// let b = KBox::<[u8; 128]>::zeroed(GFP_KERNEL)?; +/// assert_eq!(*b, [0; 128]); +/// # Ok::<(), Error>(()) +/// ``` +pub fn zeroed (flags:Flags ) ->Result <Self ,AllocError > +where +T :Zeroable , + { +// SAFETY: `__GFP_ZERO` guarantees the memory is zeroed; `T: Zeroable` guarantees that +// all-zeroes is a valid bit pattern for `T`. +Ok (unsafe {Self ::new_uninit (flags | __GFP_ZERO)?.assume_init () }) + } +/// Constructs a new `Pin<Box<T, A>>`. If `T` does not implement [`Unpin`], then `x` will be /// pinned in memory and can't be moved. #[inline] /// # Examples /// /// ``` -/// use kernel::sync::{new_spinlock, SpinLock}; + /// use kernel::sync::{ + /// new_spinlock, + /// SpinLock, // + /// };/// /// struct Inner { /// a: u32, /// /// ``` /// # use core::borrow::Borrow; -/// # use kernel::alloc::KBox; /// struct Foo<B: Borrow<u32>>(B); /// /// // Owned instance. /// /// ``` /// # use core::borrow::BorrowMut; -/// # use kernel::alloc::KBox; /// struct Foo<B: BorrowMut<u32>>(B); /// /// // Owned instance. /// # Examples /// /// ``` -/// # use kernel::prelude::*; -/// use kernel::alloc::allocator::VmallocPageIter; -/// use kernel::page::{AsPageIter, PAGE_SIZE}; +/// use kernel::{ +/// alloc::allocator::VmallocPageIter, +/// page::{ +/// AsPageIter, +/// PAGE_SIZE, // +/// }, // +/// };/// /// let mut vbox = VBox::new((), GFP_KERNEL)?; ///
Danilo Krummrich
maintainerQuoted 8 lines · Mark Brown
Hi all,
Today's linux-next merge of the driver-core tree got a conflict in:
rust/kernel/alloc/kbox.rsbetween commit:
Quoted 7 lines
9b25d4111e913("rust: alloc: cleanup imports and use "kernel vertical" style")from the rust-alloc tree and commit:
abb21500e7e5d("rust: alloc: addBox::zeroed()")from the driver-core tree.
Looks good, thanks!