Page MenuHomeFreeBSD

iflib: Correct and optimize interrupt handling, assorted fixes and improvements
ClosedPublic

Authored by marius on May 6 2019, 9:12 PM.

Details

Summary
  • Use iflib_fast_intr_rxtx() also for "legacy" interrupts, i. e. INTx and MSI. Unlike as with iflib_fast_intr_ctx(), the former will also enqueue _task_fn_tx() in addition to _task_fn_rx() if appropriate, bringing TCP TX throughput of EM-class devices on par with the MSI-X case and, thus, close to wirespeed/pre-iflib(4) times again. [1] Note that independently of the interrupt type, the UDP performance with these MACs still is abysmal and nowhere near to where it was before the conversion of em(4) to iflib(4).
  • In iflib_init_locked(), announce which free list failed to set up.
  • In _task_fn_tx() when running netmap(4), issue ifdi_intr_enable instead of the ifdi_tx_queue_intr_enable method in case of a "legacy" interrupt as the latter is valid with MSI-X only.
  • Instead of adding the missing - and apparently convoluted enough that a DBG_COUNTER_INC was put into a wrong spot in _task_fn_rx() - checks for ifdi_{r,t}x_queue_intr_enable being available in the MSI-X case also to iflib_fast_intr_rxtx(), factor these out to iflib_device_register() and make the checks fail gracefully rather than panic. This avoids invoking the checks at runtime over and over again in iflib_fast_intr_rxtx() and _task_fn_{r,t}x() - even if it's just in case of INVARIANTS - and makes these functions more readable.
  • In iflib_rx_structures_setup(), only initialize LRO resources if device and driver have LRO capability in order to not waste memory. Also, free the LRO resources again if setting them up fails for one of the queues. However, don't bother invoking iflib_rx_sds_free() in that case because iflib_rx_structures_setup() doesn't call iflib_rxsd_alloc() either (and iflib_{device,pseudo}_register() will issue iflib_rx_sds_free() in case of failure via iflib_rx_structures_free(), but there definitely is some asymmetry left to be fixed, though).
  • Similarly, free LRO resources again in iflib_rx_structures_free().
  • In iflib_irq_set_affinity(), handle get_core_offset() errors gracefully instead of panicing (but only in case of INVARIANTS). This is a follow- up to r344132, as such driver bugs shouldn't be fatal.
  • Likewise, handle unknown iflib_intr_type_t in iflib_irq_alloc_generic() gracefully, too.
  • Bring yet more sanity to iflib_msix_init():
    • If the device doesn't provide enough MSI-X vectors or not all vectors can be allocate so the expected number of queues in addition to admin interrupts can't be supported, try MSI next (and then INTx) as proper MSI-X vector distribution can't be assured in such cases. In essence, this change brings r254008 forward to iflib(4). Also, this is the fix alluded to in the commit message of r343934.
    • If the MSI-X allocation has failed, don't prematurely announce MSI is going to be used as the latter in fact may not be available either.
    • When falling back to MSI, only release the MSI-X table resource again if it was allocated in iflib_msix_init(), i. e. isn't supplied by the driver, in the first place.
  • In mp_ndesc_handler(), handle unknown type arguments gracefully, too.

PR: 235031 (likely) [1]

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

marius created this revision.May 6 2019, 9:12 PM
Herald added 1 blocking reviewer(s): iflib. · View Herald Transcript
Herald added subscribers: ae, imp. · View Herald Transcript
shurd accepted this revision.May 6 2019, 10:08 PM

Phew, great job. I've always been a bit uneasy about the MSI/INTx stuff, but this seems to have cleared everything up.

Regarding the string wrapping, I don't think there's an official rule about it either way, I just don't like it. Approved as-is, but it would be even more approved without the breaks in strings.

This revision is now accepted and ready to land.May 6 2019, 10:08 PM
This revision was automatically updated to reflect the committed changes.