From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B12B71A9F90; Thu, 11 Jun 2026 19:06:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781204775; cv=none; b=qj/AecIPrwfzGLa0vXM1TTPjEXdnflmLyRclOXFqJDw2iPWhu4+lcc692Z8LOKdZifCe2MN2ce1Mkm32kW1v0j3HVL23r2MKhsRCRW63HGqf7qc2m614UUEIlD7ueYTcvZfjmJ1iVd8KCInqnTx/INPDVEcDruOKbKP/LQmnHVo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781204775; c=relaxed/simple; bh=8qSULLYmSCouVStN8m1gqTOVYEvomiNvVqwPxOUSwyw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=VPHdIJAv7fVEkjy7eew4PyCQbhwIZru+wzmFDThNtTB4408M/t3IWFd7o36VhTgU4dIDvkKMTCWGy+yoC5Y9zFTXaPRVNf0eoBSZoEt4wz0EW73Y2/R5s6C9iABXeXgIqSIhx2u1gvqwmRE9UwOmT110itDQM+ryAQa7PrsOA+8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=C/qCcCd/; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="C/qCcCd/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EAC5F1F000E9; Thu, 11 Jun 2026 19:06:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1781204774; bh=tT37U2Phf5KPoTCYaf29T4VleYMXPAlLxxrfPU67YBc=; h=From:To:Cc:Subject:Date:Reply-To; b=C/qCcCd/scxpNMk8IttW9nStjUn2EoGnLMZvGf6yeOAymo8OxMg8TNO4YS8vWCv4v GqdSew96Ms+zcVL+rdomSkvWskFDMyAhmGqy6WRHmt9VcFFipUqKTVKpgFvidMqBaR kVtDcE0Klq1LLIr6gL1Tw/eCrQgiuBv9ZCIEgQy/46ATNeO4ba7dRhNa5nqzxwnfe6 FN75Fz5oE5IFGlufg/HrfRRLp9hL/qWxpjH5pPH7r9m/knuwUVzkiCuUIvXpx19IFQ blcAI99nBCJ+5YXUjtUIGE43QRfuxj4vfeQEWR/brSzNnd6a0zFLEXCI5+0UM+GrQq ObzrEi7wHdL4A== From: Gary Guo To: Alexandre Courbot , Yury Norov , Miguel Ojeda , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] rust: bitfield: mark `Debug` impl as `#[inline]` Date: Thu, 11 Jun 2026 20:05:54 +0100 Message-ID: <20260611190555.2298991-1-gary@kernel.org> X-Mailer: git-send-email 2.54.0 Reply-To: Gary Guo Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Gary Guo A `Debug` impl is for debugging and is normally not used, and therefore should ideally not be code-generated unless used. However, Rust has no way of knowing if a dependent crate is going to use the trait impl or not, so unless it is marked as `#[inline]`, it will be code-generated in the defining crate (as it is not generic). Mark the impl generated by bitfield macro `#[inline]`, so they do not stay in the binary unless used. This reduces nova-core.o .text by 17% (from 151922 bytes to 125676 bytes). Signed-off-by: Gary Guo --- rust/kernel/bitfield.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/rust/kernel/bitfield.rs b/rust/kernel/bitfield.rs index 554a5a2ff0ab..35ede53f2b8e 100644 --- a/rust/kernel/bitfield.rs +++ b/rust/kernel/bitfield.rs @@ -535,6 +535,7 @@ const fn [<__with_ $field>]( // `Debug` implementation. (@debug $name:ident { $($field:ident;)* }) => { impl ::kernel::fmt::Debug for $name { + #[inline] fn fmt(&self, f: &mut ::kernel::fmt::Formatter<'_>) -> ::kernel::fmt::Result { f.debug_struct(stringify!($name)) .field("", &::kernel::prelude::fmt!("{:#x}", self.inner)) base-commit: 7f07865bda5f5770d2f7927bc76cb2b4acd46074 -- 2.54.0