Page MenuHomeFreeBSD

iflib: Do not ring the transmit doorbell when nothing is pending
ClosedPublic

Authored by rcm on Sun, Oct 4, 11:16 AM.
Tags
None
Referenced Files
F174914264: D60290.diff
Tue, Oct 6, 10:49 PM
F174883794: D60290.id188583.diff
Tue, Oct 6, 6:24 PM
F174883689: D60290.id188700.diff
Tue, Oct 6, 6:23 PM
F174878677: D60290.id188725.diff
Tue, Oct 6, 5:45 PM
F174878523: D60290.id188712.diff
Tue, Oct 6, 5:44 PM
F174827296: D60290.diff
Tue, Oct 6, 6:42 AM
F174821409: D60290.diff
Tue, Oct 6, 5:33 AM
F174815067: D60290.id.diff
Tue, Oct 6, 4:21 AM

Details

Summary

For a lightly used ring iflib_txd_db_check() may defer zero descriptors,
so its "pending >= limit" test is true even when nothing has been queued
since the last doorbell. iflib_txq_drain() calls it before, inside and
after its loop, so a sender that drains its own packet wrote the tail
register three times per packet, twice with the value the hardware
already had.

The log of 81be655266fa ("iflib: ensure that tx interrupts enabled and
cleanups") calls skipping the doorbell when db_pending is zero "an
obvious missing optimization"; the comparison against a limit of zero
defeated it. vmx(4) and mgb(4) have dropped such repeated requests in
the driver since 2019. Return early when nothing is pending.

MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")

Test Plan

On a four-core router with Intel I226-V ports (igc) and four queues,
forwarding 64-byte UDP packets goes from 0.95 to 2.5 Mpps in one
direction and from 1.5 to 4.2 Mpps in both.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

rcm requested review of this revision.Sun, Oct 4, 11:16 AM
rcm retitled this revision from iflib: do not ring the transmit doorbell when nothing is pending to iflib: Do not ring the transmit doorbell when nothing is pending.Mon, Oct 5, 1:41 AM
rcm edited the summary of this revision. (Show Details)

I'm about to leave on a business trip so I can't give a proper affirmative review, but one thing jumps out without digging into anything.. the multi-line comment and another control flow make it somewhat unpleasing to me. I would investigate a couple ways of writing this, either build the ring decision up with single statement ifs (and line comments as needed), or use de morgans to move true or false around so there are early exits and only one ring decision (perhaps de-indented.. whatever ends up feeling clean after playing with it.

I'm about to leave on a business trip so I can't give a proper affirmative review, but one thing jumps out without digging into anything.. the multi-line comment and another control flow make it somewhat unpleasing to me. I would investigate a couple ways of writing this, either build the ring decision up with single statement ifs (and line comments as needed), or use de morgans to move true or false around so there are early exits and only one ring decision (perhaps de-indented.. whatever ends up feeling clean after playing with it.

I tried both and went with the De Morgan form: two early exits, then the doorbell write as the de-indented tail of the function.

sys/net/iflib.c
3464

If I'm reading things correctly, the only functional change is this line. That seems reasonable to me.

The next hunk just seems to invert the logic so as to un-indent the flush. If that's true, thats probably a worthy change, but I think it should be submitted separately.

sys/net/iflib.c
3464

Yes that is correct. I can split these two changes

rcm edited the summary of this revision. (Show Details)
rcm edited the test plan for this revision. (Show Details)

The diff is now just the functional change, the early return in iflib_txd_db_check() when ift_db_pending is 0. The inversion will be posted separately as a no-functional-change follow-up.

This revision is now accepted and ready to land.Mon, Oct 5, 2:53 PM