Message ID | 9accb4ebd1247e2f2acc77dd053f67e60bf8d283.1687079502.git.christophe.jaillet@wanadoo.fr |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2376374vqr; Sun, 18 Jun 2023 02:49:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ67V+eiur63xNchl3ntcdNIOy7JYK6zLMW12eqNEc9AXADlREDv3K+M6NeJ9+TNlurDBmbD X-Received: by 2002:a17:902:e543:b0:1b1:d51c:f3f6 with SMTP id n3-20020a170902e54300b001b1d51cf3f6mr6850886plf.57.1687081766424; Sun, 18 Jun 2023 02:49:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687081766; cv=none; d=google.com; s=arc-20160816; b=NEzHEfF2McwxOHTLG6sFLVOu61GvpdtVzc27L/k+remY0cTbiuaVzrGorSnu3ccrrA CqctW1z8h9rmEZL3lRWPVfdJXBZMhZI56+6qXYxxKCQzpf1GCwergYUy8dhiCTE0NsAg UB1vlSLrJqP5mc8Y/PQyPRgleWOiBftrUxUQYuNzAjEWdcj2a++Z7lJa7A6eofq/NwPB igMpycNSjXjI79bWp8qHnKVyjfOrOh+Jyl2CyLgPTWscMwTYC1np24iKY3gNRNeC8kzw roqg7vdLuHOaEh6PbEmwEQg2kN+aY0pdQPP+7qfmP9nETa/2NiLfs6jnQwcH7u4n4TCk kU+w== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j6-20020a170903024600b001ae4c3bbb0dsi19819467plh.145.2023.06.18.02.49.14; Sun, 18 Jun 2023 02:49:26 -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 S229652AbjFRJMO (ORCPT <rfc822;duw91626@gmail.com> + 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 <rfc822;linux-kernel@vger.kernel.org>); 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 <linux-kernel@vger.kernel.org>; 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 <christophe.jaillet@wanadoo.fr> To: Jiri Kosina <jikos@kernel.org>, Benjamin Tissoires <benjamin.tissoires@redhat.com> Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET <christophe.jaillet@wanadoo.fr>, 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769033450732236739?= X-GMAIL-MSGID: =?utf-8?q?1769033450732236739?= |
Series |
HID: Reorder fields in 'struct hid_input'
|
|
Commit Message
Christophe JAILLET
June 18, 2023, 9:11 a.m. UTC
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 <christophe.jaillet@wanadoo.fr>
---
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(-)
Comments
On Sun, 18 Jun 2023, Christophe JAILLET wrote: > 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. Applied, thanks.
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 {