net-device: move gso_partial_features to net_device_read_tx
Subsystems (3)
PATCH 1/1 net-device: move gso_partial_features to net_device_read_tx
dev->gso_partial_features is read from tx fast path for GSO packets.
Move it to appropriate section to avoid a cache line miss.
--- Documentation/networking/net_cachelines/net_device.rst | 2 +- include/linux/netdevice.h | 2 +- net/core/dev.c | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-)
Documentation/networking/net_cachelines/net_device.rst +1 -1
@@ -38,7 +38,7 @@ netdev_features_t wanted_features netdev_features_t vlan_features netdev_features_t hw_enc_features - - netif_skb_features netdev_features_t mpls_features -netdev_features_t gso_partial_features +netdev_features_t gso_partial_features read_mostly gso_features_check unsigned_int min_mtu unsigned_int max_mtu unsigned_short type
include/linux/netdevice.h +1 -1
@@ -2114,6 +2114,7 @@ struct net_device {const struct net_device_ops *netdev_ops;const struct header_ops *header_ops;struct netdev_queue *_tx; +netdev_features_t gso_partial_features;unsigned int real_num_tx_queues;unsigned int gso_max_size;unsigned int gso_ipv4_max_size;
@@ -2210,7 +2211,6 @@ struct net_device {netdev_features_t vlan_features;netdev_features_t hw_enc_features;netdev_features_t mpls_features; -netdev_features_t gso_partial_features;unsigned int min_mtu;unsigned int max_mtu;
net/core/dev.c +2 -1
@@ -11623,6 +11623,7 @@ static void __init net_dev_struct_check(void) CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_tx, gso_max_size); CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_tx, gso_ipv4_max_size); CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_tx, gso_max_segs); + CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_tx, gso_partial_features); CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_tx, num_tc); CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_tx, mtu); CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_tx, needed_headroom);
@@ -11636,7 +11637,7 @@ static void __init net_dev_struct_check(void)#ifdef CONFIG_NET_XGRESS CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_tx, tcx_egress);#endif - CACHELINE_ASSERT_GROUP_SIZE(struct net_device, net_device_read_tx, 152); + CACHELINE_ASSERT_GROUP_SIZE(struct net_device, net_device_read_tx, 160);/* TXRX read-mostly hotpath */ CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_txrx, flags);
Signature · 1 line
2.43.0.472.g3155946c3a-goog
Quoted 8 lines · Eric Dumazet
dev->gso_partial_featuresis read from tx fast path for GSO packets.Move it to appropriate section to avoid a cache line miss.
Fixes 43a71cd66b9c ("net-device: reorganize net_device fast path variables")Signed-off-by Eric Dumazet <[email protected]>Cc Coco Li <[email protected]>Cc David Ahern <[email protected]>
Thanks Eric,
FWIIW, this change looks good to me.
I have a follow-up question below.
...
include/linux/netdevice.h struct net_device { · line 2120
Quoted 12 lines
include/linux/netdevice.h +1
-0@@ -2114,6 +2114,7 @@ struct net_device {const struct net_device_ops *netdev_ops;const struct header_ops *header_ops;struct netdev_queue *_tx; +netdev_features_t gso_partial_features;unsigned int real_num_tx_queues;unsigned int gso_max_size;unsigned int gso_ipv4_max_size;
While looking at this I came to wonder if it would be worth adding a 16bit pad a little below this hunk so that tc_to_txq sits on it's own cacheline.
I'm unsure if the access pattern of tc_to_txq makes this worthwhile. But if so it would be a simple tweak.
With such a change in place, on top of your patch, the diff of pahole output on x86_64 is:
@@ -7432,10 +7432,9 @@
s16 num_tc; /* 54 2 */
unsigned int mtu; /* 56 4 */
short unsigned int needed_headroom; /* 60 2 */
- struct netdev_tc_txq tc_to_txq[16]; /* 62 64 */
-
- /* XXX 2 bytes hole, try to pack */
-
+ u16 pad1; /* 62 2 */
+ /* --- cacheline 1 boundary (64 bytes) --- */
+ struct netdev_tc_txq tc_to_txq[16]; /* 64 64 */
/* --- cacheline 2 boundary (128 bytes) --- */
struct xps_dev_maps * xps_maps[2]; /* 128 16 */
struct nf_hook_entries * nf_hooks_egress; /* 144 8 */Quoted 21 lines · Simon Horman
Quoted 8 lines · Eric Dumazet
dev->gso_partial_featuresis read from tx fast path for GSO packets.Move it to appropriate section to avoid a cache line miss.
Fixes 43a71cd66b9c ("net-device: reorganize net_device fast path variables")Signed-off-by Eric Dumazet <[email protected]>Cc Coco Li <[email protected]>Cc David Ahern <[email protected]>Thanks Eric,
FWIIW, this change looks good to me.
Reviewed-by Simon Horman <[email protected]>I have a follow-up question below.
...
Quoted 17 lines
include/linux/netdevice.h struct net_device { · line 2120
Quoted 12 lines
include/linux/netdevice.h +1
-0@@ -2114,6 +2114,7 @@ struct net_device {const struct net_device_ops *netdev_ops;const struct header_ops *header_ops;struct netdev_queue *_tx; +netdev_features_t gso_partial_features;unsigned int real_num_tx_queues;unsigned int gso_max_size;unsigned int gso_ipv4_max_size;While looking at this I came to wonder if it would be worth adding a 16bit pad a little below this hunk so that
tc_to_txqsits on it's own cacheline.
Hi Simon, thanks for the suggestion.
I am still working on struct net_device layout (after being off for last ~10 days), I will try to address your feedback soon.
Quoted 20 lines
I'm unsure if the access pattern of
tc_to_txqmakes this worthwhile. But if so it would be a simple tweak.With such a change in place, on top of your patch, the diff of pahole output on
x86_64is:(quoted diff) +3
-4@@ -7432,10 +7432,9 @@ s16 num_tc; /* 54 2 */ unsigned int mtu; /* 56 4 */ short unsigned int needed_headroom; /* 60 2 */ - struct netdev_tc_txq tc_to_txq[16]; /* 62 64 */ - - /* XXX 2 bytes hole, try to pack */ - + u16 pad1; /* 62 2 */ + /* --- cacheline 1 boundary (64 bytes) --- */ + struct netdev_tc_txq tc_to_txq[16]; /* 64 64 */ /* --- cacheline 2 boundary (128 bytes) --- */ struct xps_dev_maps * xps_maps[2]; /* 128 16 */ struct nf_hook_entries * nf_hooks_egress; /* 144 8 */
This patch was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Quoted 10 lines · On Thu, 21 Dec 2023 14:07:47 +0000 you wrote:
dev->gso_partial_featuresis read from tx fast path for GSO packets.Move it to appropriate section to avoid a cache line miss.
Fixes 43a71cd66b9c ("net-device: reorganize net_device fast path variables")Signed-off-by Eric Dumazet <[email protected]>Cc Coco Li <[email protected]>Cc David Ahern <[email protected]>[...]
Here is the summary with links:
- [net-next] net-device: move gso_partial_features to net_device_read_tx
https://git.kernel.org/netdev/net-next/c/993498e537af
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html