From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mail.toke.dk; spf=pass smtp.mailfrom=; dkim=pass header.d=gmail.com; arc=none (Message is not ARC signed); dmarc=pass (Used From Domain Record) header.from=gmail.com policy.dmarc=quarantine Received: from mail-yw1-x112d.google.com (mail-yw1-x112d.google.com [IPv6:2607:f8b0:4864:20::112d]) by mail.toke.dk (Postfix) with ESMTPS id 9DEDB9E798E for ; Sun, 30 Nov 2025 17:58:08 +0100 (CET) Received: by mail-yw1-x112d.google.com with SMTP id 00721157ae682-78a712cfbc0so33443047b3.1 for ; Sun, 30 Nov 2025 08:58:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764521886; x=1765126686; darn=lists.bufferbloat.net; h=content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=U0pM2tOIKARyUScLUv8P7Syt5GLsdtd8jm51t8qeyVE=; b=kcB6HfImbXN86KBNKM533jlulXn+1DyiPXJwBGilv81nuICRCdA7frZKaDLRUyajn+ IECMQjwYiiFZpg18mnRk4blVbIYyounNxjwXSnOs5CyGOCGRQgb3EX6+pTN+cjL82ZpX KTfM4a7QR7oNHhHP9FS+qXInd77IJMJEB1JRtu/rossN+MoJV2jHGDyLzbw7GIDxkfpG 0L3Yrpwhmsva1HGEL/qXJvpCw9R6cHKsv4gzMSEz6gKs0KREPOUozKLg7rLN/VQKgVsA YSW9Lq+0tdSPmzuF+pqyIQ0zrGTlYBhHB0fI8hvqJxgaaQyCskwVkiDwVb6c6RqCGzeM KDrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764521886; x=1765126686; h=content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=U0pM2tOIKARyUScLUv8P7Syt5GLsdtd8jm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cAcunVhl4xdASEyLgUo6OszFLPJBmopRuvwgU+l/U= X-Google-Smtp-Source: AGHT+IF3rgBa1ZcQ/kU4IUpA3oBhV19YeCk8Jh6DRPERGlRUlXwMw433U6ZZLF9efabXoGwSWtpkKw== X-Received: by 2002:a05:690c:3510:b0:781:4b2d:7261 with SMTP id 00721157ae682-78a8b52932cmr257020527b3.41.1764521886147; Sun, 30 Nov 2025 08:58:06 -0800 (PST) Received: from gmail.com (116.235.236.35.bc.googleusercontent.com. [35.236.235.116]) by smtp.gmail.com with UTF8SMTPSA id 00721157ae682-78ad0d3f5bbsm38926397b3.7.2025.11.30.08.58.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Nov 2025 08:58:05 -0800 (PST) Date: Sun, 30 Nov 2025 11:58:05 -0500 From: Willem de Bruijn To: =?UTF-8?B?VG9rZSBIw7hpbGFuZC1Kw7hyZ2Vuc2Vu?= , Willem de Bruijn , Willem de Bruijn , Willem de Bruijn , Jamal Hadi Salim , Cong Wang , Jiri Pirko , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: =?UTF-8?B?Sm9uYXMgS8O2cHBlbGVy?= , cake@lists.bufferbloat.net, netdev@vger.kernel.org Message-ID: In-Reply-To: <87tsyba3wx.fsf@toke.dk> References: <20251127-mq-cake-sub-qdisc-v2-0-24d9ead047b9@redhat.com> <20251127-mq-cake-sub-qdisc-v2-2-24d9ead047b9@redhat.com> <87a505b3dt.fsf@toke.dk> <87zf84ab2d.fsf@toke.dk> <87tsyba3wx.fsf@toke.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-MailFrom: willemdebruijn.kernel@gmail.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation Message-ID-Hash: VMRWKKJV2QDAVFVZU6M4TGPIAB5A57LN X-Message-ID-Hash: VMRWKKJV2QDAVFVZU6M4TGPIAB5A57LN X-Mailman-Approved-At: Sun, 30 Nov 2025 20:49:44 +0100 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Cake] Re: [PATCH net-next v2 2/4] net/sched: sch_cake: Add cake_mq qdisc for using cake on mq devices List-Id: Cake - FQ_codel the next generation Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Toke H=C3=B8iland-J=C3=B8rgensen wrote: > Willem de Bruijn writes: > = > > Toke H=C3=B8iland-J=C3=B8rgensen wrote: > >> Willem de Bruijn writes: > >> = > >> > Toke H=C3=B8iland-J=C3=B8rgensen wrote: > >> >> Willem de Bruijn writes: > >> >> = > >> >> > Toke H=C3=B8iland-J=C3=B8rgensen wrote: > >> >> >> Add a cake_mq qdisc which installs cake instances on each hard= ware > >> >> >> queue on a multi-queue device. > >> >> >> = > >> >> >> This is just a copy of sch_mq that installs cake instead of th= e default > >> >> >> qdisc on each queue. Subsequent commits will add sharing of th= e config > >> >> >> between cake instances, as well as a multi-queue aware shaper = algorithm. > >> >> >> = > >> >> >> Reviewed-by: Jamal Hadi Salim > >> >> >> Signed-off-by: Toke H=C3=B8iland-J=C3=B8rgensen > >> >> >> --- > >> >> >> 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. Ha= ve the > >> >> > cake instances share it directly. E.g., where all but the insta= nce on > >> >> > netdev_get_tx_queue(dev, 0) are opened in a special "shared" mo= de (a > >> >> > bit like SO_REUSEPORT sockets) and lookup the state from that > >> >> > instance. > >> >> = > >> >> We actually started out with something like that, but ended up wi= th the > >> >> current variant for primarily UAPI reasons: Having the mq variant= be a > >> >> separate named qdisc is simple and easy to understand ('cake' get= s 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 th= at 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/commi= t/?h=3Dmq-cake-sub-qdisc&id=3Dfdb6891cc584a22d4823d771a602f9f1ee56eeae > > > > Great. That's good enough for me. > = > Cool. I folded it into the series, and it does make the patch a lot > simpler, so thank you for the suggestion! > = > >> > 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 initia= lly, > >> but went with this implementation from a configuration simplicity > >> consideration. = > > > > Then admins have only to install one qdisc, rather than what we do fo= r > > FQ today which is one MQ + a loop over the FQs. > > > > I don't know if we have to coddle admins like that. > = > I don't really view it as coddling, but as making it as easy as possibl= e > to take advantage of the mq variant in the most common configuration. > The primary use case for cake is shaping on the whole link (on home > routers, in particular), and the mq extension came about to address the= > common bottleneck here where the cake shaper can't keep up with link > speeds on a single CPU. So I think it's worthwhile to make it as easy a= s > possible to consume that seems worthwhile, in a way that retains > compatibility with the existing tools that work on top of cake, such as= > the autorate scripts: > = > https://github.com/sqm-autorate/sqm-autorate > = > >> 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-ca= ke > >> 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? > = > Yeah, I do think it's doable; just needs a bit of thought around the > lifetime management of the shared config struct as sub-qdiscs come and > go. > = > I am not necessarily opposed to supporting this mode, including the cas= e > where there's a mix of qdiscs on different HW queues. However, I view i= t > as an extension of the base use case, as described above. Now that we'r= e > reusing the mq code, cake_mq becomes quite a lightweight addition, so w= e > could potentially support both? I.e., the cake_mq qdisc would be the > straight-forward way to load cake across a device, but we could add > support for sharing cake state across (a subset of) regular mq as well?= > WDYT? I'd only plan to do it once, do it right. mq_cake has the advantage of being simpler to configure. The alternative that it allows more configurations. But we don't immediately see real use cases for those. Your call, assuming no one else chimes in.