[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <e47b71de54fd3e580544be56fc1bb2985c77b0f4.1687081558.git.christophe.jaillet@wanadoo.fr>
Date: Sun, 18 Jun 2023 11:46:46 +0200
From: Christophe JAILLET <christophe.jaillet@...adoo.fr>
To: Matthieu Baerts <matthieu.baerts@...sares.net>,
Mat Martineau <martineau@...nel.org>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>
Cc: linux-kernel@...r.kernel.org,
kernel-janitors@...r.kernel.org,
Christophe JAILLET <christophe.jaillet@...adoo.fr>,
netdev@...r.kernel.org,
mptcp@...ts.linux.dev
Subject: [PATCH net-next] mptcp: Reorder fields in 'struct mptcp_pm_add_entry'
Group some variables based on their sizes to reduce hole and avoid padding.
On x86_64, this shrinks the size of 'struct mptcp_pm_add_entry'
from 136 to 128 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 mptcp_pm_add_entry {
struct list_head list; /* 0 16 */
struct mptcp_addr_info addr; /* 16 12 */
/* XXX 4 bytes hole, try to pack */
struct timer_list add_timer; /* 32 88 */
/* --- cacheline 1 boundary (64 bytes) was 56 bytes ago --- */
struct mptcp_sock * sock; /* 120 8 */
/* --- cacheline 2 boundary (128 bytes) --- */
u8 retrans_times; /* 128 1 */
/* size: 136, cachelines: 3, members: 5 */
/* sum members: 125, holes: 1, sum holes: 4 */
/* padding: 7 */
/* last cacheline: 8 bytes */
};
After:
=====
struct mptcp_pm_add_entry {
struct list_head list; /* 0 16 */
struct mptcp_addr_info addr; /* 16 12 */
u8 retrans_times; /* 28 1 */
/* XXX 3 bytes hole, try to pack */
struct timer_list add_timer; /* 32 88 */
/* --- cacheline 1 boundary (64 bytes) was 56 bytes ago --- */
struct mptcp_sock * sock; /* 120 8 */
/* size: 128, cachelines: 2, members: 5 */
/* sum members: 125, holes: 1, sum holes: 3 */
};
---
net/mptcp/pm_netlink.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
index a12a87b780f6..a56718ffdd02 100644
--- a/net/mptcp/pm_netlink.c
+++ b/net/mptcp/pm_netlink.c
@@ -25,9 +25,9 @@ static int pm_nl_pernet_id;
struct mptcp_pm_add_entry {
struct list_head list;
struct mptcp_addr_info addr;
+ u8 retrans_times;
struct timer_list add_timer;
struct mptcp_sock *sock;
- u8 retrans_times;
};
struct pm_nl_pernet {
--
2.34.1
Powered by blists - more mailing lists