• Kurt Kanzenbach's avatar
    net/core: Enable socket busy polling on -RT · c857946a
    Kurt Kanzenbach authored
    Busy polling is currently not allowed on PREEMPT_RT, because it disables
    preemption while invoking the NAPI callback. It is not possible to acquire
    sleeping locks with disabled preemption. For details see commit
    20ab39d1 ("net/core: disable NET_RX_BUSY_POLL on PREEMPT_RT").
    
    However, strict cyclic and/or low latency network applications may prefer busy
    polling e.g., using AF_XDP instead of interrupt driven communication.
    
    The preempt_disable() is used in order to prevent the poll_owner and NAPI owner
    to be preempted while owning the resource to ensure progress. Netpoll performs
    busy polling in order to acquire the lock. NAPI is locked by setting the
    NAPIF_STATE_SCHED flag. There is no busy polling if the flag is set and the
    "owner" is preempted. Worst case is that the task owning NAPI gets preempted and
    NAPI processing stalls.  This is can be prevented by properly prioritising the
    tasks within the system.
    
    Allow RX_BUSY_POLL on PREEMPT_RT if NETPOLL is disabled. Don't disable
    preemption on PREEMPT_RT within the busy poll loop.
    
    Tested on x86 hardware with v6.1-RT and v6.3-RT on Intel i225 (igc) with
    AF_XDP/ZC sockets configured to run in busy polling mode.
    Suggested-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
    Signed-off-by: Kurt Kanzenbach's avatarKurt Kanzenbach <kurt@linutronix.de>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    c857946a
dev.c 289 KB