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: 58491 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp822505wrn; Fri, 17 Feb 2023 03:03:20 -0800 (PST) X-Google-Smtp-Source: AK7set8SgmoZnsT3gaR0kuFnQZfZgYmxq6tp94TJD9x68XfVwiLj1Fl23WULHkoIxzcHM2yIGQPX X-Received: by 2002:a50:fb8e:0:b0:4aa:a4f0:2c17 with SMTP id e14-20020a50fb8e000000b004aaa4f02c17mr1026191edq.4.1676631799944; Fri, 17 Feb 2023 03:03:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676631799; cv=none; d=google.com; s=arc-20160816; b=pOa71n4EsgZwfSwaDpm1MLAduDI+HC3qVAs9UHHS+l2nPJiK6CUk9oz4HvyfMaqZwN fexkvwpS+e3CtEtpnBEjtNmemEt4Oc2AUnmDUOpZHp/veLpHgEYPi5Dn07/55C5jpjWm w4wBVnVkzSGMNcvAudErH8s7k3ElBLAlbABeUW7M/sDvrH6zknSkKlNB7oahEcux0Ch8 jei43QXR/W7PylGtpef1Gb8AHJ3pQ8EUd/ACXLuRnRas66oi7MQnQN6P80pgDr9pxmH/ rgdmkr/f7zMg4SI9jq0EeqUPdb3msrBzKrnu6xUMuRvV484w4vt3xLCReM8Mamn/JqiU HYow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=oJNYKs/MWqf2DHToRjwPOf4VaeZKpJ2IHNp3PihDxBA=; b=Yl3eDIJcbo+DK9RFLk0J+krZLeiGDZWOui1uTCmbdW5kddcMJ+32MjWSyI1QUQoW+G efH9xXiHV+r/qozRGhUSGjrwtB1sPIhGbv4p53W7KPaYWDISAweIYvf5gnVtxN+2bfOc 6Ywt4yaevO9OTH8R4RCTpmMhumW3jyoT6ksn+uH1uY7+YCQxztznvOQINMmLXJudzPEG 3OAv40iFAbAAmH2KWT+pZTxrU7v15Eyf87rOmBPKWqV/h7DYKn9Yt/lqSOWW4UiDiq2a dw1MoVtEYkkdVK40gfqd5wtI+MW5yJSA91oePSAKPl3tAEbvheDUHM0is04WR3sS5AAa BqKg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y8-20020aa7ccc8000000b004acbda41e46si5127724edt.453.2023.02.17.03.02.56; Fri, 17 Feb 2023 03:03:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229657AbjBQK7T (ORCPT + 99 others); Fri, 17 Feb 2023 05:59:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229558AbjBQK7P (ORCPT ); Fri, 17 Feb 2023 05:59:15 -0500 Received: from smtp.smtpout.orange.fr (smtp-23.smtpout.orange.fr [80.12.242.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFE4C3028D for ; Fri, 17 Feb 2023 02:59:13 -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 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758075866534144828?= X-GMAIL-MSGID: =?utf-8?q?1758075866534144828?= 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;