[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <willemdebruijn.kernel.12cce168f29d0@gmail.com>
Date: Sun, 30 Nov 2025 10:07:17 -0500
From: Willem de Bruijn <willemdebruijn.kernel@...il.com>
To: Toke Høiland-Jørgensen <toke@...e.dk>,
Willem de Bruijn <willemdebruijn.kernel@...il.com>,
Willem de Bruijn <willemdebruijn.kernel@...il.com>,
Jamal Hadi Salim <jhs@...atatu.com>,
Cong Wang <xiyou.wangcong@...il.com>,
Jiri Pirko <jiri@...nulli.us>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Simon Horman <horms@...nel.org>
Cc: Jonas Köppeler <j.koeppeler@...berlin.de>,
cake@...ts.bufferbloat.net,
netdev@...r.kernel.org
Subject: Re: [PATCH net-next v2 2/4] net/sched: sch_cake: Add cake_mq qdisc
for using cake on mq devices
Toke Høiland-Jørgensen wrote:
> Willem de Bruijn <willemdebruijn.kernel@...il.com> writes:
>
> > Toke Høiland-Jørgensen wrote:
> >> Willem de Bruijn <willemdebruijn.kernel@...il.com> writes:
> >>
> >> > Toke Høiland-Jørgensen wrote:
> >> >> Add a cake_mq qdisc which installs cake instances on each hardware
> >> >> queue on a multi-queue device.
> >> >>
> >> >> This is just a copy of sch_mq that installs cake instead of the default
> >> >> qdisc on each queue. Subsequent commits will add sharing of the config
> >> >> between cake instances, as well as a multi-queue aware shaper algorithm.
> >> >>
> >> >> Reviewed-by: Jamal Hadi Salim <jhs@...atatu.com>
> >> >> Signed-off-by: Toke Høiland-Jørgensen <toke@...hat.com>
> >> >> ---
> >> >> net/sched/sch_cake.c | 214 ++++++++++++++++++++++++++++++++++++++++++++++++++-
> >> >> 1 file changed, 213 insertions(+), 1 deletion(-)
> >> >
> >> > Is this code duplication unavoidable?
> >> >
> >> > Could the same be achieved by either
> >> >
> >> > extending the original sch_mq to have a variant that calls the
> >> > custom cake_mq_change.
> >> >
> >> > Or avoid hanging the shared state off of parent mq entirely. Have the
> >> > cake instances share it directly. E.g., where all but the instance on
> >> > netdev_get_tx_queue(dev, 0) are opened in a special "shared" mode (a
> >> > bit like SO_REUSEPORT sockets) and lookup the state from that
> >> > instance.
> >>
> >> We actually started out with something like that, but ended up with the
> >> current variant for primarily UAPI reasons: Having the mq variant be a
> >> separate named qdisc is simple and easy to understand ('cake' gets you
> >> single-queue, 'cake_mq' gets you multi-queue).
> >>
> >> I think having that variant live with the cake code makes sense. I
> >> suppose we could reuse a couple of the mq callbacks by exporting them
> >> and calling them from the cake code and avoid some duplication that way.
> >> I can follow up with a patch to consolidate those if you think it is
> >> worth it to do so?
> >
> > Since most functions are identical, I do think reusing them is
> > preferable over duplicating them.
>
> Sure, that's fair. Seems relatively straight forward too:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/toke/linux.git/commit/?h=mq-cake-sub-qdisc&id=fdb6891cc584a22d4823d771a602f9f1ee56eeae
Great. That's good enough for me.
> > I'm not fully convinced that mq_cake + cake is preferable over
> > mq + cake (my second suggestion). We also do not have a separate
> > mq_fq, say. But mine is just one opinion from the peanut gallery.
>
> Right, I do see what you mean; as I said we did consider this initially,
> but went with this implementation from a configuration simplicity
> consideration.
Then admins have only to install one qdisc, rather than what we do for
FQ today which is one MQ + a loop over the FQs.
I don't know if we have to coddle admins like that.
> If we were to implement this as an option when running
> under the existing mq, we'd have to add an option to cake itself to opt
> in to this behaviour, and then deal with the various combinations of
> sub-qdiscs being added and removed (including mixing cake and non-cake
> sub-qdiscs of the same mq). And userspace would have to setup the mq,
> then manually add the cake instances with the shared flag underneath it.
One question is whether the kernel needs to protect admins from doing
the unexpected thing, which would be mixing mq children of different
type when using shared cake state between children.
Honestly, I don't think so. But it could be done. For instance by
adding an mq option that requires all children to be of the same kind,
or even by silently setting this if the first child added is a cake
instance with shared option set.
As for shared state, in cake_init the qdisc could check that the dev
root is mq and it is a direct child of this qdisc, and then scan the
mq children for the existence of a cake child. If one exists, take a
ref on a shared state struct. If not, create the struct. Again, like
SO_REUSEPORT.
All easier said than implemented, of course, but seems doable?
> Whereas with this cake_mq qdisc the user interface is as simple as
> possible: just substitute 'cake_mq' for 'cake' if you want the
> multi-queue behaviour on a device; everything else stays the same. Since
> configuration simplicity is an explicit goal of cake, I think this is
> appropriate; although it may not be for other qdiscs.
>
> Hope that makes sense?
>
> -Toke
Powered by blists - more mailing lists