[PATCH] rust: alloc: add GFP_NOIO flag

From: Andreas Hindborg

Date: Wed Jan 28 2026 - 13:38:31 EST


Add an abstraction for the `GFP_NOIO` flag. This flag signals that the
caller requires allocation to complete without triggering any block device
IO.

Signed-off-by: Andreas Hindborg <a.hindborg@xxxxxxxxxx>
---
rust/bindings/bindings_helper.h | 1 +
rust/kernel/alloc.rs | 4 ++++
2 files changed, 5 insertions(+)

diff --git a/rust/bindings/bindings_helper.h b/rust/bindings/bindings_helper.h
index a067038b4b422..3910ecc5c34cf 100644
--- a/rust/bindings/bindings_helper.h
+++ b/rust/bindings/bindings_helper.h
@@ -106,6 +106,7 @@ const size_t RUST_CONST_HELPER_PAGE_SIZE = PAGE_SIZE;
const gfp_t RUST_CONST_HELPER_GFP_ATOMIC = GFP_ATOMIC;
const gfp_t RUST_CONST_HELPER_GFP_KERNEL = GFP_KERNEL;
const gfp_t RUST_CONST_HELPER_GFP_KERNEL_ACCOUNT = GFP_KERNEL_ACCOUNT;
+const gfp_t RUST_CONST_HELPER_GFP_NOIO = GFP_NOIO;
const gfp_t RUST_CONST_HELPER_GFP_NOWAIT = GFP_NOWAIT;
const gfp_t RUST_CONST_HELPER___GFP_ZERO = __GFP_ZERO;
const gfp_t RUST_CONST_HELPER___GFP_HIGHMEM = ___GFP_HIGHMEM;
diff --git a/rust/kernel/alloc.rs b/rust/kernel/alloc.rs
index e38720349dcf7..5f6a0f7e99c03 100644
--- a/rust/kernel/alloc.rs
+++ b/rust/kernel/alloc.rs
@@ -99,6 +99,10 @@ pub mod flags {
/// The same as [`GFP_KERNEL`], except the allocation is accounted to kmemcg.
pub const GFP_KERNEL_ACCOUNT: Flags = Flags(bindings::GFP_KERNEL_ACCOUNT);

+ /// [`GFP_NOIO`] will use direct reclaim to discard clean pages or slab
+ /// pages that do not require the starting of any physical IO.
+ pub const GFP_NOIO: Flags = Flags(bindings::GFP_NOIO);
+
/// For kernel allocations that should not stall for direct reclaim, start physical IO or
/// use any filesystem callback. It is very likely to fail to allocate memory, even for very
/// small allocations.

---
base-commit: 63804fed149a6750ffd28610c5c1c98cce6bd377
change-id: 20260128-gfp-noio-fbd41e135088

Best regards,
--
Andreas Hindborg <a.hindborg@xxxxxxxxxx>