From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Eric Dumazet <edumazet@google.com>
Cc: Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH net-next] net: dev: Always serialize on Qdisc::busylock in __dev_xmit_skb() on PREEMPT_RT.
Date: Fri, 10 Dec 2021 18:43:17 +0100 [thread overview]
Message-ID: <YbORtbuORp7HJGUl@linutronix.de> (raw)
In-Reply-To: <CANn89i+zyeMJVhNmEEhwE0oaRvD-m0ZR9w1+ScsvpWZEuP9G5Q@mail.gmail.com>
On 2021-12-10 08:52:55 [-0800], Eric Dumazet wrote:
>
> Problem is that if you have a qdisc, qdisc_dequeue() will not know that the
> packet queued by high prio thread needs to shortcut all prior packets and
> be sent right away.
That is correct.
> Because of that, it seems just better that a high prio thread returns
> immediately and let the dirty work (dequeue packets and send them to devices)
> be done by other threads ?
Ah okay. Lets say you have a task sending a packet every 100ms. And you
want that packet to leave the NIC asap. This is your task with
SCHED_FIFO 70 priority. IMPORTANT otherwise.
Lets say you have a ssh session on the same NIC running at SCHED_OTHER.
Nothing important obviously.
The NIC is idle, ssh sends a keep-alive, 80 bytes, one skb.
SCHED_OTHER, SSH, CPU0 FIFO 70, IMPORTANT, CPU1
__dev_xmit_skb()
-> spin_lock(root_lock);
-> qdisc_run_begin()
-> __test_and_set_bit(__QDISC_STATE2_RUNNING);
-> sch_direct_xmit()
*PREEMPT* (by something else)
__dev_xmit_skb()
-> spin_lock(root_lock);
<--- PI-boost
-> spin_unlock(root_lock);
*PREEMPT* again ---> PI boost ends after unlock
-> qdisc_run_begin()
-> __test_and_set_bit(__QDISC_STATE2_RUNNING) (nope);
-> dev_qdisc_enqueue()
-> qdisc_run_begin() returns false
-> spin_unlock(root_lock);
at this point, we don't return to the SSH thread, instead other RT tasks
are running. That means that the SSH thread, which owns the qdisc and
the NIC, remains preempted and the NIC idle.
300ms pass by, the IMPORTANT thread queued two additional packets.
Now, a few usecs later, all SCHED_FIFO tasks go idle on CPU0, and the
SSH thread can continue with dev_hard_start_xmit() and send its packet,
-> dev_hard_start_xmit()
__qdisc_run() (yes, and the three additional packets)
…
By always acquiring the busy-lock, in the previous scenario, the task
with the high-priority allows the low-priority task to run until
qdisc_run_end() at which point it releases the qdisc so the
high-priority task can actually send packets.
One side note: This scenario requires two CPUs (one for low priority
task that gets preempted and owns the qdisc, and one one for high
priority task that wants to sends packets).
With one CPU only the local_bh_disable() invocation would ensure that
low-priority thread left the bh-disable section entirely.
> > > Thanks!
> > >
> > > Paolo
> >
Sebastian
next prev parent reply other threads:[~2021-12-10 17:43 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
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=YbORtbuORp7HJGUl@linutronix.de \
--to=bigeasy@linutronix.de \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=tglx@linutronix.de \
/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 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).