diff options
author | Willem de Bruijn <willemb@google.com> | 2013-03-19 06:18:11 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-03-19 17:15:04 -0400 |
commit | 77f65ebdca506870d99bfabe52bde222511022ec (patch) | |
tree | 8f5ba6c76d1b49b44128d08281cc0b6f3e62285c /net/packet/internal.h | |
parent | b0aa73bf081da6810dacd750b9f8186640e172db (diff) |
packet: packet fanout rollover during socket overload
Changes:
v3->v2: rebase (no other changes)
passes selftest
v2->v1: read f->num_members only once
fix bug: test rollover mode + flag
Minimize packet drop in a fanout group. If one socket is full,
roll over packets to another from the group. Maintain flow
affinity during normal load using an rxhash fanout policy, while
dispersing unexpected traffic storms that hit a single cpu, such
as spoofed-source DoS flows. Rollover breaks affinity for flows
arriving at saturated sockets during those conditions.
The patch adds a fanout policy ROLLOVER that rotates between sockets,
filling each socket before moving to the next. It also adds a fanout
flag ROLLOVER. If passed along with any other fanout policy, the
primary policy is applied until the chosen socket is full. Then,
rollover selects another socket, to delay packet drop until the
entire system is saturated.
Probing sockets is not free. Selecting the last used socket, as
rollover does, is a greedy approach that maximizes chance of
success, at the cost of extreme load imbalance. In practice, with
sufficiently long queues to absorb bursts, sockets are drained in
parallel and load balance looks uniform in `top`.
To avoid contention, scales counters with number of sockets and
accesses them lockfree. Values are bounds checked to ensure
correctness.
Tested using an application with 9 threads pinned to CPUs, one socket
per thread and sufficient busywork per packet operation to limits each
thread to handling 32 Kpps. When sent 500 Kpps single UDP stream
packets, a FANOUT_CPU setup processes 32 Kpps in total without this
patch, 270 Kpps with the patch. Tested with read() and with a packet
ring (V1).
Also, passes psock_fanout.c unit test added to selftests.
Signed-off-by: Willem de Bruijn <willemb@google.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/packet/internal.h')
-rw-r--r-- | net/packet/internal.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/net/packet/internal.h b/net/packet/internal.h index e84cab8cb7a9..e891f025a1b9 100644 --- a/net/packet/internal.h +++ b/net/packet/internal.h | |||
@@ -77,10 +77,11 @@ struct packet_fanout { | |||
77 | unsigned int num_members; | 77 | unsigned int num_members; |
78 | u16 id; | 78 | u16 id; |
79 | u8 type; | 79 | u8 type; |
80 | u8 defrag; | 80 | u8 flags; |
81 | atomic_t rr_cur; | 81 | atomic_t rr_cur; |
82 | struct list_head list; | 82 | struct list_head list; |
83 | struct sock *arr[PACKET_FANOUT_MAX]; | 83 | struct sock *arr[PACKET_FANOUT_MAX]; |
84 | int next[PACKET_FANOUT_MAX]; | ||
84 | spinlock_t lock; | 85 | spinlock_t lock; |
85 | atomic_t sk_ref; | 86 | atomic_t sk_ref; |
86 | struct packet_type prot_hook ____cacheline_aligned_in_smp; | 87 | struct packet_type prot_hook ____cacheline_aligned_in_smp; |