Eliminating Packet Latency
Quoted 6 lines · * eg Engleder Gerhard | 2016-03-16 08:34:10 [+0100]:
Quoted 4 lines
I found that sometimes when sending network packets, the kernel would hijack the thread of the sender when the queue was empty. This would cause issues, since I had no control over the priority of that thread, since it could be anything. My fix was to never allow the kernel to send in the context of the sending userspace
We had a similar problem and solved it with changed locking:
So the following patch should do the job. Can someone confirm?
From: Sebastian Andrzej Siewior <[email protected]>
Date: Wed, 30 Mar 2016 13:36:29 +0200
Subject: [PATCH] net: dev: always take qdisc's busylock in __dev_xmit_skb()
The root-lock is dropped before dev_hard_start_xmit() is invoked and after setting the __QDISC___STATE_RUNNING bit. If this task is now pushed away by a task with a higher priority then the task with the higher priority 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 task(s) with higher priority leave the CPU and the task with lower priority gets back and finishes the job.
If we take always the busylock we ensure that the RT task can boost the low-prio task and submit the packet.
--- net/core/dev.c | 4 ++++ 1 file changed, 4 insertions(+)
net/core/dev.c +4 -0
@@ -2891,7 +2891,11 @@ static inline int __dev_xmit_skb(struct sk_buff *skb, struct Qdisc *q,* This permits __QDISC___STATE_RUNNING owner to get the lock more * often and dequeue packets faster. */ +#ifdef CONFIG_PREEMPT_RT_FULL + contended = true; +#else contended =qdisc_is_running (q); +#endif if (unlikely (contended))spin_lock (&q->busylock);
Signature · 3 lines
2.8.0.rc3 Sebastian
From: Sebastian Andrzej Siewior [mailto:[email protected]]
Quoted 47 lines
Quoted 7 lines
Quoted 5 lines
I found that sometimes when sending network packets, the kernel would hijack the thread of the sender when the queue was empty. This would cause issues, since I had no control over the priority of that thread, since it could be anything. My fix was to never allow the kernel to send in the context of the sending userspace
We had a similar problem and solved it with changed locking:
So the following patch should do the job. Can someone confirm?
From: Sebastian Andrzej Siewior <[email protected]>
Date: Wed, 30 Mar 2016 13:36:29 +0200
Subject: [PATCH] net: dev: always take qdisc's busylock in__dev_xmit_skb()The root-lock is dropped before
dev_hard_start_xmit()is invoked and after setting the__QDISC___STATE_RUNNINGbit. If this task is now pushed away by a task with a higher priority then the task with the higher priority 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 task(s) with higher priority leave the CPU and the task with lower priority gets back and finishes the job.If we take always the busylock we ensure that the RT task can boost the low-prio task and submit the packet.
Signed-off-by Sebastian Andrzej Siewior <[email protected]>--- net/core/dev.c | 4 ++++ 1 file changed, 4 insertions(+)net/core/dev.c index cc364be3587b..0e17592adbff renamed from net/core/dev.c +0
-0100644
net/core/dev.c +4
-1@@ -2891,7 +2891,11 @@ static inline int __dev_xmit_skb(struct sk_buff *skb,struct Qdisc *q, * This permits __QDISC___STATE_RUNNING owner to get the lock more * often and dequeue packets faster. */ +#ifdef CONFIG_PREEMPT_RT_FULL + contended = true; +#else contended =qdisc_is_running (q); +#endif if (unlikely (contended))spin_lock (&q->busylock); --
Quoted 1 line
2.8.0.rc3
In could not reproduce the problematic situation with v4.4.4-rt11 (without patch) in our test environment. The patch may work, but I am able to confirm that with a test.