lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220211223442.254489-5-Smita.KoralahalliChannabasappa@amd.com>
Date:   Fri, 11 Feb 2022 16:34:42 -0600
From:   Smita Koralahalli <Smita.KoralahalliChannabasappa@....com>
To:     <x86@...nel.org>, <linux-edac@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>
CC:     Tony Luck <tony.luck@...el.com>,
        Dave Hansen <dave.hansen@...ux.intel.com>,
        "H . Peter Anvin" <hpa@...or.com>,
        James Morse <james.morse@....com>,
        Robert Richter <rric@...nel.org>,
        Yazen Ghannam <yazen.ghannam@....com>,
        Smita Koralahalli <Smita.KoralahalliChannabasappa@....com>
Subject: [PATCH v3 4/4] x86/mce: Avoid unnecessary padding in struct mce_bank

Include struct mce_bank member "init" in the bitfield by changing its type
from bool to get rid of unnecessary padding and to reduce the overall
struct size.

Outputs collected before and after the change.

$ pahole -C mce_bank arch/x86/kernel/cpu/mce/core.o

before:

	/* size: 24, cachelines: 1, members: 5 */
	/* bit holes: 1, sum bit holes: 62 bits */
	/* bit_padding: 2 bits */
	/* last cacheline: 24 bytes */

after:

	/* size: 16, cachelines: 1, members: 5 */
	/* last cacheline: 16 bytes */

No functional changes.

Signed-off-by: Smita Koralahalli <Smita.KoralahalliChannabasappa@....com>
Reviewed-by: Yazen Ghannam <yazen.ghannam@....com>
---
 arch/x86/kernel/cpu/mce/internal.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/cpu/mce/internal.h b/arch/x86/kernel/cpu/mce/internal.h
index 422387f8699d..0b0f55f0c585 100644
--- a/arch/x86/kernel/cpu/mce/internal.h
+++ b/arch/x86/kernel/cpu/mce/internal.h
@@ -177,13 +177,14 @@ extern struct mce_vendor_flags mce_flags;
 
 struct mce_bank {
 	u64			ctl;			/* subevents to enable */
-	bool			init;			/* initialise bank? */
+
+	__u64 init			: 1,		/* initialise bank? */
 
 	/*
 	 * (AMD) MCA_CONFIG[McaLsbInStatusSupported]: This bit indicates
 	 * the LSB field is found in MCA_STATUS, when set.
 	 */
-	__u64 lsb_in_status		: 1,
+	      lsb_in_status		: 1,
 
 	/*
 	 * (AMD) MCA_CONFIG[McaX]: This bit when set indicates a given
@@ -195,7 +196,7 @@ struct mce_bank {
 	 */
 	      mcax			: 1,
 
-	      __reserved_1		: 62;
+	      __reserved_1		: 61;
 };
 
 DECLARE_PER_CPU_READ_MOSTLY(struct mce_bank[MAX_NR_BANKS], mce_banks_array);
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ