Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5059606rwd; Sun, 18 Jun 2023 04:48:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5bsAQCxrjXDnVOdjK/o8DDAs9+35Ia0PWdFxQXInsiyyysuxspMCuz8hjO+mGzQVMUrViW X-Received: by 2002:a17:903:1206:b0:1af:aafb:64c8 with SMTP id l6-20020a170903120600b001afaafb64c8mr5465918plh.21.1687088899559; Sun, 18 Jun 2023 04:48:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687088899; cv=none; d=google.com; s=arc-20160816; b=MNKWc4exUtBgNwAEWFtpKL+heF83hk4QDcneaKCkjn/sS6ta/3tI9W6F93TNSPL13m tZMR6C1bQ3xpRbacJjJaAW/dERBXW+9iUacGrdVC93nWGG7GeLh27a+BGq3kxd8JRk33 m5W99QXUx6zcr0YZOrd4PXQT+BlMdWZ2F0ezV3w6Dss8MnSpVD+jjHcx01+cAio3MlNa 9jZyR78ZX0k8cKkgDzqOTy4Q8idux5Vxi1dFHYles05Cajf7t801XxauxCGYCyTzNBQo r+vMzd7rQ4zEzEAgFsgEnX9edKntAEWMH7mqQsklkGEPpiDNbX2dumaRk8+UAltwY9GG 0+zw== 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=IPe57G4mt7sHUeZs/pUABOMlmfqc6SVR+qf56bLRvks=; b=d25lbJhnIgi+Qbrm2g6//U9KDh6DHn2436tdfClGwfuxDlRZQZAD2FvYfKmQJt+FJQ Brk0+GTMZ8aY5knNEZS3wsLu3meY06kitlidEm0c+qJgh74DPoXp7iDN8jpZcf5ybgfL t1Z+o541Ox67HFzdHQUlSDuuEdFPs0raHlbFwWv1H8DHLiwbFyTr1zs2NiIDMin7B53G IoS0XPxRvyY/mA5dqad0zJUqnSN+RDPnE3KZF9UcCO3VQUMx+LvuLrlHUhIYUBNMFTKf MAZMGgtLCeobyoX8LROLfiQa2SQMav7obxbMHR37yEi84Bw8ZoJ4OcS73fk9bfkzU4i4 4JYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=Kpb5qhNZ; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d7-20020a170902854700b001b3faf578b1si9410341plo.444.2023.06.18.04.48.07; Sun, 18 Jun 2023 04:48:19 -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=Kpb5qhNZ; 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 S229640AbjFRJMO (ORCPT + 99 others); Sun, 18 Jun 2023 05:12:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229453AbjFRJMN (ORCPT ); Sun, 18 Jun 2023 05:12:13 -0400 Received: from smtp.smtpout.orange.fr (smtp-26.smtpout.orange.fr [80.12.242.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA41713D for ; Sun, 18 Jun 2023 02:12:02 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id AoRzqEE3BtieiAoRzq4eJ0; Sun, 18 Jun 2023 11:12:00 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1687079520; bh=IPe57G4mt7sHUeZs/pUABOMlmfqc6SVR+qf56bLRvks=; h=From:To:Cc:Subject:Date; b=Kpb5qhNZDIssWIDn68TTP4Tmt80DSlHclMOIWdpIZT0pC5FFVX6Pechv3YIV1uw0w Q1yDvEg+KRz8A+1nEt12JP/wpzuDUSRP3xi6QPlZ/rAb/mB73LtXl/an1jth/hp+bK BNeB+VRtpkh+ZINb4gBTqCJ8VloBctPbKr45LxEOzjJ4ZcQ/m846Z4AECFudUqhGTt X6gcGASdqUsEnuy1REdF1y0e9uy4egbd4uTK1ry64wI6zAqVa/5ZHVpcxpknQZemBL OOus/XviwJyt4tacQ3DHR8A3kTp2LDumWhyetTKaquNND/xW1DX4tb12j+peK7EFTr vaDLe62D6yUng== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 18 Jun 2023 11:12:00 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Jiri Kosina , Benjamin Tissoires Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-input@vger.kernel.org Subject: [PATCH] HID: Reorder fields in 'struct hid_input' Date: Sun, 18 Jun 2023 11:11:58 +0200 Message-Id: <9accb4ebd1247e2f2acc77dd053f67e60bf8d283.1687079502.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FORGED_SPF_HELO,NO_DNS_FOR_FROM,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,T_SCC_BODY_TEXT_LINE, T_SPF_TEMPERROR autolearn=no 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 Group some variables based on their sizes to reduce hole and avoid padding. On x86_64, this shrinks the size of 'struct hid_input' from 72 to 64 bytes. It saves a few bytes of memory and is more cache-line friendly. Signed-off-by: Christophe JAILLET --- Using pahole Before: ====== struct hid_input { struct list_head list; /* 0 16 */ struct hid_report * report; /* 16 8 */ struct input_dev * input; /* 24 8 */ const char * name; /* 32 8 */ bool registered; /* 40 1 */ /* XXX 7 bytes hole, try to pack */ struct list_head reports; /* 48 16 */ /* --- cacheline 1 boundary (64 bytes) --- */ unsigned int application; /* 64 4 */ /* size: 72, cachelines: 2, members: 7 */ /* sum members: 61, holes: 1, sum holes: 7 */ /* padding: 4 */ /* last cacheline: 8 bytes */ }; After: ===== struct hid_input { struct list_head list; /* 0 16 */ struct hid_report * report; /* 16 8 */ struct input_dev * input; /* 24 8 */ const char * name; /* 32 8 */ struct list_head reports; /* 40 16 */ unsigned int application; /* 56 4 */ bool registered; /* 60 1 */ /* size: 64, cachelines: 1, members: 7 */ /* padding: 3 */ }; --- include/linux/hid.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/hid.h b/include/linux/hid.h index 5be5e671c263..d29c5de96a40 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -555,9 +555,9 @@ struct hid_input { struct hid_report *report; struct input_dev *input; const char *name; - bool registered; struct list_head reports; /* the list of reports */ unsigned int application; /* application usage for this input */ + bool registered; }; enum hid_type { -- 2.34.1