* [PATCH net-next] mptcp: Reorder fields in 'struct mptcp_pm_add_entry'
@ 2023-06-18 9:46 Christophe JAILLET
2023-06-19 11:14 ` Matthieu Baerts
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Christophe JAILLET @ 2023-06-18 9:46 UTC (permalink / raw)
To: Matthieu Baerts, Mat Martineau, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni
Cc: linux-kernel, kernel-janitors, Christophe JAILLET, netdev, mptcp
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@wanadoo.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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] mptcp: Reorder fields in 'struct mptcp_pm_add_entry'
2023-06-18 9:46 [PATCH net-next] mptcp: Reorder fields in 'struct mptcp_pm_add_entry' Christophe JAILLET
@ 2023-06-19 11:14 ` Matthieu Baerts
2023-06-19 14:42 ` Jiri Pirko
2023-06-21 3:40 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Matthieu Baerts @ 2023-06-19 11:14 UTC (permalink / raw)
To: Christophe JAILLET, Mat Martineau, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni
Cc: linux-kernel, kernel-janitors, netdev, mptcp
Hi Christophe,
On 18/06/2023 11:46, Christophe JAILLET wrote:
> 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.
Good catch and thank you for having shared this patch, it looks good to me!
Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net>
Cheers,
Matt
--
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] mptcp: Reorder fields in 'struct mptcp_pm_add_entry'
2023-06-18 9:46 [PATCH net-next] mptcp: Reorder fields in 'struct mptcp_pm_add_entry' Christophe JAILLET
2023-06-19 11:14 ` Matthieu Baerts
@ 2023-06-19 14:42 ` Jiri Pirko
2023-06-21 3:40 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Jiri Pirko @ 2023-06-19 14:42 UTC (permalink / raw)
To: Christophe JAILLET
Cc: Matthieu Baerts, Mat Martineau, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, linux-kernel, kernel-janitors,
netdev, mptcp
Sun, Jun 18, 2023 at 11:46:46AM CEST, christophe.jaillet@wanadoo.fr wrote:
>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@wanadoo.fr>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] mptcp: Reorder fields in 'struct mptcp_pm_add_entry'
2023-06-18 9:46 [PATCH net-next] mptcp: Reorder fields in 'struct mptcp_pm_add_entry' Christophe JAILLET
2023-06-19 11:14 ` Matthieu Baerts
2023-06-19 14:42 ` Jiri Pirko
@ 2023-06-21 3:40 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-06-21 3:40 UTC (permalink / raw)
To: Christophe JAILLET
Cc: matthieu.baerts, martineau, davem, edumazet, kuba, pabeni,
linux-kernel, kernel-janitors, netdev, mptcp
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Sun, 18 Jun 2023 11:46:46 +0200 you wrote:
> 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@wanadoo.fr>
>
> [...]
Here is the summary with links:
- [net-next] mptcp: Reorder fields in 'struct mptcp_pm_add_entry'
https://git.kernel.org/netdev/net-next/c/92b08290859b
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-06-21 3:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-18 9:46 [PATCH net-next] mptcp: Reorder fields in 'struct mptcp_pm_add_entry' Christophe JAILLET
2023-06-19 11:14 ` Matthieu Baerts
2023-06-19 14:42 ` Jiri Pirko
2023-06-21 3:40 ` patchwork-bot+netdevbpf
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).