Skip to content
  • Eric Dumazet's avatar
    softirq: Let ksoftirqd do its job · 4cd13c21
    Eric Dumazet authored
    A while back, Paolo and Hannes sent an RFC patch adding threaded-able
    napi poll loop support : (https://patchwork.ozlabs.org/patch/620657/)
    
    The problem seems to be that softirqs are very aggressive and are often
    handled by the current process, even if we are under stress and that
    ksoftirqd was scheduled, so that innocent threads would have more chance
    to make progress.
    
    This patch makes sure that if ksoftirq is running, we let it
    perform the softirq work.
    
    Jonathan Corbet summarized the issue in https://lwn.net/Articles/687617/
    
    
    
    Tested:
    
     - NIC receiving traffic handled by CPU 0
     - UDP receiver running on CPU 0, using a single UDP socket.
     - Incoming flood of UDP packets targeting the UDP socket.
    
    Before the patch, the UDP receiver could almost never get CPU cycles and
    could only receive ~2,000 packets per second.
    
    After the patch, CPU cycles are split 50/50 between user application and
    ksoftirqd/0, and we can effectively read ~900,000 packets per second,
    a huge improvement in DOS situation. (Note that more packets are now
    dropped by the NIC itself, since the BH handlers get less CPU cycles to
    drain RX ring buffer)
    
    Since the load runs in well identified threads context, an admin can
    more easily tune process scheduling parameters if needed.
    
    Reported-by: default avatarPaolo Abeni <pabeni@redhat.com>
    Reported-by: default avatarHannes Frederic Sowa <hannes@stressinduktion.org>
    Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
    Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
    Cc: David Miller <davem@davemloft.net>
    Cc: Hannes Frederic Sowa <hannes@redhat.com>
    Cc: Jesper Dangaard Brouer <jbrouer@redhat.com>
    Cc: Jonathan Corbet <corbet@lwn.net>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Rik van Riel <riel@redhat.com>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Link: http://lkml.kernel.org/r/1472665349.14381.356.camel@edumazet-glaptop3.roam.corp.google.com
    
    
    Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
    4cd13c21