[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <9accb4ebd1247e2f2acc77dd053f67e60bf8d283.1687079502.git.christophe.jaillet@wanadoo.fr>
Date: Sun, 18 Jun 2023 11:11:58 +0200
From: Christophe JAILLET <christophe.jaillet@...adoo.fr>
To: Jiri Kosina <jikos@...nel.org>,
Benjamin Tissoires <benjamin.tissoires@...hat.com>
Cc: linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org,
Christophe JAILLET <christophe.jaillet@...adoo.fr>,
linux-input@...r.kernel.org
Subject: [PATCH] HID: Reorder fields in 'struct hid_input'
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@...adoo.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(-)
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
Powered by blists - more mailing lists