* [PATCH net-next] net: minor reshuffle of napi_struct
@ 2023-03-31 4:47 Jakub Kicinski
2023-03-31 12:37 ` Eric Dumazet
2023-04-02 12:30 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Jakub Kicinski @ 2023-03-31 4:47 UTC (permalink / raw)
To: davem; +Cc: netdev, edumazet, pabeni, Jakub Kicinski
napi_id is read by GRO and drivers to mark skbs, and it currently
sits at the end of the structure, in a mostly unused cache line.
Move it up into a hole, and separate the clearly control path
fields from the important ones.
Before:
struct napi_struct {
struct list_head poll_list; /* 0 16 */
long unsigned int state; /* 16 8 */
int weight; /* 24 4 */
int defer_hard_irqs_count; /* 28 4 */
long unsigned int gro_bitmask; /* 32 8 */
int (*poll)(struct napi_struct *, int); /* 40 8 */
int poll_owner; /* 48 4 */
/* XXX 4 bytes hole, try to pack */
struct net_device * dev; /* 56 8 */
/* --- cacheline 1 boundary (64 bytes) --- */
struct gro_list gro_hash[8]; /* 64 192 */
/* --- cacheline 4 boundary (256 bytes) --- */
struct sk_buff * skb; /* 256 8 */
struct list_head rx_list; /* 264 16 */
int rx_count; /* 280 4 */
/* XXX 4 bytes hole, try to pack */
struct hrtimer timer; /* 288 64 */
/* XXX last struct has 4 bytes of padding */
/* --- cacheline 5 boundary (320 bytes) was 32 bytes ago --- */
struct list_head dev_list; /* 352 16 */
struct hlist_node napi_hash_node; /* 368 16 */
/* --- cacheline 6 boundary (384 bytes) --- */
unsigned int napi_id; /* 384 4 */
/* XXX 4 bytes hole, try to pack */
struct task_struct * thread; /* 392 8 */
/* size: 400, cachelines: 7, members: 17 */
/* sum members: 388, holes: 3, sum holes: 12 */
/* paddings: 1, sum paddings: 4 */
/* last cacheline: 16 bytes */
};
After:
struct napi_struct {
struct list_head poll_list; /* 0 16 */
long unsigned int state; /* 16 8 */
int weight; /* 24 4 */
int defer_hard_irqs_count; /* 28 4 */
long unsigned int gro_bitmask; /* 32 8 */
int (*poll)(struct napi_struct *, int); /* 40 8 */
int poll_owner; /* 48 4 */
/* XXX 4 bytes hole, try to pack */
struct net_device * dev; /* 56 8 */
/* --- cacheline 1 boundary (64 bytes) --- */
struct gro_list gro_hash[8]; /* 64 192 */
/* --- cacheline 4 boundary (256 bytes) --- */
struct sk_buff * skb; /* 256 8 */
struct list_head rx_list; /* 264 16 */
int rx_count; /* 280 4 */
unsigned int napi_id; /* 284 4 */
struct hrtimer timer; /* 288 64 */
/* XXX last struct has 4 bytes of padding */
/* --- cacheline 5 boundary (320 bytes) was 32 bytes ago --- */
struct task_struct * thread; /* 352 8 */
struct list_head dev_list; /* 360 16 */
struct hlist_node napi_hash_node; /* 376 16 */
/* size: 392, cachelines: 7, members: 17 */
/* sum members: 388, holes: 1, sum holes: 4 */
/* paddings: 1, sum paddings: 4 */
/* forced alignments: 1 */
/* last cacheline: 8 bytes */
} __attribute__((__aligned__(8)));
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
include/linux/netdevice.h | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 78f70e94b5d8..b3c11353078b 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -370,11 +370,12 @@ struct napi_struct {
struct sk_buff *skb;
struct list_head rx_list; /* Pending GRO_NORMAL skbs */
int rx_count; /* length of rx_list */
+ unsigned int napi_id;
struct hrtimer timer;
+ struct task_struct *thread;
+ /* control-path-only fields follow */
struct list_head dev_list;
struct hlist_node napi_hash_node;
- unsigned int napi_id;
- struct task_struct *thread;
};
enum {
--
2.39.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net-next] net: minor reshuffle of napi_struct
2023-03-31 4:47 [PATCH net-next] net: minor reshuffle of napi_struct Jakub Kicinski
@ 2023-03-31 12:37 ` Eric Dumazet
2023-04-02 12:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Eric Dumazet @ 2023-03-31 12:37 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: davem, netdev, pabeni
On Fri, Mar 31, 2023 at 6:47 AM Jakub Kicinski <kuba@kernel.org> wrote:
>
> napi_id is read by GRO and drivers to mark skbs, and it currently
> sits at the end of the structure, in a mostly unused cache line.
> Move it up into a hole, and separate the clearly control path
> fields from the important ones.
>
>
Reviewed-by: Eric Dumazet <edumazet@google.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: minor reshuffle of napi_struct
2023-03-31 4:47 [PATCH net-next] net: minor reshuffle of napi_struct Jakub Kicinski
2023-03-31 12:37 ` Eric Dumazet
@ 2023-04-02 12:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-04-02 12:30 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: davem, netdev, edumazet, pabeni
Hello:
This patch was applied to netdev/net-next.git (main)
by David S. Miller <davem@davemloft.net>:
On Thu, 30 Mar 2023 21:47:31 -0700 you wrote:
> napi_id is read by GRO and drivers to mark skbs, and it currently
> sits at the end of the structure, in a mostly unused cache line.
> Move it up into a hole, and separate the clearly control path
> fields from the important ones.
>
> Before:
>
> [...]
Here is the summary with links:
- [net-next] net: minor reshuffle of napi_struct
https://git.kernel.org/netdev/net-next/c/dd2d6604407d
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] 3+ messages in thread
end of thread, other threads:[~2023-04-02 12:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-31 4:47 [PATCH net-next] net: minor reshuffle of napi_struct Jakub Kicinski
2023-03-31 12:37 ` Eric Dumazet
2023-04-02 12:30 ` 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).