Skip to content

refine rollover

Willem de Bruijn netdev 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest6 patches 1 replyIn review
  2. v26 patches 2 repliesSuperseded
  3. v17 patches 8 repliesSuperseded

Changes in v3 from the cover letter

- statistics: replace unsigned long with __aligned_u64

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6packet: rollover prepare: move code out of callsitesnet/packet/af_packet.c+10 -90 replies
2/6packet: rollover prepare: per-socket statenet/packet/af_packet.c net/packet/internal.h+23 -40 replies
3/6packet: rollover only to socket with headroomnet/packet/af_packet.c+58 -160 replies
4/6packet: rollover lock contention avoidancenet/packet/af_packet.c net/packet/internal.h+32 -70 replies
5/6packet: rollover huge flows before small flowsnet/packet/af_packet.c net/packet/internal.h+24 -30 replies
6/6packet: rollover statisticsinclude/uapi/linux/if_packet.h net/packet/af_packet.c net/packet/internal.h+28 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCH net-next v3 0/6] refine rollover

From: Willem de Bruijn <[email protected]>

refine packet socket rollover:

1. mitigate a case of lock contention
2. avoid exporting resource exhaustion to other sockets, by migrating only to a victim socket that has ample room
3. avoid reordering of most flows on the socket,
by migrating first the flow responsible for load imbalance
4. help processes detect load imbalance,
by exporting rollover counters

Context: rollover implements flow migration in packet socket fanout groups in case of extreme load imbalance. It is a specific implementation of migration that minimizes reordering by selecting the same victim socket when possible (and by selecting subsequent victims in a round robin fashion, from which its name derives).

Changes:
v2 -> v3:
- statistics: replace unsigned long with __aligned_u64
v1 -> v2:
- huge flow detection: run lockless
- huge flow detection: replace stored index with random
- contention avoidance: test in packet_poll while lock held
- contention avoidance: clear pressure sooner

packet_poll and packet_recvmsg would clear only if the sock is empty to avoid taking the necessary lock. But,
* packet_poll already holds this lock, so a lockless variant __packet_rcv_has_room is cheap.
* packet_recvmsg is usually called only for non-ring sockets, which also runs lockless.

- preparation: drop "single return" patch

packet_rcv_has_room is now a locked wrapper around __packet_rcv_has_room, achieving the same (single footer).

The benchmark mentioned in the patches is at
https://github.com/wdebruij/kerneltools/blob/master/tests/bench_rollover.c

Willem de Bruijn (6):
packet: rollover prepare: move code out of callsites
packet: rollover prepare: per-socket state
packet: rollover only to socket with headroom
packet: rollover lock contention avoidance
packet: rollover huge flows before small flows
packet: rollover statistics

 include/uapi/linux/if_packet.h |   7 ++
 net/packet/af_packet.c         | 172 ++++++++++++++++++++++++++++++++++-------
 net/packet/internal.h          |  12 ++-
 3 files changed, 163 insertions(+), 28 deletions(-)
Signature · 1 line
2.2.0.rc0.207.ga3a616c