• J
    i40e: invert logic for checking incorrect cpu vs irq affinity · 6d977729
    Jacob Keller 提交于
    In commit 96db776a ("i40e/vf: fix interrupt affinity bug")
    we added some code to force exit of polling in case we did
    not have the correct CPU. This is important since it was possible for
    the IRQ affinity to be changed while the CPU is pegged at 100%. This can
    result in the polling routine being stuck on the wrong CPU until
    traffic finally stops.
    
    Unfortunately, the implementation, "if the CPU is correct, exit as
    normal, otherwise, fall-through to the end-polling exit" is incredibly
    confusing to reason about. In this case, the normal flow looks like the
    exception, while the exception actually occurs far away from the if
    statement and comment.
    
    We recently discovered and fixed a bug in this code because we were
    incorrectly initializing the affinity mask.
    
    Re-write the code so that the exceptional case is handled at the check,
    rather than having the logic be spread through the regular exit flow.
    This does end up with minor code duplication, but the resulting code is
    much easier to reason about.
    
    The new logic is identical, but inverted. If we are running on a CPU not
    in our affinity mask, we'll exit polling. However, the code flow is much
    easier to understand.
    
    Note that we don't actually have to check for MSI-X, because in the MSI
    case we'll only have one q_vector, but its default affinity mask should
    be correct as it includes all CPUs when it's initialized. Further, we
    could at some point add code to setup the notifier for the non-MSI-X
    case and enable this workaround for that case too, if desired, though
    there isn't much gain since its unlikely to be the common case.
    Signed-off-by: NJacob Keller <jacob.e.keller@intel.com>
    Tested-by: NAndrew Bowers <andrewx.bowers@intel.com>
    Signed-off-by: NJeff Kirsher <jeffrey.t.kirsher@intel.com>
    6d977729
i40e_txrx.c 95.4 KB