[Bug 262571] epair(4) interfaces stop forwarding traffic on moderate load

From: <bugzilla-noreply_at_freebsd.org>
Date: Wed, 16 Mar 2022 23:40:31 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=262571

--- Comment #2 from commit-hook@FreeBSD.org ---
A commit in branch stable/13 references this bug:

URL:
https://cgit.FreeBSD.org/src/commit/?id=bb9ad300f029d57c84804702daa2652542a2535f

commit bb9ad300f029d57c84804702daa2652542a2535f
Author:     Michael Gmelin <grembo@FreeBSD.org>
AuthorDate: 2022-03-16 22:08:55 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2022-03-16 23:38:33 +0000

    if_epair: fix race condition on multi-core systems

    As an unwanted side effect of the performance improvements in
    24f0bfbad57b9, epair interfaces stop forwarding traffic on higher
    load levels when running on multi-core systems.

    This happens due to a race condition in the logic that decides when to
    place work in the task queue(s) responsible for processing the content
    of ring buffers.

    In order to fix this, a field named state is added to the epair_queue
    structure. This field is used by the affected functions to signal each
    other that something happened in the underlying ring buffers that might
    require work to be scheduled in task queue(s), replacing the existing
    logic, which relied on checking if ring buffers are empty or not.

    epair_menq() does:
      - set BIT_MBUF_QUEUED
      - queue mbuf
      - if testandset BIT_QUEUE_TASK:
          enqueue task

    epair_tx_start_deferred() does:
      - swap ring buffers
      - process mbufs
      - clear BIT_QUEUE_TASK
      - if testandclear BIT_MBUF_QUEUED
          enqueue task

    PR:             262571
    Approved by:    re (gjb, early MFC)
    Reported by:    Johan Hendriks <joh.hendriks@gmail.com>
    MFC after:      3 days
    Differential Revision:  https://reviews.freebsd.org/D34569

    (cherry picked from commit 66acf7685bcd8cf23b6c658a991637238a01859e)

 sys/net/if_epair.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

-- 
You are receiving this mail because:
You are the assignee for the bug.