• Christian Marangi's avatar
    net: stmmac: improve TX timer arm logic · 2d1a42cf
    Christian Marangi authored
    There is currently a problem with the TX timer getting armed multiple
    unnecessary times causing big performance regression on some device that
    suffer from heavy handling of hrtimer rearm.
    
    The use of the TX timer is an old implementation that predates the napi
    implementation and the interrupt enable/disable handling.
    
    Due to stmmac being a very old code, the TX timer was never evaluated
    again with this new implementation and was kept there causing
    performance regression. The performance regression started to appear
    with kernel version 4.19 with 8fce3331 ("net: stmmac: Rework coalesce
    timer and fix multi-queue races") where the timer was reduced to 1ms
    causing it to be armed 40 times more than before.
    
    Decreasing the timer made the problem more present and caused the
    regression in the other of 600-700mbps on some device (regression where
    this was notice is ipq806x).
    
    The problem is in the fact that handling the hrtimer on some target is
    expensive and recent kernel made the timer armed much more times.
    A solution that was proposed was reverting the hrtimer change and use
    mod_timer but such solution would still hide the real problem in the
    current implementation.
    
    To fix the regression, apply some additional logic and skip arming the
    timer when not needed.
    
    Arm the timer ONLY if a napi is not already scheduled. Running the timer
    is redundant since the same function (stmmac_tx_clean) will run in the
    napi TX poll. Also try to cancel any timer if a napi is scheduled to
    prevent redundant run of TX call.
    
    With the following new logic the original performance are restored while
    keeping using the hrtimer.
    Signed-off-by: default avatarChristian Marangi <ansuelsmth@gmail.com>
    Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
    2d1a42cf
stmmac_main.c 215 KB