rust: convert raw URLs to Markdown autolinks in commentsSome comments in Rust files use raw URLs (http://example.com) ratherthan Markdown autolinks <URL>. This inconsistency makes thedocumentatio
rust: convert raw URLs to Markdown autolinks in commentsSome comments in Rust files use raw URLs (http://example.com) ratherthan Markdown autolinks <URL>. This inconsistency makes thedocumentation less uniform and harder to maintain.This patch converts all remaining raw URLs in Rust code comments to usethe Markdown autolink format, maintaining consistency with the rest ofthe codebase which already uses this style.Suggested-by: Miguel Ojeda <ojeda@kernel.org>Link: https://github.com/Rust-for-Linux/linux/issues/1153Signed-off-by: Xizhe Yin <xizheyin@smail.nju.edu.cn>Link: https://lore.kernel.org/r/509F0B66E3C1575D+20250407033441.5567-1-xizheyin@smail.nju.edu.cn[ Used From form for Signed-off-by. Sorted tags. - Miguel ]Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
show more ...
rust: block: refactor to use `&raw mut`Replace all occurrences (one) of `addr_of_mut!(place)` with`&raw mut place`.This will allow us to reduce macro complexity, and improve consistencywith exi
rust: block: refactor to use `&raw mut`Replace all occurrences (one) of `addr_of_mut!(place)` with`&raw mut place`.This will allow us to reduce macro complexity, and improve consistencywith existing reference syntax as `&raw mut` is similar to `&mut` makingit fit more naturally with other existing code.Suggested-by: Benno Lossin <benno.lossin@proton.me>Link: https://github.com/Rust-for-Linux/linux/issues/1148Signed-off-by: Antonio Hickey <contact@antoniohickey.com>Acked-by: Andreas Hindborg <a.hindborg@kernel.org>Reviewed-by: Benno Lossin <benno.lossin@proton.me>Reviewed-by: Boqun Feng <boqun.feng@gmail.com>Link: https://lore.kernel.org/r/20250320020740.1631171-17-contact@antoniohickey.com[ Reworded slightly. - Miguel ]Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
rust: make pin-init its own crateRename relative paths inside of the crate to still refer to the sameitems, also rename paths inside of the kernel crate and adjust the buildsystem to build the cr
rust: make pin-init its own crateRename relative paths inside of the crate to still refer to the sameitems, also rename paths inside of the kernel crate and adjust the buildsystem to build the crate.[ Remove the `expect` (and thus the `lint_reasons` feature) since the tree now uses `quote!` from `rust/macros/export.rs`. Remove the `TokenStream` import removal, since it is now used as well. In addition, temporarily (i.e. just for this commit) use an `--extern force:alloc` to prevent an unknown `new_uninit` error in the `rustdoc` target. For context, please see a similar case in: https://lore.kernel.org/lkml/20240422090644.525520-1-ojeda@kernel.org/ And adjusted the message above. - Miguel ]Signed-off-by: Benno Lossin <benno.lossin@proton.me>Reviewed-by: Fiona Behrens <me@kloenk.dev>Tested-by: Andreas Hindborg <a.hindborg@kernel.org>Link: https://lore.kernel.org/r/20250308110339.2997091-16-benno.lossin@proton.meSigned-off-by: Miguel Ojeda <ojeda@kernel.org>
Merge tag 'rust-6.14' of git://git.kernel.org/pub/scm/linux/kernel/git/ojeda/linuxPull rust updates from Miguel Ojeda: "Toolchain and infrastructure: - Finish the move to custom FFI integer ty
Merge tag 'rust-6.14' of git://git.kernel.org/pub/scm/linux/kernel/git/ojeda/linuxPull rust updates from Miguel Ojeda: "Toolchain and infrastructure: - Finish the move to custom FFI integer types started in the previous cycle and finally map 'long' to 'isize' and 'char' to 'u8'. Do a few cleanups on top thanks to that. - Start to use 'derive(CoercePointee)' on Rust >= 1.84.0. This is a major milestone on the path to build the kernel using only stable Rust features. In particular, previously we were using the unstable features 'coerce_unsized', 'dispatch_from_dyn' and 'unsize', and now we will use the new 'derive_coerce_pointee' one, which is on track to stabilization. This new feature is a macro that essentially expands into code that internally uses the unstable features that we were using before, without having to expose those. With it, stable Rust users, including the kernel, will be able to build custom smart pointers that work with trait objects, e.g.: fn f(p: &Arc<dyn Display>) { pr_info!("{p}\n"); } let a: Arc<dyn Display> = Arc::new(42i32, GFP_KERNEL)?; let b: Arc<dyn Display> = Arc::new("hello there", GFP_KERNEL)?; f(&a); // Prints "42". f(&b); // Prints "hello there". Together with the 'arbitrary_self_types' feature that we started using in the previous cycle, using our custom smart pointers like 'Arc' will eventually only rely in stable Rust. - Introduce 'PROCMACROLDFLAGS' environment variable to allow to link Rust proc macros using different flags than those used for linking Rust host programs (e.g. when 'rustc' uses a different C library than the host programs' one), which Android needs. - Help kernel builds under macOS with Rust enabled by accomodating other naming conventions for dynamic libraries (i.e. '.so' vs. '.dylib') which are used for Rust procedural macros. The actual support for macOS (i.e. the rest of the pieces needed) is provided out-of-tree by others, following the policy used for other parts of the kernel by Kbuild. - Run Clippy for 'rusttest' code too and clean the bits it spotted. - Provide Clippy with the minimum supported Rust version to improve the suggestions it gives. - Document 'bindgen' 0.71.0 regression. 'kernel' crate: - 'build_error!': move users of the hidden function to the documented macro, prevent such uses in the future by moving the function elsewhere and add the macro to the prelude. - 'types' module: add improved version of 'ForeignOwnable::borrow_mut' (which was removed in the past since it was problematic); change 'ForeignOwnable' pointer type to '*mut'. - 'alloc' module: implement 'Display' for 'Box' and align the 'Debug' implementation to it; add example (doctest) for 'ArrayLayout::new()' - 'sync' module: document 'PhantomData' in 'Arc'; use 'NonNull::new_unchecked' in 'ForeignOwnable for Arc' impl. - 'uaccess' module: accept 'Vec's with different allocators in 'UserSliceReader::read_all'. - 'workqueue' module: enable run-testing a couple more doctests. - 'error' module: simplify 'from_errno()'. - 'block' module: fix formatting in code documentation (a lint to catch these is being implemented). - Avoid 'unwrap()'s in doctests, which also improves the examples by showing how kernel code is supposed to be written. - Avoid 'as' casts with 'cast{,_mut}' calls which are a bit safer. And a few other cleanups"* tag 'rust-6.14' of git://git.kernel.org/pub/scm/linux/kernel/git/ojeda/linux: (32 commits) kbuild: rust: add PROCMACROLDFLAGS rust: uaccess: generalize userSliceReader to support any Vec rust: kernel: add improved version of `ForeignOwnable::borrow_mut` rust: kernel: reorder `ForeignOwnable` items rust: kernel: change `ForeignOwnable` pointer to mut rust: arc: split unsafe block, add missing comment rust: types: avoid `as` casts rust: arc: use `NonNull::new_unchecked` rust: use derive(CoercePointee) on rustc >= 1.84.0 rust: alloc: add doctest for `ArrayLayout::new()` rust: init: update `stack_try_pin_init` examples rust: error: import `kernel`'s `LayoutError` instead of `core`'s rust: str: replace unwraps with question mark operators rust: page: remove unnecessary helper function from doctest rust: rbtree: remove unwrap in asserts rust: init: replace unwraps with question mark operators rust: use host dylib naming convention to support macOS rust: add `build_error!` to the prelude rust: kernel: move `build_error` hidden function to prevent mistakes rust: use the `build_error!` macro, not the hidden function ...
rust: add `build_error!` to the preludeThe sibling `build_assert!` is already in the prelude, it makes sensethat a "core"/"language" facility like this is part of the prelude andusers should not
rust: add `build_error!` to the preludeThe sibling `build_assert!` is already in the prelude, it makes sensethat a "core"/"language" facility like this is part of the prelude andusers should not be defining their own one (thus there should be no riskof future name collisions and we would want to be aware of them anyway).Thus add `build_error!` into the prelude.Reviewed-by: Alice Ryhl <aliceryhl@google.com>Link: https://lore.kernel.org/r/20241123222849.350287-3-ojeda@kernel.org[ Applied the change to the new miscdevice cases. - Miguel ]Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
rust: use the `build_error!` macro, not the hidden functionCode and some examples were using the function, rather than the macro. Themacro is what is documented.Thus move users to the macro.Re
rust: use the `build_error!` macro, not the hidden functionCode and some examples were using the function, rather than the macro. Themacro is what is documented.Thus move users to the macro.Reviewed-by: Alice Ryhl <aliceryhl@google.com>Link: https://lore.kernel.org/r/20241123222849.350287-1-ojeda@kernel.org[ Applied the change to the new miscdevice cases. - Miguel ]Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
rust: block: fix use of BLK_MQ_F_SHOULD_MERGEBLK_MQ_F_SHOULD_MERGE has was removed [1] and is now in effect by default.So remove the flag from tag sets of Rust block device drivers.Link: https:/
rust: block: fix use of BLK_MQ_F_SHOULD_MERGEBLK_MQ_F_SHOULD_MERGE has was removed [1] and is now in effect by default.So remove the flag from tag sets of Rust block device drivers.Link: https://lore.kernel.org/r/20241219060214.1928848-1-hch@lst.de [1]Fixes: 9377b95cda73 ("block: remove BLK_MQ_F_SHOULD_MERGE")Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>Link: https://lore.kernel.org/r/20241220-merge-flag-fix-v1-1-41b7778dac06@kernel.orgSigned-off-by: Jens Axboe <axboe@kernel.dk>
rust: block: fix formatting in GenDisk docAlign bullet points and improve indentation in the `Invariants` sectionof the `GenDisk` struct documentation for better readability.[ Yutaro is also wor
rust: block: fix formatting in GenDisk docAlign bullet points and improve indentation in the `Invariants` sectionof the `GenDisk` struct documentation for better readability.[ Yutaro is also working on implementing the lint we suggested to catch this sort of issue in upstream Rust: https://github.com/rust-lang/rust-clippy/issues/13601 https://github.com/rust-lang/rust-clippy/pull/13711 Thanks a lot! - Miguel ]Fixes: 3253aba3408a ("rust: block: introduce `kernel::block::mq` module")Signed-off-by: Yutaro Ohno <yutaro.ono.418@gmail.com>Reviewed-by: Boqun Feng <boqun.feng@gmail.com>Acked-by: Andreas Hindborg <a.hindborg@kernel.org>Link: https://lore.kernel.org/r/ZxkcU5yTFCagg_lX@ohnotpSigned-off-by: Miguel Ojeda <ojeda@kernel.org>
Merge tag 'block-6.13-20242901' of git://git.kernel.dk/linuxPull more block updates from Jens Axboe: - NVMe pull request via Keith: - Use correct srcu list traversal (Breno) - Scatter
Merge tag 'block-6.13-20242901' of git://git.kernel.dk/linuxPull more block updates from Jens Axboe: - NVMe pull request via Keith: - Use correct srcu list traversal (Breno) - Scatter-gather support for metadata (Keith) - Fabrics shutdown race condition fix (Nilay) - Persistent reservations updates (Guixin) - Add the required bits for MD atomic write support for raid0/1/10 - Correct return value for unknown opcode in ublk - Fix deadlock with zone revalidation - Fix for the io priority request vs bio cleanups - Use the correct unsigned int type for various limit helpers - Fix for a race in loop - Cleanup blk_rq_prep_clone() to prevent uninit-value warning and make it easier for actual humans to read - Fix potential UAF when iterating tags - A few fixes for bfq-iosched UAF issues - Fix for brd discard not decrementing the allocated page count - Various little fixes and cleanups* tag 'block-6.13-20242901' of git://git.kernel.dk/linux: (36 commits) brd: decrease the number of allocated pages which discarded block, bfq: fix bfqq uaf in bfq_limit_depth() block: Don't allow an atomic write be truncated in blkdev_write_iter() mq-deadline: don't call req_get_ioprio from the I/O completion handler block: Prevent potential deadlock in blk_revalidate_disk_zones() block: Remove extra part pointer NULLify in blk_rq_init() nvme: tuning pr code by using defined structs and macros nvme: introduce change ptpl and iekey definition block: return bool from get_disk_ro and bdev_read_only block: remove a duplicate definition for bdev_read_only block: return bool from blk_rq_aligned block: return unsigned int from blk_lim_dma_alignment_and_pad block: return unsigned int from queue_dma_alignment block: return unsigned int from bdev_io_opt block: req->bio is always set in the merge code block: don't bother checking the data direction for merges block: blk-mq: fix uninit-value in blk_rq_prep_clone and refactor Revert "block, bfq: merge bfq_release_process_ref() into bfq_put_cooperator()" md/raid10: Atomic write support md/raid1: Atomic write support ...
rust: block: simplify Result<()> in validate_block_size return`Result` is used in place of `Result<()>` because the default typeparameters are unit `()` and `Error` types, which are automatically
rust: block: simplify Result<()> in validate_block_size return`Result` is used in place of `Result<()>` because the default typeparameters are unit `()` and `Error` types, which are automaticallyinferred. Thus keep the usage consistent throughout codebase.Suggested-by: Miguel Ojeda <ojeda@kernel.org>Link: https://github.com/Rust-for-Linux/linux/issues/1128Signed-off-by: Manas <manas18244@iiitd.ac.in>Reviewed-by: Miguel Ojeda <ojeda@kernel.org>Link: https://lore.kernel.org/r/20241118-simplify-result-v3-1-6b1566a77eab@iiitd.ac.inSigned-off-by: Jens Axboe <axboe@kernel.dk>
rust: use custom FFI integer typesCurrently FFI integer types are defined in libcore. This commit createsthe `ffi` crate and asks bindgen to use that crate for FFI integer typesinstead of `core::
rust: use custom FFI integer typesCurrently FFI integer types are defined in libcore. This commit createsthe `ffi` crate and asks bindgen to use that crate for FFI integer typesinstead of `core::ffi`.This commit is preparatory and no type changes are made in this commityet.Signed-off-by: Gary Guo <gary@garyguo.net>Link: https://lore.kernel.org/r/20240913213041.395655-4-gary@garyguo.net[ Added `rustdoc`, `rusttest` and KUnit tests support. Rebased on top of `rust-next` (e.g. migrated more `core::ffi` cases). Reworded crate docs slightly and formatted. - Miguel ]Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
rust: block: fix formatting of `kernel::block::mq::request` moduleFix several issues with rustdoc formatting for the`kernel::block::mq::Request` module, in particular: - An ordered list not ren
rust: block: fix formatting of `kernel::block::mq::request` moduleFix several issues with rustdoc formatting for the`kernel::block::mq::Request` module, in particular: - An ordered list not rendering correctly, fixed by using numbers prefixes instead of letters. - Code snippets formatted as regular text, fixed by wrapping the code with `back-ticks`. - References to types missing intra-doc links, fixed by wrapping the types with [square brackets].Reported-by: Miguel Ojeda <ojeda@kernel.org>Closes: https://github.com/Rust-for-Linux/linux/issues/1108Signed-off-by: Francesco Zardi <frazar00@gmail.com>Acked-by: Andreas Hindborg <a.hindborg@kernel.org>Fixes: 3253aba3408a ("rust: block: introduce `kernel::block::mq` module")Link: https://lore.kernel.org/r/20240903173027.16732-3-frazar00@gmail.com[ Added an extra intra-doc link. Took the chance to add some periods for consistency. Reworded slightly. - Miguel ]Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
rust: block: fix wrong usage of lockdep APIWhen allocating `struct gendisk`, `GenDiskBuilder` is using a dynamiclock class key without registering the key. This is an incorrect use ofthe API, whi
rust: block: fix wrong usage of lockdep APIWhen allocating `struct gendisk`, `GenDiskBuilder` is using a dynamiclock class key without registering the key. This is an incorrect use ofthe API, which causes a `WARN` trace.Fix the issue by using a static lock class key, which is more appropriatefor the situation anyway.Fixes: 3253aba3408a ("rust: block: introduce `kernel::block::mq` module")Reported-by: Behme Dirk (XC-CP/ESB5) <Dirk.Behme@de.bosch.com>Closes: https://rust-for-linux.zulipchat.com/#narrow/stream/x/topic/x/near/457090036Signed-off-by: Andreas Hindborg <a.hindborg@samsung.com>Reviewed-by: Benno Lossin <benno.lossin@proton.me>Reviewed-by: Gary Guo <gary@garyguo.net>Reviewed-by: Alice Ryhl <aliceryhl@google.com>Tested-by: Dirk Behme <dirk.behme@de.bosch.com>Link: https://lore.kernel.org/r/20240815074519.2684107-3-nmi@metaspace.dk[ Applied `rustfmt`, reworded slightly and made Zulip link a permalink. - Miguel ]Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
rust: block: do not use removed queue flag API`blk_queue_flag_set` and `blk_queue_flag_clear` was removed in favor of anew API. This caused a build error for Rust block device abstractions.Thus,
rust: block: do not use removed queue flag API`blk_queue_flag_set` and `blk_queue_flag_clear` was removed in favor of anew API. This caused a build error for Rust block device abstractions.Thus, use the new feature passing API instead of the old removed API.Fixes: bd4a633b6f7c ("block: move the nonrot flag to queue_limits")Signed-off-by: Andreas Hindborg <a.hindborg@samsung.com>Link: https://lore.kernel.org/r/20240620085721.1218296-1-nmi@metaspace.dkSigned-off-by: Jens Axboe <axboe@kernel.dk>
rust: block: do not use removed queue limit APIThe Rust block layer API was using the old queue limit API, which was justremoved. Use the new API instead.Reported-by: Boqun Feng <boqun.feng@gmai
rust: block: do not use removed queue limit APIThe Rust block layer API was using the old queue limit API, which was justremoved. Use the new API instead.Reported-by: Boqun Feng <boqun.feng@gmail.com>Fixes: 3253aba3408a ("rust: block: introduce `kernel::block::mq` module")Signed-off-by: Andreas Hindborg <a.hindborg@samsung.com>Link: https://lore.kernel.org/r/20240614235350.621121-1-nmi@metaspace.dkSigned-off-by: Jens Axboe <axboe@kernel.dk>
rust: block: introduce `kernel::block::mq` moduleAdd initial abstractions for working with blk-mq.This patch is a maintained, refactored subset of code originally publishedby Wedson Almeida Filh
rust: block: introduce `kernel::block::mq` moduleAdd initial abstractions for working with blk-mq.This patch is a maintained, refactored subset of code originally publishedby Wedson Almeida Filho <wedsonaf@gmail.com> [1].[1] https://github.com/wedsonaf/linux/tree/f2cfd2fe0e2ca4e90994f96afe268bbd4382a891/rust/kernel/blk/mq.rsCc: Wedson Almeida Filho <wedsonaf@gmail.com>Signed-off-by: Andreas Hindborg <a.hindborg@samsung.com>Reviewed-by: Benno Lossin <benno.lossin@proton.me>Link: https://lore.kernel.org/r/20240611114551.228679-2-nmi@metaspace.dkSigned-off-by: Jens Axboe <axboe@kernel.dk>