mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-30 10:49:28 +00:00
macvlan: lockless tx path
macvlan is a stacked device, like tunnels. We should use the lockless
mechanism we are using in tunnels and loopback.
This patch completely removes locking in TX path.
tx stat counters are added into existing percpu stat structure, renamed
from rx_stats to pcpu_stats.
Note : this reverts commit 2c11455321
(macvlan: add multiqueue
capability)
Note : rx_errors converted to a 32bit counter, like tx_dropped, since
they dont need 64bit range.
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Patrick McHardy <kaber@trash.net>
Cc: Ben Greear <greearb@candelatech.com>
Cc: Ben Hutchings <bhutchings@solarflare.com>
Acked-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
0e3125c755
commit
8ffab51b3d
2 changed files with 55 additions and 59 deletions
|
@ -25,19 +25,25 @@ struct macvlan_port;
|
|||
struct macvtap_queue;
|
||||
|
||||
/**
|
||||
* struct macvlan_rx_stats - MACVLAN percpu rx stats
|
||||
* struct macvlan_pcpu_stats - MACVLAN percpu stats
|
||||
* @rx_packets: number of received packets
|
||||
* @rx_bytes: number of received bytes
|
||||
* @rx_multicast: number of received multicast packets
|
||||
* @tx_packets: number of transmitted packets
|
||||
* @tx_bytes: number of transmitted bytes
|
||||
* @syncp: synchronization point for 64bit counters
|
||||
* @rx_errors: number of errors
|
||||
* @rx_errors: number of rx errors
|
||||
* @tx_dropped: number of tx dropped packets
|
||||
*/
|
||||
struct macvlan_rx_stats {
|
||||
struct macvlan_pcpu_stats {
|
||||
u64 rx_packets;
|
||||
u64 rx_bytes;
|
||||
u64 rx_multicast;
|
||||
u64 tx_packets;
|
||||
u64 tx_bytes;
|
||||
struct u64_stats_sync syncp;
|
||||
unsigned long rx_errors;
|
||||
u32 rx_errors;
|
||||
u32 tx_dropped;
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -52,7 +58,7 @@ struct macvlan_dev {
|
|||
struct hlist_node hlist;
|
||||
struct macvlan_port *port;
|
||||
struct net_device *lowerdev;
|
||||
struct macvlan_rx_stats __percpu *rx_stats;
|
||||
struct macvlan_pcpu_stats __percpu *pcpu_stats;
|
||||
enum macvlan_mode mode;
|
||||
int (*receive)(struct sk_buff *skb);
|
||||
int (*forward)(struct net_device *dev, struct sk_buff *skb);
|
||||
|
@ -64,18 +70,18 @@ static inline void macvlan_count_rx(const struct macvlan_dev *vlan,
|
|||
unsigned int len, bool success,
|
||||
bool multicast)
|
||||
{
|
||||
struct macvlan_rx_stats *rx_stats;
|
||||
|
||||
rx_stats = this_cpu_ptr(vlan->rx_stats);
|
||||
if (likely(success)) {
|
||||
u64_stats_update_begin(&rx_stats->syncp);
|
||||
rx_stats->rx_packets++;
|
||||
rx_stats->rx_bytes += len;
|
||||
struct macvlan_pcpu_stats *pcpu_stats;
|
||||
|
||||
pcpu_stats = this_cpu_ptr(vlan->pcpu_stats);
|
||||
u64_stats_update_begin(&pcpu_stats->syncp);
|
||||
pcpu_stats->rx_packets++;
|
||||
pcpu_stats->rx_bytes += len;
|
||||
if (multicast)
|
||||
rx_stats->rx_multicast++;
|
||||
u64_stats_update_end(&rx_stats->syncp);
|
||||
pcpu_stats->rx_multicast++;
|
||||
u64_stats_update_end(&pcpu_stats->syncp);
|
||||
} else {
|
||||
rx_stats->rx_errors++;
|
||||
this_cpu_inc(vlan->pcpu_stats->rx_errors);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue