Skip to content

Commit c353c7b

Browse files
edumazetdavem330
authored andcommitted
net-device: move lstats in net_device_read_txrx
dev->lstats is notably used from loopback ndo_start_xmit() and other virtual drivers. Per cpu stats updates are dirtying per-cpu data, but the pointer itself is read-only. Fixes: 43a71cd ("net-device: reorganize net_device fast path variables") Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: Coco Li <lixiaoyan@google.com> Cc: Simon Horman <horms@kernel.org> Reviewed-by: Simon Horman <horms@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 666a877 commit c353c7b

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

Documentation/networking/net_cachelines/net_device.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ struct_netpoll_info* npinfo -
136136
possible_net_t nd_net - read_mostly (dev_net)napi_busy_loop,tcp_v(4/6)_rcv,ip(v6)_rcv,ip(6)_input,ip(6)_input_finish
137137
void* ml_priv
138138
enum_netdev_ml_priv_type ml_priv_type
139-
struct_pcpu_lstats__percpu* lstats
140-
struct_pcpu_sw_netstats__percpu* tstats
139+
struct_pcpu_lstats__percpu* lstats read_mostly dev_lstats_add()
140+
struct_pcpu_sw_netstats__percpu* tstats read_mostly dev_sw_netstats_tx_add()
141141
struct_pcpu_dstats__percpu* dstats
142142
struct_garp_port* garp_port
143143
struct_mrp_port* mrp_port

include/linux/netdevice.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2141,6 +2141,11 @@ struct net_device {
21412141

21422142
/* TXRX read-mostly hotpath */
21432143
__cacheline_group_begin(net_device_read_txrx);
2144+
union {
2145+
struct pcpu_lstats __percpu *lstats;
2146+
struct pcpu_sw_netstats __percpu *tstats;
2147+
struct pcpu_dstats __percpu *dstats;
2148+
};
21442149
unsigned int flags;
21452150
unsigned short hard_header_len;
21462151
netdev_features_t features;
@@ -2395,11 +2400,6 @@ struct net_device {
23952400
enum netdev_ml_priv_type ml_priv_type;
23962401

23972402
enum netdev_stat_type pcpu_stat_type:8;
2398-
union {
2399-
struct pcpu_lstats __percpu *lstats;
2400-
struct pcpu_sw_netstats __percpu *tstats;
2401-
struct pcpu_dstats __percpu *dstats;
2402-
};
24032403

24042404
#if IS_ENABLED(CONFIG_GARP)
24052405
struct garp_port __rcu *garp_port;

net/core/dev.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11652,11 +11652,12 @@ static void __init net_dev_struct_check(void)
1165211652
CACHELINE_ASSERT_GROUP_SIZE(struct net_device, net_device_read_tx, 160);
1165311653

1165411654
/* TXRX read-mostly hotpath */
11655+
CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_txrx, lstats);
1165511656
CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_txrx, flags);
1165611657
CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_txrx, hard_header_len);
1165711658
CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_txrx, features);
1165811659
CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_txrx, ip6_ptr);
11659-
CACHELINE_ASSERT_GROUP_SIZE(struct net_device, net_device_read_txrx, 30);
11660+
CACHELINE_ASSERT_GROUP_SIZE(struct net_device, net_device_read_txrx, 38);
1166011661

1166111662
/* RX read-mostly hotpath */
1166211663
CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, ptype_specific);

0 commit comments

Comments
 (0)