[PATCH v3 4/4] x86/mce: Avoid unnecessary padding in struct mce_bank

From: Smita Koralahalli
Date: Fri Feb 11 2022 - 17:35:44 EST


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@xxxxxxx>
Reviewed-by: Yazen Ghannam <yazen.ghannam@xxxxxxx>
---
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