Skip to content

Commit

Permalink
net: dev: Always serialize on Qdisc::busylock in __dev_xmit_skb() on …
Browse files Browse the repository at this point in the history
…PREEMPT_RT.

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>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Sebastian Andrzej Siewior authored and David S. Miller committed Dec 13, 2021
1 parent 93d576f commit 64445dd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -3719,8 +3719,12 @@ 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);
contended = IS_ENABLED(CONFIG_PREEMPT_RT) || qdisc_is_running(q);
if (unlikely(contended))
spin_lock(&q->busylock);

Expand Down

0 comments on commit 64445dd

Please sign in to comment.