From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8CAA5C10F11 for ; Wed, 10 Apr 2019 15:01:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 64ACB2083E for ; Wed, 10 Apr 2019 15:01:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732988AbfDJPBZ convert rfc822-to-8bit (ORCPT ); Wed, 10 Apr 2019 11:01:25 -0400 Received: from mail-lf1-f46.google.com ([209.85.167.46]:39261 "EHLO mail-lf1-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732933AbfDJPBZ (ORCPT ); Wed, 10 Apr 2019 11:01:25 -0400 Received: by mail-lf1-f46.google.com with SMTP id z9so2083593lfh.6 for ; Wed, 10 Apr 2019 08:01:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:in-reply-to:references:date :message-id:mime-version:content-transfer-encoding; bh=s9T47Atu+AhMeM3pcR495XSiCEGheRqKU11QRyEjwFY=; b=IZ7JjSay24DGkEEU+rXVifKzO21AupdRQnEQtZvS9sb63q6WKeudY5C49MPmgOjazm zrObvEpzNgxSAPUxKd3r6J+vIZrs2kCAE6PLPSFxMC0hquip4DWD/ugnnKonh18G8GxJ MTOLp3gimDyN1yO01FSKvvCfIujmJ7nWx5Nwp7iIqR5WPBjL0G0eXxolYKz14cwsuMs/ 69hu/MUfXOmyY9CtQyGNSPSn3gcBfwvCpIlFkQBpiC1w8JBhd2OvFE3+2aHmr6bv+AMq 6cj4+S6Wnvb1LJ77yypMgo1MjNf0Z6Fu5ieJfyZZt9xZQqBCFccONOlggVFZwaX4erss M90A== X-Gm-Message-State: APjAAAUYN8lFPlZtuANWl641rJvNJEYFrzRg64L2cVOFSzQl62o2wsL6 JXn2F+u9QzWgCVOkWp0BgTtaLw== X-Google-Smtp-Source: APXvYqxTWxmNBuDbpJBYCnb6ckawueO9Dr5QU8K8V9b7CzlZYUqBIQPqu4MzCM4lUkPiiR8/vCpDfw== X-Received: by 2002:a19:ec17:: with SMTP id b23mr22725310lfa.76.1554908482884; Wed, 10 Apr 2019 08:01:22 -0700 (PDT) Received: from alrua-x1.borgediget.toke.dk (alrua-x1.vpn.toke.dk. [2a00:7660:6da:10::2]) by smtp.gmail.com with ESMTPSA id x71sm519415lff.82.2019.04.10.08.01.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Apr 2019 08:01:22 -0700 (PDT) Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id 82E811804A4; Wed, 10 Apr 2019 17:01:21 +0200 (CEST) From: Toke =?utf-8?Q?H=C3=B8iland-J=C3=B8rgensen?= To: David Woodhouse , Jason Wang , netdev@vger.kernel.org Subject: Re: Tun congestion/BQL In-Reply-To: <123cfccb766a6f55312d6a477764d3e7b88ad221.camel@infradead.org> References: <2e310fc6ee847d20dd23692fd1db733e607602f5.camel@infradead.org> <1506fcbbfb7ab7a1e448b7b6cbf45f703bfcc80f.camel@infradead.org> <8c64c80d-165c-076b-fca3-5374edc87853@redhat.com> <87ftqqugbj.fsf@toke.dk> <123cfccb766a6f55312d6a477764d3e7b88ad221.camel@infradead.org> X-Clacks-Overhead: GNU Terry Pratchett Date: Wed, 10 Apr 2019 17:01:21 +0200 Message-ID: <875zrlvr9a.fsf@toke.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org David Woodhouse writes: > On Wed, 2019-04-10 at 15:42 +0200, Toke Høiland-Jørgensen wrote: >> > > That doesn't seem to make much difference at all; it's still dropping a >> > > lot of packets because ptr_ring_produce() is returning non-zero. >> > >> > >> > I think you need try to stop the queue just in this case? Ideally we may >> > want to stop the queue when the queue is about to full, but we don't >> > have such helper currently. > > I don't quite understand. If the ring isn't full after I've put a > packet into it... how can it be full subsequently? We can't end up in > tun_net_xmit() concurrently, right? I'm not (knowingly) using XDP. > >> Ideally we want to react when the queue starts building rather than when >> it starts getting full; by pushing back on upper layers (or, if >> forwarding, dropping packets to signal congestion). > > This is precisely what my first accidental if (!ptr_ring_empty()) > variant was doing, right? :) Yeah, I guess. But maybe a too aggressively? How are you processing packets on the dequeue side (for crypto)? One at a time, or is there some kind of batching in play? >> In practice, this means tuning the TX ring to the *minimum* size it can >> be without starving (this is basically what BQL does for Ethernet), and >> keeping packets queued in the qdisc layer instead, where it can be >> managed... > > I was going to add BQL (as $SUBJECT may have caused you to infer) but > trivially adding the netdev_sent_queue() in tun_net_xmit() and > netdev_completed_queue() for xdp vs. skb in tun_do_read() was tripping > the BUG in dql_completed(). I just ripped that part out and focused on > the queue stop/start and haven't gone back to it yet. Right, makes sense. What qdisc are you running on the tun device? Also, I assume that netperf is running on the same host that has the tun device on it, right? -Toke