From nobody Thu Apr 2 23:57:07 2026 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) (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 D88FF224B12 for ; Thu, 26 Mar 2026 02:04:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774490663; cv=none; b=hvA6nN5LVU0SL1TMtHZbIbLaoUmMK16ZPlkjpQ1RNlVMgCgFgif8k+0Li0hi1+Qydx4yD4iTP/Xki1rnAudL+0OmVZw4JOSlG3+RwTIC9RYzP3hgyIS6QaxHp2u2BjLTmOlyBFOHpSmY7YDWiLARVIW8+vOLFEqCQRo5oQPSXbM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774490663; c=relaxed/simple; bh=UbaLDdoKMZ1amHnNIq1ECQ8csN3V5qaNENCXbyH+3GE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=E/OGaCbqyAIHBmZLAMDsb+b+obI9fEww16G/yMU6SNEX6c+muv7olI41ULtRW33DscBZtjHO2vPneuJCswFsqjKJqQoh1fbyoqJOkMlpTfPKDwDpYAAIJcoBdtlKOY91jf30W0TypgSUymkm7NKsUU5li2NHaAf0/uHWptsYPrY= 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=QXBDQ15s; arc=none smtp.client-ip=209.85.216.51 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="QXBDQ15s" Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-35a1d4a095bso224359a91.0 for ; Wed, 25 Mar 2026 19:04:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774490661; x=1775095461; 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=iWl6PzFsmSICAmTCaN++hWfc9rZNO5qDABFfVl7uRzs=; b=QXBDQ15sKeO9iCayXFJunVp1HgAuL2cevoHs8nO6qPPmIwCBeC5xJnyoIf530w4iNt vS68V1AeUea0qMYV6e0zu7kX3dBGQnpApKh1BDq4sHOTWrPyjxr7eEy15GHvX2c0nvcV 9MwYp7oGHvnT/KibwhlYps/YSjlbkJIsFl4J7Z4B+BV1n80ISD71pdNQtbEFvCSolPJA JWj4HzE7eTaVuz1ISj1v531y41p5GnlfYjiMi/dIkbT5yrqJY/aQNYsDnwAdznrZvE+P cyoQV5JjUhVvvo0ah6cQyd40sIxMLbtO0DiwSSd14YF/jfen6HKksEaTEE2d0AVUme/u nWuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774490661; x=1775095461; 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=iWl6PzFsmSICAmTCaN++hWfc9rZNO5qDABFfVl7uRzs=; b=lxNUDu03RIJRsDAayyyk9A9LUdmcWaTlIO0z9lcuiVeRXjLc1wOvtNTbs0tYsxZAuR K/Ki1pixLyRFU63fgidMqm+EaUZRDJ5C7LzoWwx20qUepexzsj9ofVK4SiItRmMuKaAv sb1IIVSmVke9ZebYi0HqdnNRHBdVB9wAU14ZHo0/PaQj+JO4i8yMCg71Aj/+VhMGU7Fz T6Vz5Jpn19KHMoOLjQiWmpv6b0KpEOvrxg2JnRvTONyZqQnc5hn4tkPiCZUrUgVzlSB0 jD6IqosKdCkGDNdXtOWAEwDG40czszhl22TXLeSr0MOQ5XzlU2PgFsk0auk+ZsvNxaTX sZUQ== X-Forwarded-Encrypted: i=1; AJvYcCUPibQQwkKKDYvaVuV6d37fYmuEyBIaqKujjXG2pXZEHxHU/rkpSBeeDWSxb+8lnVL7SpRm3rLsCovG2M4=@vger.kernel.org X-Gm-Message-State: AOJu0YxAdFdWgCZxlZDM505yef3gZkEeliHr3cFIEHMmPrp3Voey/OaN D7rpPolvw24XdzCy12VZsnRsNP9Ze/im45tM7aO3gZFnaRLlVNxHL/gn X-Gm-Gg: ATEYQzy8+YlemveNakncf9LApm5yBFPQRqH/lv79geM9F/89UgbT8jlesb/lk8x5UWJ W7Rqtd1VvIprYpvZ1apSMGt8dLG5wsWd1kAtUX/HW7aEXHQKDdnuNT/EHvYXQqAHl8Bjxjz5oNT jLLHWPRzOKG73FofG5NmsZY+ZTYPbqBkuRNMMWX5UOE7kVDWo1U06c2Jl2qtdr8Q5AtD7LGjqV9 MdGTV7YQR/73NUfMrhY5ebZzbpGbxZccZnLvM+N/x7slSIBChgyNSmTbMxWTP/2x7+2XPyp9Mfc 8zxhRXjxLCJW5Rs/M0S/pktYFoRQ9FGZPnVSpWa3eWbPPV+/EVgC1cR5mjBYXfDIYhJ2tkQYJd1 lcpZY6tXXM0PM7DcmxlRlGRCs/duKbBZJvNKrzxRPnGRWWlDYB2ocMVlfpNyY3jyjYrKfsGE8mZ 3iqXOyRuqD3t7K7GKF2v2zewOHiSkAM32YheSmr4HZZQ== X-Received: by 2002:a17:90b:57e3:b0:34a:be93:72ee with SMTP id 98e67ed59e1d1-35c0d1451d7mr4561960a91.8.1774490661208; Wed, 25 Mar 2026 19:04:21 -0700 (PDT) Received: from toolbx.alistair23.me ([2403:581e:fdf9:0:6209:4521:6813:45b7]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-35c0eb4d780sm1571592a91.6.2026.03.25.19.04.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Mar 2026 19:04:20 -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 v3] rust: Mark all from() for Error functions inline Date: Thu, 26 Mar 2026 12:04:06 +1000 Message-ID: <20260326020406.1438210-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-initi and syn) and converts one existing `inline(always)` to `inline` to match the styles. Link: https://lore.kernel.org/all/CAH5fLggOnVguVErjySphX__vs3iYAo4O+J6hrXW5= 46JrWSq5ZA@mail.gmail.com/ [1] Signed-off-by: Alistair Francis Acked-by: Danilo Krummrich Acked-by: Andreas Hindborg --- v3: - Convert Link to use lore.kernel.org - Drop change to syn rust/kernel/alloc/kvec/errors.rs | 3 +++ rust/kernel/error.rs | 6 ++++++ rust/kernel/ptr/projection.rs | 2 +- rust/kernel/xarray.rs | 1 + 4 files changed, 11 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 } --=20 2.53.0