All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: eg Engleder Gerhard <eg@keba.com>
Cc: Dave Rolenc <drolenc@rtlogic.com>,
	Michael Hewitt <mhewitt@aha.com>,
	"linux-rt-users@vger.kernel.org" <linux-rt-users@vger.kernel.org>
Subject: Re: Eliminating Packet Latency
Date: Wed, 30 Mar 2016 15:08:10 +0200	[thread overview]
Message-ID: <20160330130810.GC21849@linutronix.de> (raw)

* eg Engleder Gerhard | 2016-03-16 08:34:10 [+0100]:

>> 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 <bigeasy@linutronix.de>
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.

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

diff --git a/net/core/dev.c b/net/core/dev.c
index cc364be3587b..0e17592adbff 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -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);
 
-- 
2.8.0.rc3

Sebastian

             reply	other threads:[~2016-03-30 13:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-30 13:08 Sebastian Andrzej Siewior [this message]
2016-03-31 11:13 ` AW: Eliminating Packet Latency eg Engleder Gerhard
  -- strict thread matches above, loose matches on Subject: below --
2016-03-14 21:02 Michael Hewitt
2016-03-14 21:29 ` Dave Rolenc
2016-03-15  8:55 ` Stanislav Meduna
2016-03-15 17:24   ` Dave Rolenc
2016-03-15 19:22 ` Giuliano Colla

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160330130810.GC21849@linutronix.de \
    --to=bigeasy@linutronix.de \
    --cc=12C1B74BDFD05D40B2356A9B12DFA3396C365B9764@KEBMXSPMB01.keba.co.at \
    --cc=drolenc@rtlogic.com \
    --cc=eg@keba.com \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=mhewitt@aha.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.