From: Vincent Mailhol <mailhol@kernel.org>
To: Oliver Hartkopp <socketcan@hartkopp.net>,
Marc Kleine-Budde <mkl@pengutronix.de>
Cc: linux-can@vger.kernel.org, linux-kernel@vger.kernel.org,
Vincent Mailhol <mailhol@kernel.org>
Subject: [PATCH 1/3] can: raw: reorder struct uniqframe's members to optimise packing
Date: Mon, 15 Sep 2025 18:23:13 +0900 [thread overview]
Message-ID: <20250915-can-raw-repack-v1-1-5ea293bc6d33@kernel.org> (raw)
In-Reply-To: <20250915-can-raw-repack-v1-0-5ea293bc6d33@kernel.org>
struct uniqframe has one hole. Reorder the fields to save 8 bytes.
Statistics before:
$ pahole --class_name=uniqframe net/can/raw.o
struct uniqframe {
int skbcnt; /* 0 4 */
/* XXX 4 bytes hole, try to pack */
const struct sk_buff * skb; /* 8 8 */
unsigned int join_rx_count; /* 16 4 */
/* size: 24, cachelines: 1, members: 3 */
/* sum members: 16, holes: 1, sum holes: 4 */
/* padding: 4 */
/* last cacheline: 24 bytes */
};
...and after:
$ pahole --class_name=uniqframe net/can/raw.o
struct uniqframe {
const struct sk_buff * skb; /* 0 8 */
int skbcnt; /* 8 4 */
unsigned int join_rx_count; /* 12 4 */
/* size: 16, cachelines: 1, members: 3 */
/* last cacheline: 16 bytes */
};
Signed-off-by: Vincent Mailhol <mailhol@kernel.org>
---
net/can/raw.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/can/raw.c b/net/can/raw.c
index 76b867d21def209f5c6d236604c0e434a1c55a4d..db21d8a8c54d1b6a25a72c7a9d11d5c94f3187b5 100644
--- a/net/can/raw.c
+++ b/net/can/raw.c
@@ -75,8 +75,8 @@ MODULE_ALIAS("can-proto-1");
*/
struct uniqframe {
- int skbcnt;
const struct sk_buff *skb;
+ int skbcnt;
unsigned int join_rx_count;
};
--
2.49.1
next prev parent reply other threads:[~2025-09-15 9:24 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-15 9:23 [PATCH 0/3] can: raw: optimize the sizes of struct uniqframe and struct raw_sock Vincent Mailhol
2025-09-15 9:23 ` Vincent Mailhol [this message]
2025-09-15 10:18 ` [PATCH 1/3] can: raw: reorder struct uniqframe's members to optimise packing Oliver Hartkopp
2025-09-15 9:23 ` [PATCH 2/3] can: raw: use bitfields to store flags in struct raw_sock Vincent Mailhol
2025-09-15 10:16 ` Oliver Hartkopp
2025-09-15 10:47 ` Vincent Mailhol
2025-09-15 17:41 ` Oliver Hartkopp
2025-09-16 18:35 ` Christophe JAILLET
2025-09-17 4:43 ` Vincent Mailhol
2025-09-15 9:23 ` [PATCH 3/3] can: raw: reorder struct raw_sock's members to optimise packing Vincent Mailhol
2025-09-15 17:42 ` Oliver Hartkopp
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=20250915-can-raw-repack-v1-1-5ea293bc6d33@kernel.org \
--to=mailhol@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mkl@pengutronix.de \
--cc=socketcan@hartkopp.net \
/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