General list for discussing Bufferbloat
 help / color / mirror / Atom feed
From: "Toke Høiland-Jørgensen" <toke@toke.dk>
To: Jonathan Morton <chromatix99@gmail.com>
Cc: Sebastian Moeller <moeller0@gmx.de>, bloat@lists.bufferbloat.net
Subject: Re: [Bloat] CAKE in openwrt high CPU
Date: Tue, 01 Sep 2020 23:09:10 +0200	[thread overview]
Message-ID: <87lfhti4qx.fsf@toke.dk> (raw)
In-Reply-To: <48FC5B6D-21B6-4A5E-88DC-18FF03BE47C0@gmail.com>

Jonathan Morton <chromatix99@gmail.com> writes:

>> On 1 Sep, 2020, at 9:45 pm, Toke Høiland-Jørgensen via Bloat <bloat@lists.bufferbloat.net> wrote:
>> 
>> CAKE takes the global qdisc lock.
>
> Presumably this is a default mechanism because CAKE doesn't handle any
> locking itself.
>
> Obviously it would need to be replaced with at least a lock over
> CAKE's complete data structures, taking the lock on each entry point
> and releasing it at each return point, and I assume there is a flag we
> can set to indicate we do so. Finer-grained locking might be possible,
> but CAKE is fairly complex so that might be hard to implement. Locking
> per CAKE instance would at least allow running ingress and egress on
> different CPUs.

What you're describing here is basically the existing qdisc root lock.
It is per instance of the qdisc, and it is held only while enqueueing
and dequeueing packets from that qdisc. So it is possible today to run
the ingress and egress instances of CAKE on different CPUs. All you have
to do is schedule the packets to be processed on different CPUs in the
different directions - which usually means messing with RPS settings for
the NIC, and as I remarked to Sebastian, for many OpenWrt SOCs this is
not really supported...

To make CAKE truly take advantage of multiple CPUs, there are to
options:

1. Make it aware of multiple hardware queues. To do this, we to
   implement the 'attach()' method in the Qdisc_ops struct (see sch_mq
   for an example). The idea here would be to create stub child qdiscs
   with a separate struct Qdisc_ops implementing enqueue() and
   dequeue(). These would be called separately for each hardware queue,
   with their separate locks held at the time; and with proper XPS
   steering, each hardware queue can be serviced by a separate CPU.

2. Set the TCQ_F_NOLOCK in the qdisc flags; this will cause the existing
   enqueue() and dequeue() functions to be called without the root lock
   being held, and the qdisc is responsible for dealing with that
   itself.

Of course in either case, the trick is to get the CAKE data structures
to play nice with concurrent access from multiple CPUs. For option 1.
above, we could just duplicate all the flow queues for each netdev queue
and take the hit in wasted space - or we could partition the data
structure, either statically at init, or dynamically as each flow
becomes active. But at a minimum there would need to be some way for the
shaper to enforce the maximum rate. Maybe a granular lock or an atomic
is good enough for this, though?

Note also that for 2. there's an ongoing issue[0] with packets getting
stuck which is still unresolved, as far as I can tell - so not sure if
this is the right way to go. However, apart from this, the benefit of 2.
is that CAKE could *potentially* process packets on multiple CPUs
without relying on hardware multi-Q. I'm not quite sure if the stack
will actually process packets on more than one CPU without them,
though.

Either way, I suppose some experimentation would be needed to find the
best solution.

-Toke

[0] https://lore.kernel.org/netdev/CACS=qq+a0H=e8yLFu95aE7Hr0bQ9ytCBBn2rFx82oJnPpkBpvg@mail.gmail.com/

  reply	other threads:[~2020-09-01 21:09 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-30 17:27 Mikael Abrahamsson
2020-08-30 17:52 ` Dave Taht
2020-08-31 11:35 ` Toke Høiland-Jørgensen
2020-08-31 12:22   ` Mikael Abrahamsson
2020-08-31 13:29     ` Toke Høiland-Jørgensen
2020-09-03 13:10       ` Mikael Abrahamsson
2020-09-03 13:29         ` Toke Høiland-Jørgensen
2020-09-03 13:34           ` Sebastian Moeller
2020-09-03 13:32         ` Sebastian Moeller
2020-09-04 13:37           ` Mikael Abrahamsson
2020-09-04 14:12             ` Sebastian Moeller
2020-09-01 15:41   ` Jonathan Foulkes
2020-09-01 16:11     ` Toke Høiland-Jørgensen
2020-09-01 16:25       ` Sebastian Moeller
2020-09-01 18:45         ` Toke Høiland-Jørgensen
2020-09-01 19:05           ` Jonathan Morton
2020-09-01 21:09             ` Toke Høiland-Jørgensen [this message]
2020-09-01 19:01       ` Jonathan Foulkes
2020-09-01 21:11         ` Toke Høiland-Jørgensen
2020-09-02 20:26           ` Jonathan Foulkes
2020-09-02 20:57             ` Toke Høiland-Jørgensen
2020-09-03 13:19           ` Mikael Abrahamsson
2020-09-03 13:27             ` Luca Muscariello
2020-09-03 14:32               ` Toke Høiland-Jørgensen
2020-09-03 15:31                 ` Luca Muscariello
2020-09-03 18:39                   ` Toke Høiland-Jørgensen
2020-09-03 18:53                 ` Jonathan Morton
2020-09-03 22:14                 ` [Bloat] Other CAKE territory (was: CAKE in openwrt high CPU) David Collier-Brown
2020-09-04  1:19                   ` Jonathan Morton
2020-09-04 13:41                     ` Mikael Abrahamsson
2020-09-04 11:11                   ` Toke Høiland-Jørgensen
2020-09-03 13:27             ` [Bloat] CAKE in openwrt high CPU Toke Høiland-Jørgensen
2020-09-01 16:18     ` Sebastian Moeller
2020-09-01 19:31       ` Jonathan Foulkes
2020-09-01 20:04         ` Sebastian Moeller
2020-09-01 20:09           ` Jonathan Morton

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

  List information: https://lists.bufferbloat.net/postorius/lists/bloat.lists.bufferbloat.net/

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

  git send-email \
    --in-reply-to=87lfhti4qx.fsf@toke.dk \
    --to=toke@toke.dk \
    --cc=bloat@lists.bufferbloat.net \
    --cc=chromatix99@gmail.com \
    --cc=moeller0@gmx.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