[PATCH] xhci: Shrink struct xhci_interval_bw

From: Christophe JAILLET
Date: Fri Nov 03 2023 - 02:52:25 EST


The struct xhci_interval_bw can be reordered to shrink it from 40 to 32
bytes.
This makes sense because it is used in struct xhci_interval_bw_table in an
array of XHCI_MAX_INTERVAL (i.e. 16) values. So this struct is shrunk by
128 bytes and is more cacheline friendly.

On x86_64 we have:

struct xhci_interval_bw {
unsigned int num_packets; /* 0 4 */

/* XXX 4 bytes hole, try to pack */

struct list_head endpoints; /* 8 16 */
unsigned int overhead[3]; /* 24 12 */

/* size: 40, cachelines: 1, members: 3 */
/* sum members: 32, holes: 1, sum holes: 4 */
/* padding: 4 */
/* last cacheline: 40 bytes */
};

After the change:
struct xhci_interval_bw {
struct list_head endpoints; /* 0 16 */
unsigned int num_packets; /* 16 4 */
unsigned int overhead[3]; /* 20 12 */

/* size: 32, cachelines: 1, members: 3 */
/* last cacheline: 32 bytes */
};

Signed-off-by: Christophe JAILLET <christophe.jaillet@xxxxxxxxxx>
---
drivers/usb/host/xhci.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 3ea5c092bba7..0430646a3a05 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -956,13 +956,13 @@ enum xhci_overhead_type {
};

struct xhci_interval_bw {
- unsigned int num_packets;
/* Sorted by max packet size.
* Head of the list is the greatest max packet size.
*/
struct list_head endpoints;
/* How many endpoints of each speed are present. */
unsigned int overhead[3];
+ unsigned int num_packets;
};

#define XHCI_MAX_INTERVAL 16
--
2.34.1