net/core: Enable socket busy polling on -RT
Subsystems (2)
RFC PATCH 1/1 net/core: Enable socket busy polling on -RT
Busy polling is currently not allowed on PREEMPT_RT, because it disables preemption. It is not possible to acquire sleeping locks with disabled preemption. For details see commit 20ab39d13e2e ("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_lock owner to be preempted while holding the lock and to ensure progress. To overcome that problem on -RT, allow busy polling only in case the netconsole (and netpoll) is not used. No functional change for upstream.
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.
--- net/Kconfig | 2 +- net/core/dev.c | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-)
net/Kconfig +1 -1
@@ -324,7 +324,7 @@ config CGROUP_NET_CLASSID config NET_RX_BUSY_POLL bool - default y if !PREEMPT_RT + default y if !PREEMPT_RT || (PREEMPT_RT && !NETCONSOLE) config BQL bool
net/core/dev.c +6 -3
@@ -6197,7 +6197,8 @@ void napi_busy_loop(unsigned int napi_id,if (!napi) goto out; -preempt_disable (); +if (!IS_ENABLED (CONFIG_PREEMPT_RT )) +preempt_disable ();for (;;) {int work =0 ;
@@ -6239,7 +6240,8 @@ void napi_busy_loop(unsigned int napi_id,if (unlikely (need_resched ())) {if (napi_poll)busy_poll_stop (napi, have_poll_lock, prefer_busy_poll, budget); -preempt_enable (); +if (!IS_ENABLED (CONFIG_PREEMPT_RT )) +preempt_enable ();rcu_read_unlock ();cond_resched ();if (loop_end (loop_end_arg, start_time))
@@ -6250,7 +6252,8 @@ void napi_busy_loop(unsigned int napi_id, }if (napi_poll)busy_poll_stop (napi, have_poll_lock, prefer_busy_poll, budget); -preempt_enable (); +if (!IS_ENABLED (CONFIG_PREEMPT_RT )) +preempt_enable (); out:rcu_read_unlock (); }
Signature · 1 line
2.30.2