netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: dev: Always serialize on Qdisc::busylock in __dev_xmit_skb() on PREEMPT_RT.
@ 2021-12-10 15:41 Sebastian Andrzej Siewior
  2021-12-10 16:35 ` Paolo Abeni
  2021-12-11  4:32 ` Jakub Kicinski
  0 siblings, 2 replies; 16+ messages in thread
From: Sebastian Andrzej Siewior @ 2021-12-10 15:41 UTC (permalink / raw)
  To: netdev; +Cc: David S. Miller, Jakub Kicinski, Eric Dumazet, Thomas Gleixner

The root-lock is dropped before dev_hard_start_xmit() is invoked and after
setting the __QDISC___STATE_RUNNING bit. If the Qdisc owner is preempted
by another sender/task with a higher priority then this new sender won't
be able to submit packets to the NIC directly instead they will be
enqueued into the Qdisc. The NIC will remain idle until the Qdisc owner
is scheduled again and finishes the job.

By serializing every task on the ->busylock then the task will be
preempted by a sender only after the Qdisc has no owner.

Always serialize on the busylock on PREEMPT_RT.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 net/core/dev.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index 2a352e668d103..4a701cf2e2c10 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3836,8 +3836,16 @@ static inline int __dev_xmit_skb(struct sk_buff *skb, struct Qdisc *q,
 	 * separate lock before trying to get qdisc main lock.
 	 * This permits qdisc->running owner to get the lock more
 	 * often and dequeue packets faster.
+	 * On PREEMPT_RT it is possible to preempt the qdisc owner during xmit
+	 * and then other tasks will only enqueue packets. The packets will be
+	 * sent after the qdisc owner is scheduled again. To prevent this
+	 * scenario the task always serialize on the lock.
 	 */
-	contended = qdisc_is_running(q);
+	if (!IS_ENABLED(CONFIG_PREEMPT_RT))
+		contended = qdisc_is_running(q);
+	else
+		contended = true;
+
 	if (unlikely(contended))
 		spin_lock(&q->busylock);
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2021-12-14 12:40 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-10 15:41 [PATCH net-next] net: dev: Always serialize on Qdisc::busylock in __dev_xmit_skb() on PREEMPT_RT Sebastian Andrzej Siewior
2021-12-10 16:35 ` Paolo Abeni
2021-12-10 16:46   ` Sebastian Andrzej Siewior
2021-12-10 16:52     ` Eric Dumazet
2021-12-10 17:43       ` Sebastian Andrzej Siewior
2021-12-13 10:27     ` Paolo Abeni
2021-12-11  4:32 ` Jakub Kicinski
2021-12-13 10:45   ` Sebastian Andrzej Siewior
2021-12-13 10:53     ` [PATCH v2 " Sebastian Andrzej Siewior
2021-12-13 15:00       ` patchwork-bot+netdevbpf
2021-12-13 16:15     ` [PATCH " Jakub Kicinski
2021-12-13 16:18       ` Sebastian Andrzej Siewior
2021-12-13 16:20         ` Jakub Kicinski
2021-12-13 16:32           ` Sebastian Andrzej Siewior
2021-12-13 16:29       ` [PATCH net-next] net: dev: Change the order of the arguments for the contended condition Sebastian Andrzej Siewior
2021-12-14 12:40         ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).