From patchwork Sun Jun 18 20:52:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 109683 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2648601vqr; Sun, 18 Jun 2023 14:35:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7l0K5pana2tB9FNsfT3NxBBxPVt+WdHa8jEdH/ZGFr+yrzMPEtCgQhjpldpePgXPJlhoI1 X-Received: by 2002:a17:902:eb42:b0:1a1:b3bb:cd5b with SMTP id i2-20020a170902eb4200b001a1b3bbcd5bmr8359095pli.62.1687124127260; Sun, 18 Jun 2023 14:35:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687124127; cv=none; d=google.com; s=arc-20160816; b=Itozj1GG1C20zTCkl/F2vBFaaoUBUVBifInsGbha2vHRVfIJFqv777MljIZwmYDoWT KT1EkdUV+wM/DbIbRp2Z+3JJSAS8Kok7YAMf1FGqZ3hWnkv85OLc+QRdtGr2eYPA726L gR9AM2CPAEaasYOWwBn0yeLQBD5UamphKzw0xw+nX3Fv5VNhxBFR4IfiM5SqtbLGNMUW R9qgbr0lLBYBvndqLohfxeyW6KXc5HGq8XE0YbOuOc3zi2ihOgueYAKyOjkD4KYjVokm TIH5nEUsPzXiamzYtnzPaneVLzQES/wE1us9a8KYBqfRbR5NaOS4yN64cX8pthefNjdO j9FA== 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:dkim-signature; bh=hfE30K9IK7rXEnDLZJeVX8ddHPQiVgEhsGvxibEOfaw=; b=ocKTM3TP6tPhO/q21HvG5gFynwqaZBA0u+H5yhoYjZXj9XCBXKqjRajVPmPt59KM56 hASa2H+rZ2943m3fE0d49XgcoQK122ZedHOvEP1febmlz04xFdGFUeAxkxHBKezbWogy JfZgocisUzP4P1yuJLqsvYRmDRMqQENg1SEivZaOK1lZ8wYwcL7/SknOnfI0dSdn3Qzk NRJWBBwwRxvVUVbhwi/4sLANMAt/lr24NgsiMj6sTp+vNg/k3keNVMnhIi05Obvf35GV rFKyVsySveEe1vtx3rjo1VSiLj0mZxJBsTUScCJMO5Jr8lQ2puN3QoJdgPiwmfous/Lg VS+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=bwidpUFg; 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 z6-20020a170903018600b001aaf78f7a95si9457741plg.101.2023.06.18.14.35.12; Sun, 18 Jun 2023 14:35:27 -0700 (PDT) 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; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=bwidpUFg; 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 S229605AbjFRUyM (ORCPT + 99 others); Sun, 18 Jun 2023 16:54:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229482AbjFRUyL (ORCPT ); Sun, 18 Jun 2023 16:54:11 -0400 Received: from smtp.smtpout.orange.fr (smtp-20.smtpout.orange.fr [80.12.242.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85F89E68 for ; Sun, 18 Jun 2023 13:53:47 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id AzNvqYsw5LSaaAzNvqfd41; Sun, 18 Jun 2023 22:52:32 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1687121552; bh=hfE30K9IK7rXEnDLZJeVX8ddHPQiVgEhsGvxibEOfaw=; h=From:To:Cc:Subject:Date; b=bwidpUFgI5FGBLro01LZRgpEap6F3W1IkW3seMmj5UxJFMSQriDW4ce4ecJekQVmE /F4Daw9LSApRqZlPO5WvJxYlH9/0OCOp+KmMSkuopDvXrII04NEDSYaexqdEjmxcya JNNe1Qb0dVIu21NrGyL6g5PQNlw+tnFIKL8Z3AjXAmCLK3Ellvdh0PT6B6uzB65ogz ciyULM4rnNFOD0fE4xlYctcSZxbtRFHSi9UO1AYIHGyxJvcLcxPxVVvhYdbQoa7hqb VALI6p0MFdPLrzmVcZvp176RdPifi5QqpHmevB5PM0UUPbeDdcqd+r4IFlbnWecMWm QiJfraQOT5gvA== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 18 Jun 2023 22:52:32 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: deller@gmx.de Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH] video/hdmi: Reorder fields in 'struct hdmi_avi_infoframe' Date: Sun, 18 Jun 2023 22:52:28 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE 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?1769077868855217701?= X-GMAIL-MSGID: =?utf-8?q?1769077868855217701?= Group some variables based on their sizes to reduce hole and avoid padding. On x86_64, this shrinks the size of 'struct hdmi_avi_infoframe' from 68 to 60 bytes. It saves a few bytes of memory and is more cache-line friendly. This also reduces the union hdmi_infoframe the same way. Signed-off-by: Christophe JAILLET --- Using pahole Before: ====== struct hdmi_avi_infoframe { enum hdmi_infoframe_type type; /* 0 4 */ unsigned char version; /* 4 1 */ unsigned char length; /* 5 1 */ /* XXX 2 bytes hole, try to pack */ enum hdmi_colorspace colorspace; /* 8 4 */ enum hdmi_scan_mode scan_mode; /* 12 4 */ enum hdmi_colorimetry colorimetry; /* 16 4 */ enum hdmi_picture_aspect picture_aspect; /* 20 4 */ enum hdmi_active_aspect active_aspect; /* 24 4 */ bool itc; /* 28 1 */ /* XXX 3 bytes hole, try to pack */ enum hdmi_extended_colorimetry extended_colorimetry; /* 32 4 */ enum hdmi_quantization_range quantization_range; /* 36 4 */ enum hdmi_nups nups; /* 40 4 */ unsigned char video_code; /* 44 1 */ /* XXX 3 bytes hole, try to pack */ enum hdmi_ycc_quantization_range ycc_quantization_range; /* 48 4 */ enum hdmi_content_type content_type; /* 52 4 */ unsigned char pixel_repeat; /* 56 1 */ /* XXX 1 byte hole, try to pack */ short unsigned int top_bar; /* 58 2 */ short unsigned int bottom_bar; /* 60 2 */ short unsigned int left_bar; /* 62 2 */ /* --- cacheline 1 boundary (64 bytes) --- */ short unsigned int right_bar; /* 64 2 */ /* size: 68, cachelines: 2, members: 20 */ /* sum members: 57, holes: 4, sum holes: 9 */ /* padding: 2 */ /* last cacheline: 4 bytes */ }; After: ===== struct hdmi_avi_infoframe { enum hdmi_infoframe_type type; /* 0 4 */ unsigned char version; /* 4 1 */ unsigned char length; /* 5 1 */ bool itc; /* 6 1 */ unsigned char pixel_repeat; /* 7 1 */ enum hdmi_colorspace colorspace; /* 8 4 */ enum hdmi_scan_mode scan_mode; /* 12 4 */ enum hdmi_colorimetry colorimetry; /* 16 4 */ enum hdmi_picture_aspect picture_aspect; /* 20 4 */ enum hdmi_active_aspect active_aspect; /* 24 4 */ enum hdmi_extended_colorimetry extended_colorimetry; /* 28 4 */ enum hdmi_quantization_range quantization_range; /* 32 4 */ enum hdmi_nups nups; /* 36 4 */ unsigned char video_code; /* 40 1 */ /* XXX 3 bytes hole, try to pack */ enum hdmi_ycc_quantization_range ycc_quantization_range; /* 44 4 */ enum hdmi_content_type content_type; /* 48 4 */ short unsigned int top_bar; /* 52 2 */ short unsigned int bottom_bar; /* 54 2 */ short unsigned int left_bar; /* 56 2 */ short unsigned int right_bar; /* 58 2 */ /* size: 60, cachelines: 1, members: 20 */ /* sum members: 57, holes: 1, sum holes: 3 */ /* last cacheline: 60 bytes */ }; --- include/linux/hdmi.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/hdmi.h b/include/linux/hdmi.h index 2f4dcc8d060e..3bb87bf6bc65 100644 --- a/include/linux/hdmi.h +++ b/include/linux/hdmi.h @@ -170,19 +170,19 @@ struct hdmi_avi_infoframe { enum hdmi_infoframe_type type; unsigned char version; unsigned char length; + bool itc; + unsigned char pixel_repeat; enum hdmi_colorspace colorspace; enum hdmi_scan_mode scan_mode; enum hdmi_colorimetry colorimetry; enum hdmi_picture_aspect picture_aspect; enum hdmi_active_aspect active_aspect; - bool itc; enum hdmi_extended_colorimetry extended_colorimetry; enum hdmi_quantization_range quantization_range; enum hdmi_nups nups; unsigned char video_code; enum hdmi_ycc_quantization_range ycc_quantization_range; enum hdmi_content_type content_type; - unsigned char pixel_repeat; unsigned short top_bar; unsigned short bottom_bar; unsigned short left_bar;