From: Marc Kleine-Budde <mkl@pengutronix.de>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, kuba@kernel.org, linux-can@vger.kernel.org,
kernel@pengutronix.de,
Vincent Mailhol <mailhol.vincent@wanadoo.fr>,
Marc Kleine-Budde <mkl@pengutronix.de>
Subject: [net-next 07/39] can: dev: reorder struct can_priv members for better packing
Date: Tue, 30 Mar 2021 13:45:27 +0200 [thread overview]
Message-ID: <20210330114559.1114855-8-mkl@pengutronix.de> (raw)
In-Reply-To: <20210330114559.1114855-1-mkl@pengutronix.de>
From: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Save eight bytes of holes on x86-64 architectures by reordering struct
can_priv members.
Before:
$ pahole -C can_priv drivers/net/can/dev/dev.o
struct can_priv {
struct net_device * dev; /* 0 8 */
struct can_device_stats can_stats; /* 8 24 */
struct can_bittiming bittiming; /* 32 32 */
/* --- cacheline 1 boundary (64 bytes) --- */
struct can_bittiming data_bittiming; /* 64 32 */
const struct can_bittiming_const * bittiming_const; /* 96 8 */
const struct can_bittiming_const * data_bittiming_const; /* 104 8 */
struct can_tdc tdc; /* 112 12 */
/* XXX 4 bytes hole, try to pack */
/* --- cacheline 2 boundary (128 bytes) --- */
const struct can_tdc_const * tdc_const; /* 128 8 */
const u16 * termination_const; /* 136 8 */
unsigned int termination_const_cnt; /* 144 4 */
u16 termination; /* 148 2 */
/* XXX 2 bytes hole, try to pack */
const u32 * bitrate_const; /* 152 8 */
unsigned int bitrate_const_cnt; /* 160 4 */
/* XXX 4 bytes hole, try to pack */
const u32 * data_bitrate_const; /* 168 8 */
unsigned int data_bitrate_const_cnt; /* 176 4 */
u32 bitrate_max; /* 180 4 */
struct can_clock clock; /* 184 4 */
enum can_state state; /* 188 4 */
/* --- cacheline 3 boundary (192 bytes) --- */
u32 ctrlmode; /* 192 4 */
u32 ctrlmode_supported; /* 196 4 */
u32 ctrlmode_static; /* 200 4 */
int restart_ms; /* 204 4 */
struct delayed_work restart_work; /* 208 168 */
/* XXX last struct has 4 bytes of padding */
/* --- cacheline 5 boundary (320 bytes) was 56 bytes ago --- */
int (*do_set_bittiming)(struct net_device *); /* 376 8 */
/* --- cacheline 6 boundary (384 bytes) --- */
int (*do_set_data_bittiming)(struct net_device *); /* 384 8 */
int (*do_set_mode)(struct net_device *, enum can_mode); /* 392 8 */
int (*do_set_termination)(struct net_device *, u16); /* 400 8 */
int (*do_get_state)(const struct net_device *, enum can_state *); /* 408 8 */
int (*do_get_berr_counter)(const struct net_device *, struct can_berr_counter *); /* 416 8 */
unsigned int echo_skb_max; /* 424 4 */
/* XXX 4 bytes hole, try to pack */
struct sk_buff * * echo_skb; /* 432 8 */
/* size: 440, cachelines: 7, members: 31 */
/* sum members: 426, holes: 4, sum holes: 14 */
/* paddings: 1, sum paddings: 4 */
/* last cacheline: 56 bytes */
};
After:
$ pahole -C can_priv drivers/net/can/dev/dev.o
struct can_priv {
struct net_device * dev; /* 0 8 */
struct can_device_stats can_stats; /* 8 24 */
const struct can_bittiming_const * bittiming_const; /* 32 8 */
const struct can_bittiming_const * data_bittiming_const; /* 40 8 */
struct can_bittiming bittiming; /* 48 32 */
/* --- cacheline 1 boundary (64 bytes) was 16 bytes ago --- */
struct can_bittiming data_bittiming; /* 80 32 */
const struct can_tdc_const * tdc_const; /* 112 8 */
struct can_tdc tdc; /* 120 12 */
/* --- cacheline 2 boundary (128 bytes) was 4 bytes ago --- */
unsigned int bitrate_const_cnt; /* 132 4 */
const u32 * bitrate_const; /* 136 8 */
const u32 * data_bitrate_const; /* 144 8 */
unsigned int data_bitrate_const_cnt; /* 152 4 */
u32 bitrate_max; /* 156 4 */
struct can_clock clock; /* 160 4 */
unsigned int termination_const_cnt; /* 164 4 */
const u16 * termination_const; /* 168 8 */
u16 termination; /* 176 2 */
/* XXX 2 bytes hole, try to pack */
enum can_state state; /* 180 4 */
u32 ctrlmode; /* 184 4 */
u32 ctrlmode_supported; /* 188 4 */
/* --- cacheline 3 boundary (192 bytes) --- */
u32 ctrlmode_static; /* 192 4 */
int restart_ms; /* 196 4 */
struct delayed_work restart_work; /* 200 168 */
/* XXX last struct has 4 bytes of padding */
/* --- cacheline 5 boundary (320 bytes) was 48 bytes ago --- */
int (*do_set_bittiming)(struct net_device *); /* 368 8 */
int (*do_set_data_bittiming)(struct net_device *); /* 376 8 */
/* --- cacheline 6 boundary (384 bytes) --- */
int (*do_set_mode)(struct net_device *, enum can_mode); /* 384 8 */
int (*do_set_termination)(struct net_device *, u16); /* 392 8 */
int (*do_get_state)(const struct net_device *, enum can_state *); /* 400 8 */
int (*do_get_berr_counter)(const struct net_device *, struct can_berr_counter *); /* 408 8 */
unsigned int echo_skb_max; /* 416 4 */
/* XXX 4 bytes hole, try to pack */
struct sk_buff * * echo_skb; /* 424 8 */
/* size: 432, cachelines: 7, members: 31 */
/* sum members: 426, holes: 2, sum holes: 6 */
/* paddings: 1, sum paddings: 4 */
/* last cacheline: 48 bytes */
};
Link: https://lore.kernel.org/r/20210224002008.4158-3-mailhol.vincent@wanadoo.fr
Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
include/linux/can/dev.h | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h
index 4795da0eb949..27b275e463da 100644
--- a/include/linux/can/dev.h
+++ b/include/linux/can/dev.h
@@ -39,22 +39,23 @@ struct can_priv {
struct net_device *dev;
struct can_device_stats can_stats;
- struct can_bittiming bittiming, data_bittiming;
const struct can_bittiming_const *bittiming_const,
*data_bittiming_const;
- struct can_tdc tdc;
+ struct can_bittiming bittiming, data_bittiming;
const struct can_tdc_const *tdc_const;
+ struct can_tdc tdc;
- const u16 *termination_const;
- unsigned int termination_const_cnt;
- u16 termination;
- const u32 *bitrate_const;
unsigned int bitrate_const_cnt;
+ const u32 *bitrate_const;
const u32 *data_bitrate_const;
unsigned int data_bitrate_const_cnt;
u32 bitrate_max;
struct can_clock clock;
+ unsigned int termination_const_cnt;
+ const u16 *termination_const;
+ u16 termination;
+
enum can_state state;
/* CAN controller features - see include/uapi/linux/can/netlink.h */
--
2.30.2
next prev parent reply other threads:[~2021-03-30 11:46 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-30 11:45 pull-request: can-next 2021-03-30 Marc Kleine-Budde
2021-03-30 11:45 ` [net-next 01/39] MAINTAINERS: remove Dan Murphy from m_can and tcan4x5x Marc Kleine-Budde
2021-03-30 20:10 ` patchwork-bot+netdevbpf
2021-03-30 11:45 ` [net-next 02/39] MAINTAINERS: Update MCAN MMIO device driver maintainer Marc Kleine-Budde
2021-03-30 11:45 ` [net-next 03/39] can: dev: always create TX echo skb Marc Kleine-Budde
2021-03-30 11:45 ` [net-next 04/39] can: dev: can_free_echo_skb(): don't crash the kernel if can_priv::echo_skb is accessed out of bounds Marc Kleine-Budde
2021-03-30 11:45 ` [net-next 05/39] can: dev: can_free_echo_skb(): extend to return can frame length Marc Kleine-Budde
2021-03-30 11:45 ` [net-next 06/39] can: add new CAN FD bittiming parameters: Transmitter Delay Compensation (TDC) Marc Kleine-Budde
2021-03-30 11:45 ` Marc Kleine-Budde [this message]
2021-03-30 11:45 ` [net-next 08/39] can: netlink: move '=' operators back to previous line (checkpatch fix) Marc Kleine-Budde
2021-03-30 11:45 ` [net-next 09/39] can: bittiming: add calculation for CAN FD Transmitter Delay Compensation (TDC) Marc Kleine-Budde
2021-03-30 11:45 ` [net-next 10/39] can: bittiming: add CAN_KBPS, CAN_MBPS and CAN_MHZ macros Marc Kleine-Budde
2021-03-30 11:45 ` [net-next 11/39] can: grcan: add missing Kconfig dependency to HAS_IOMEM Marc Kleine-Budde
2021-03-30 11:45 ` [net-next 12/39] can: xilinx_can: Simplify code by using dev_err_probe() Marc Kleine-Budde
2021-03-30 11:45 ` [net-next 13/39] can: ucan: fix alignment constraints Marc Kleine-Budde
2021-03-30 11:45 ` [net-next 14/39] can: peak_usb: pcan_usb_pro_encode_msg(): use macros for flags instead of plain integers Marc Kleine-Budde
2021-03-30 11:45 ` [net-next 15/39] can: peak_usb: add support of ethtool set_phys_id() Marc Kleine-Budde
2021-03-30 11:45 ` [net-next 16/39] can: peak_usb: add support of ONE_SHOT mode Marc Kleine-Budde
2021-03-30 11:45 ` [net-next 17/39] can: m_can: m_can_class_allocate_dev(): remove impossible error return judgment Marc Kleine-Budde
2021-03-30 11:45 ` [net-next 18/39] can: m_can: add infrastructure for internal timestamps Marc Kleine-Budde
2021-03-30 11:45 ` [net-next 19/39] can: m_can: m_can_chip_config(): enable and configure " Marc Kleine-Budde
2021-03-30 11:45 ` [net-next 20/39] can: m_can: fix periph RX path: use rx-offload to ensure skbs are sent from softirq context Marc Kleine-Budde
2021-03-30 11:45 ` [net-next 21/39] can: tcan4x5x: remove duplicate include of regmap.h Marc Kleine-Budde
2021-03-30 11:45 ` [net-next 22/39] can: mcp251xfd: add dev coredump support Marc Kleine-Budde
2021-03-30 11:45 ` [net-next 23/39] can: mcp251xfd: simplify UINC handling Marc Kleine-Budde
2021-03-30 11:45 ` [net-next 24/39] can: mcp251xfd: move netdevice.h to mcp251xfd.h Marc Kleine-Budde
2021-03-30 11:45 ` [net-next 25/39] can: mcp251xfd: mcp251xfd_get_timestamp(): move " Marc Kleine-Budde
2021-03-30 11:45 ` [net-next 26/39] can: mcp251xfd: add HW timestamp infrastructure Marc Kleine-Budde
2021-03-30 11:45 ` [net-next 27/39] can: mcp251xfd: add HW timestamp to RX, TX and error CAN frames Marc Kleine-Budde
2021-03-30 11:45 ` [net-next 28/39] can: c_can: convert block comments to network style comments Marc Kleine-Budde
2021-03-30 11:45 ` [net-next 29/39] can: c_can: remove unnecessary blank lines and add suggested ones Marc Kleine-Budde
2021-03-30 11:45 ` [net-next 30/39] can: c_can: fix indention Marc Kleine-Budde
2021-03-30 11:45 ` [net-next 31/39] can: c_can: fix print formating string Marc Kleine-Budde
2021-03-30 11:45 ` [net-next 32/39] can: c_can: replace double assignments by two single ones Marc Kleine-Budde
2021-03-30 11:45 ` [net-next 33/39] can: c_can: fix remaining checkpatch warnings Marc Kleine-Budde
2021-03-30 11:45 ` [net-next 34/39] can: c_can: remove unused code Marc Kleine-Budde
2021-03-30 11:45 ` [net-next 35/39] can: c_can: fix indentation Marc Kleine-Budde
2021-03-30 11:45 ` [net-next 36/39] can: c_can: add a comment about IF_RX interface's use Marc Kleine-Budde
2021-03-30 11:45 ` [net-next 37/39] can: c_can: use 32-bit write to set arbitration register Marc Kleine-Budde
2021-03-30 11:45 ` [net-next 38/39] can: c_can: prepare to up the message objects number Marc Kleine-Budde
2021-03-30 11:45 ` [net-next 39/39] can: c_can: add support to 64 message objects Marc Kleine-Budde
2021-03-30 20:10 ` pull-request: can-next 2021-03-30 patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210330114559.1114855-8-mkl@pengutronix.de \
--to=mkl@pengutronix.de \
--cc=davem@davemloft.net \
--cc=kernel@pengutronix.de \
--cc=kuba@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=mailhol.vincent@wanadoo.fr \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).