* [PATCH net-next] netlabel: Reorder fields in 'struct netlbl_domaddr6_map'
@ 2023-06-18 10:16 Christophe JAILLET
2023-06-19 14:08 ` Simon Horman
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Christophe JAILLET @ 2023-06-18 10:16 UTC (permalink / raw)
To: Paul Moore, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: linux-kernel, kernel-janitors, Christophe JAILLET, netdev,
linux-security-module
Group some variables based on their sizes to reduce hole and avoid padding.
On x86_64, this shrinks the size of 'struct netlbl_domaddr6_map'
from 72 to 64 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 netlbl_dom_map {
char * domain; /* 0 8 */
u16 family; /* 8 2 */
/* XXX 6 bytes hole, try to pack */
struct netlbl_dommap_def def; /* 16 16 */
u32 valid; /* 32 4 */
/* XXX 4 bytes hole, try to pack */
struct list_head list; /* 40 16 */
struct callback_head rcu __attribute__((__aligned__(8))); /* 56 16 */
/* size: 72, cachelines: 2, members: 6 */
/* sum members: 62, holes: 2, sum holes: 10 */
/* forced alignments: 1 */
/* last cacheline: 8 bytes */
} __attribute__((__aligned__(8)));
After:
=====
struct netlbl_dom_map {
char * domain; /* 0 8 */
struct netlbl_dommap_def def; /* 8 16 */
u16 family; /* 24 2 */
/* XXX 2 bytes hole, try to pack */
u32 valid; /* 28 4 */
struct list_head list; /* 32 16 */
struct callback_head rcu __attribute__((__aligned__(8))); /* 48 16 */
/* size: 64, cachelines: 1, members: 6 */
/* sum members: 62, holes: 1, sum holes: 2 */
/* forced alignments: 1 */
} __attribute__((__aligned__(8)));
---
net/netlabel/netlabel_domainhash.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/netlabel/netlabel_domainhash.h b/net/netlabel/netlabel_domainhash.h
index 9f80972ae39b..7eaa35fdd9bd 100644
--- a/net/netlabel/netlabel_domainhash.h
+++ b/net/netlabel/netlabel_domainhash.h
@@ -57,8 +57,8 @@ struct netlbl_domaddr6_map {
struct netlbl_dom_map {
char *domain;
- u16 family;
struct netlbl_dommap_def def;
+ u16 family;
u32 valid;
struct list_head list;
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] netlabel: Reorder fields in 'struct netlbl_domaddr6_map'
2023-06-18 10:16 [PATCH net-next] netlabel: Reorder fields in 'struct netlbl_domaddr6_map' Christophe JAILLET
@ 2023-06-19 14:08 ` Simon Horman
2023-06-19 14:43 ` Jiri Pirko
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Simon Horman @ 2023-06-19 14:08 UTC (permalink / raw)
To: Christophe JAILLET
Cc: Paul Moore, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, linux-kernel, kernel-janitors, netdev,
linux-security-module
On Sun, Jun 18, 2023 at 12:16:41PM +0200, 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 netlbl_domaddr6_map'
> from 72 to 64 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: Simon Horman <simon.horman@corigine.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] netlabel: Reorder fields in 'struct netlbl_domaddr6_map'
2023-06-18 10:16 [PATCH net-next] netlabel: Reorder fields in 'struct netlbl_domaddr6_map' Christophe JAILLET
2023-06-19 14:08 ` Simon Horman
@ 2023-06-19 14:43 ` Jiri Pirko
2023-06-19 16:06 ` Paul Moore
2023-06-21 3:40 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: Jiri Pirko @ 2023-06-19 14:43 UTC (permalink / raw)
To: Christophe JAILLET
Cc: Paul Moore, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, linux-kernel, kernel-janitors, netdev,
linux-security-module
Sun, Jun 18, 2023 at 12:16:41PM 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 netlbl_domaddr6_map'
>from 72 to 64 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] 5+ messages in thread
* Re: [PATCH net-next] netlabel: Reorder fields in 'struct netlbl_domaddr6_map'
2023-06-18 10:16 [PATCH net-next] netlabel: Reorder fields in 'struct netlbl_domaddr6_map' Christophe JAILLET
2023-06-19 14:08 ` Simon Horman
2023-06-19 14:43 ` Jiri Pirko
@ 2023-06-19 16:06 ` Paul Moore
2023-06-21 3:40 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: Paul Moore @ 2023-06-19 16:06 UTC (permalink / raw)
To: Christophe JAILLET
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
linux-kernel, kernel-janitors, netdev, linux-security-module
On Sun, Jun 18, 2023 at 6:16 AM Christophe JAILLET
<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 netlbl_domaddr6_map'
> from 72 to 64 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 netlbl_dom_map {
> char * domain; /* 0 8 */
> u16 family; /* 8 2 */
>
> /* XXX 6 bytes hole, try to pack */
>
> struct netlbl_dommap_def def; /* 16 16 */
> u32 valid; /* 32 4 */
>
> /* XXX 4 bytes hole, try to pack */
>
> struct list_head list; /* 40 16 */
> struct callback_head rcu __attribute__((__aligned__(8))); /* 56 16 */
>
> /* size: 72, cachelines: 2, members: 6 */
> /* sum members: 62, holes: 2, sum holes: 10 */
> /* forced alignments: 1 */
> /* last cacheline: 8 bytes */
> } __attribute__((__aligned__(8)));
>
>
> After:
> =====
> struct netlbl_dom_map {
> char * domain; /* 0 8 */
> struct netlbl_dommap_def def; /* 8 16 */
> u16 family; /* 24 2 */
>
> /* XXX 2 bytes hole, try to pack */
>
> u32 valid; /* 28 4 */
> struct list_head list; /* 32 16 */
> struct callback_head rcu __attribute__((__aligned__(8))); /* 48 16 */
>
> /* size: 64, cachelines: 1, members: 6 */
> /* sum members: 62, holes: 1, sum holes: 2 */
> /* forced alignments: 1 */
> } __attribute__((__aligned__(8)));
> ---
> net/netlabel/netlabel_domainhash.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Acked-by: Paul Moore <paul@paul-moore.com>
--
paul-moore.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] netlabel: Reorder fields in 'struct netlbl_domaddr6_map'
2023-06-18 10:16 [PATCH net-next] netlabel: Reorder fields in 'struct netlbl_domaddr6_map' Christophe JAILLET
` (2 preceding siblings ...)
2023-06-19 16:06 ` Paul Moore
@ 2023-06-21 3:40 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-06-21 3:40 UTC (permalink / raw)
To: Christophe JAILLET
Cc: paul, davem, edumazet, kuba, pabeni, linux-kernel,
kernel-janitors, netdev, linux-security-module
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Sun, 18 Jun 2023 12:16:41 +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 netlbl_domaddr6_map'
> from 72 to 64 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] netlabel: Reorder fields in 'struct netlbl_domaddr6_map'
https://git.kernel.org/netdev/net-next/c/f0d952646bcf
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] 5+ messages in thread
end of thread, other threads:[~2023-06-21 3:40 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-18 10:16 [PATCH net-next] netlabel: Reorder fields in 'struct netlbl_domaddr6_map' Christophe JAILLET
2023-06-19 14:08 ` Simon Horman
2023-06-19 14:43 ` Jiri Pirko
2023-06-19 16:06 ` Paul Moore
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).