diff mbox series

[net-next] mptcp: Reorder fields in 'struct mptcp_pm_add_entry'

Message ID e47b71de54fd3e580544be56fc1bb2985c77b0f4.1687081558.git.christophe.jaillet@wanadoo.fr (mailing list archive)
State Accepted
Commit 92b08290859b09a2ead2dc553aaaadb015748536
Delegated to: Netdev Maintainers
Headers show
Series [net-next] mptcp: Reorder fields in 'struct mptcp_pm_add_entry' | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 12 this patch: 12
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 12 this patch: 12
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 10 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Christophe JAILLET June 18, 2023, 9:46 a.m. UTC
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(-)

Comments

Matthieu Baerts June 19, 2023, 11:14 a.m. UTC | #1
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
Jiri Pirko June 19, 2023, 2:42 p.m. UTC | #2
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>
patchwork-bot+netdevbpf@kernel.org June 21, 2023, 3:40 a.m. UTC | #3
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!
diff mbox series

Patch

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 {