From patchwork Fri Feb 17 10:59:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 13144583 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 76772C05027 for ; Fri, 17 Feb 2023 11:29:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230160AbjBQL3g (ORCPT ); Fri, 17 Feb 2023 06:29:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230156AbjBQL3d (ORCPT ); Fri, 17 Feb 2023 06:29:33 -0500 X-Greylist: delayed 1811 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Fri, 17 Feb 2023 03:29:24 PST Received: from smtp.smtpout.orange.fr (smtp-24.smtpout.orange.fr [80.12.242.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C5ABF656A0 for ; Fri, 17 Feb 2023 03:29:24 -0800 (PST) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id SySNpfME7qIOtSySNpIV5M; Fri, 17 Feb 2023 11:59:11 +0100 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Fri, 17 Feb 2023 11:59:11 +0100 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: "Rafael J. Wysocki" , Len Brown Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-acpi@vger.kernel.org Subject: [PATCH] ACPI: video: Reorder fields in 'struct acpi_video_device' Date: Fri, 17 Feb 2023 11:59:08 +0100 Message-Id: <6b868520dac20434296b6282496d3234fae01115.1676631473.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Group some variables based on their sizes to reduce hole and avoid padding. On x86_64, this shrinks the size of 'struct acpi_video_device' from 264 to 256 bytes. This size is much better when the struct is kmalloc()'ed. Signed-off-by: Christophe JAILLET --- Using pahole Before: ====== struct acpi_video_device { long unsigned int device_id; /* 0 8 */ struct acpi_video_device_flags flags; /* 8 1 */ struct acpi_video_device_cap cap; /* 9 1 */ /* XXX 6 bytes hole, try to pack */ struct list_head entry; /* 16 16 */ struct delayed_work switch_brightness_work; /* 32 184 */ /* XXX last struct has 4 bytes of padding */ /* --- cacheline 3 boundary (192 bytes) was 24 bytes ago --- */ int switch_brightness_event; /* 216 4 */ /* XXX 4 bytes hole, try to pack */ struct acpi_video_bus * video; /* 224 8 */ struct acpi_device * dev; /* 232 8 */ struct acpi_video_device_brightness * brightness; /* 240 8 */ struct backlight_device * backlight; /* 248 8 */ /* --- cacheline 4 boundary (256 bytes) --- */ struct thermal_cooling_device * cooling_dev; /* 256 8 */ /* size: 264, cachelines: 5, members: 11 */ /* sum members: 254, holes: 2, sum holes: 10 */ /* paddings: 1, sum paddings: 4 */ /* last cacheline: 8 bytes */ }; After: ===== struct acpi_video_device { long unsigned int device_id; /* 0 8 */ struct list_head entry; /* 8 16 */ struct acpi_video_device_flags flags; /* 24 1 */ struct acpi_video_device_cap cap; /* 25 1 */ /* XXX 2 bytes hole, try to pack */ int switch_brightness_event; /* 28 4 */ struct delayed_work switch_brightness_work; /* 32 184 */ /* XXX last struct has 4 bytes of padding */ /* --- cacheline 3 boundary (192 bytes) was 24 bytes ago --- */ struct acpi_video_bus * video; /* 216 8 */ struct acpi_device * dev; /* 224 8 */ struct acpi_video_device_brightness * brightness; /* 232 8 */ struct backlight_device * backlight; /* 240 8 */ struct thermal_cooling_device * cooling_dev; /* 248 8 */ /* size: 256, cachelines: 4, members: 11 */ /* sum members: 254, holes: 1, sum holes: 2 */ /* paddings: 1, sum paddings: 4 */ }; --- drivers/acpi/acpi_video.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c index 97b711e57bff..1118dd7dbf6c 100644 --- a/drivers/acpi/acpi_video.c +++ b/drivers/acpi/acpi_video.c @@ -202,11 +202,11 @@ struct acpi_video_device_cap { struct acpi_video_device { unsigned long device_id; + struct list_head entry; struct acpi_video_device_flags flags; struct acpi_video_device_cap cap; - struct list_head entry; - struct delayed_work switch_brightness_work; int switch_brightness_event; + struct delayed_work switch_brightness_work; struct acpi_video_bus *video; struct acpi_device *dev; struct acpi_video_device_brightness *brightness;