From nobody Fri Apr 3 03:01:55 2026 Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A00420DD75 for ; Wed, 25 Mar 2026 00:51:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774399893; cv=none; b=O7uLgwBvrwueWPWMdd8BJ1Z1k1IBCCP+7KGcEAwj7NAHcMBX1W8tB4BXORlkkVos+PR+bhQRt/3k0ucSCnBdEJ46JHMLtoBbkGZm6gMHwEL5CEN7ag6jq4ntWKPEjHrQOzaAOJzEcU6O+qi/pehWeyEDglmRmcQDN/Hb/wMpy4s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774399893; c=relaxed/simple; bh=XRVIgwc58JkWpAPH7KqwqozlTeVA5dZQ28Y/5SMWRuk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=XN9465d/r+mpm3tFpO4e/Eijq7RQ7A6cAA5QwOh83lcvyNNxPrQBf7QKSGomVHCd/pg7i4ewnu0akLGiD/OIzNpa3T/BkICh2+sewGC12sgQ7vz4aoP2tMLXS/1S8STu6jOGNhI/Ai+NCta5iWnbWvxO2Gk18lQUkGXI4BM3/OA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=pvoRR+5w; arc=none smtp.client-ip=209.85.216.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pvoRR+5w" Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-3590042fa8eso3904617a91.1 for ; Tue, 24 Mar 2026 17:51:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774399891; x=1775004691; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=RFuNadNUZFgtF+sP4Pga3iBRmMtaHmf3b1Z1WRL7Is8=; b=pvoRR+5wUAWmFRMJ6fCoaV4KyrEYSHElv6QRNBxP+qsSg/scmi00y6eDgQztsQrFb9 zxpEDXMPdCd2SMB108nlsR6vA/hFvAFkIUJtJ6Uv9x0PfDUTeIBoC889EoF1NJHPUzQm 5YWeGNsS5BxOLQjBi1wLBA9Ej4NyLgy+m7G2zPXr6Ai0U6+NyoElqYEnN3S3aHgrKRvu whkoK0tzAJA8w17fEuDX0ZTmYwbRuhrsHXJ4NBTe0iCMnaujpYxgDFR0H7psLM4vIFha PiuBWbvaP2gOmxXcAZASozFD3a2JLbRwQlO1T0/mcVBWuO9DUcTnrqxi862vOn7AaOlv aimQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774399891; x=1775004691; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=RFuNadNUZFgtF+sP4Pga3iBRmMtaHmf3b1Z1WRL7Is8=; b=mlHYFfMfux0q1pN27cMG+/SQcUDPJ89q6QO8oZQogqDi6zHTOLBhAWwB1nAphgXpnm j/cFfVcrCAa3mGcZT3Dj/PQxbhnpsHpkNWbf9A/ImNb06NicV775DWzKEVOU+TA+dcnF 0vXKG0lS/PkcPMcHO7L519ig+9h0beukGHbrmWm/9BR4HwxB82a3QdM4Meo7vKQz/fRM 3QaZSnBdp1fCNt65h4M2jKf6KwMR6V1yrBN/UbcdeDOzyDoZ2V1sp9hunK2Go2wNLV9A UnrqXffmMbnGVSdM54WEd+J1/tnFhtiqA+Evx04MddqKai0VUAyCN8rT/LIqQI0PGMoQ gJBQ== X-Forwarded-Encrypted: i=1; AJvYcCUiYQDM4f+YNwzNFKX1WpGq2+Y3fgmI8zXVjYOvPMgHywMWQswB9pCA5ZQ/+TRVOzdGtoQfYcuPCoEW2hM=@vger.kernel.org X-Gm-Message-State: AOJu0YxduKoI3xlwCxMEe9CYt1tzTsC2wfI4w7gAZW2c5zYXrY7BM/t8 Vt0e/GQbyWsTLSfw6vPLVf/83PoFmW8z6H/UXF0XQ7RvTry4SHBXT71d X-Gm-Gg: ATEYQzxKBHGH8TofesMyb7foPSaz1Cn2zd06RC7tepuDtO5k5MDUhxoQ38HkLiYa/rR QctGZBb0EnUu/oxuZ6rk0yXhyN37sg7Sp9vCr6YH0lRdmbFSWwwVWtBBqMrzKwKo9ERF/yu8ngE KWVj/XhLqn/HSg2Ua/lzWj02pV04QVGuIwSQuAE3qrByDqYmxwoxw6NdO1ZcPTw5v0wTL8cY2AJ W2rpaV9I0j8nkMx77ugyRmWiSTy68jINtG32/ZWSaKHpmA2v4h4wNr2Wemn9xTXJwGrdI5IwvO+ TGIvaJd4vmGK/lZfb0TiwF7r7piRLZICRww8d8t9akh0oUvOJD2FgiI5rP/MRoyHzl5+V5HOTYB 2LezP1+c9t7iBBvV2RfAmvACzlRfY68S6sXisetxOotnLYFHcuY0HdFTD51KgJR8XGeUBSQZliI ntEzgVas2Nt6KvwlbFXZui4s5BT93uoIWd9eJq1UIU X-Received: by 2002:a17:90b:3ecc:b0:353:356c:6821 with SMTP id 98e67ed59e1d1-35c0dcfc99fmr1179122a91.8.1774399891485; Tue, 24 Mar 2026 17:51:31 -0700 (PDT) Received: from toolbx.alistair23.me ([2403:581e:fdf9:0:6209:4521:6813:45b7]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-35c03211351sm3770972a91.15.2026.03.24.17.51.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Mar 2026 17:51:30 -0700 (PDT) From: alistair23@gmail.com X-Google-Original-From: alistair.francis@wdc.com To: dakr@kernel.org, ljs@kernel.org, vbabka@kernel.org, Liam.Howlett@oracle.com, urezki@gmail.com, ojeda@kernel.org, boqun@kernel.org, gary@garyguo.net, bjorn3_gh@protonmail.com, lossin@kernel.org, a.hindborg@kernel.org, aliceryhl@google.com, tmgross@umich.edu, tamird@kernel.org, work@onurozkan.dev, acourbot@nvidia.com, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Cc: alistair23@gmail.com, Alistair Francis Subject: [PATCH v2] rust: Mark all from() for Error functions inline Date: Wed, 25 Mar 2026 10:51:18 +1000 Message-ID: <20260325005118.168814-1-alistair.francis@wdc.com> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alistair Francis Mark all of the existing impl From<...> for Error { fn from(err: ...) -> Self { ... } } functions as `#[inline]` There was a recent request [1] to inline the simple from() Error functions to avoid the function call overhead. This patch inlines all of the functions (except for the pin-init) and converts one existing `inline(always)` to `inline` to match the styles. 1: https://lkml.org/lkml/2026/3/13/962 Signed-off-by: Alistair Francis Acked-by: Danilo Krummrich --- The pin-init changes have been submitted here instead: https://github.com/Rust-for-Linux/pin-init/pull/126 rust/kernel/alloc/kvec/errors.rs | 3 +++ rust/kernel/error.rs | 6 ++++++ rust/kernel/ptr/projection.rs | 2 +- rust/kernel/xarray.rs | 1 + rust/syn/error.rs | 1 + 5 files changed, 12 insertions(+), 1 deletion(-) diff --git a/rust/kernel/alloc/kvec/errors.rs b/rust/kernel/alloc/kvec/erro= rs.rs index e7de5049ee47..985c5f2c3962 100644 --- a/rust/kernel/alloc/kvec/errors.rs +++ b/rust/kernel/alloc/kvec/errors.rs @@ -15,6 +15,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { } =20 impl From> for Error { + #[inline] fn from(_: PushError) -> Error { // Returning ENOMEM isn't appropriate because the system is not ou= t of memory. The vector // is just full and we are refusing to resize it. @@ -32,6 +33,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { } =20 impl From for Error { + #[inline] fn from(_: RemoveError) -> Error { EINVAL } @@ -55,6 +57,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { } =20 impl From> for Error { + #[inline] fn from(_: InsertError) -> Error { EINVAL } diff --git a/rust/kernel/error.rs b/rust/kernel/error.rs index 258b12afdcba..935787c2a91c 100644 --- a/rust/kernel/error.rs +++ b/rust/kernel/error.rs @@ -216,36 +216,42 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Res= ult { } =20 impl From for Error { + #[inline] fn from(_: AllocError) -> Error { code::ENOMEM } } =20 impl From for Error { + #[inline] fn from(_: TryFromIntError) -> Error { code::EINVAL } } =20 impl From for Error { + #[inline] fn from(_: Utf8Error) -> Error { code::EINVAL } } =20 impl From for Error { + #[inline] fn from(_: LayoutError) -> Error { code::ENOMEM } } =20 impl From for Error { + #[inline] fn from(_: fmt::Error) -> Error { code::EINVAL } } =20 impl From for Error { + #[inline] fn from(e: core::convert::Infallible) -> Error { match e {} } diff --git a/rust/kernel/ptr/projection.rs b/rust/kernel/ptr/projection.rs index 140ea8e21617..7e37390da6c6 100644 --- a/rust/kernel/ptr/projection.rs +++ b/rust/kernel/ptr/projection.rs @@ -13,7 +13,7 @@ pub struct OutOfBound; =20 impl From for Error { - #[inline(always)] + #[inline] fn from(_: OutOfBound) -> Self { ERANGE } diff --git a/rust/kernel/xarray.rs b/rust/kernel/xarray.rs index a49d6db28845..46e5f43223fe 100644 --- a/rust/kernel/xarray.rs +++ b/rust/kernel/xarray.rs @@ -172,6 +172,7 @@ pub struct StoreError { } =20 impl From> for Error { + #[inline] fn from(value: StoreError) -> Self { value.error } diff --git a/rust/syn/error.rs b/rust/syn/error.rs index 6fa0faf7f4e4..636f07d56d05 100644 --- a/rust/syn/error.rs +++ b/rust/syn/error.rs @@ -405,6 +405,7 @@ impl Copy for SpanRange {} impl std::error::Error for Error {} =20 impl From for Error { + #[inline] fn from(err: LexError) -> Self { Error::new(err.span(), err) } --=20 2.53.0