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 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 CF74DC10F11 for ; Wed, 10 Apr 2019 13:43:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A9D4620850 for ; Wed, 10 Apr 2019 13:43:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731633AbfDJNnB convert rfc822-to-8bit (ORCPT ); Wed, 10 Apr 2019 09:43:01 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:35713 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732084AbfDJNm7 (ORCPT ); Wed, 10 Apr 2019 09:42:59 -0400 Received: by mail-ed1-f67.google.com with SMTP id s39so2102259edb.2 for ; Wed, 10 Apr 2019 06:42:58 -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=leg/4GCLxFYanuXK/EtXNWWql2AAT44l4INKXOeQjqs=; b=Sod8WGii86UtkT/cbGsBMbilvB7ZHhCm2aLRb7D2HOYRApiLfCVBtA/iIbHd49BsFX qox7mjr8JIyXCswj7eJcMif7kQVG85p3V/Fo/fk1yoraVFH+lnzjo2wwNnAnmwhM8Qnm pA3y0846ZwN8urMJ0Uj/hjDe82wAXn1lGuPcYaxHVBW194hru4mOz4zPHWS5MpVt98Wh EFow9eBRXVzd3ubKflfgteuQdx2Qq9/GGS1zCXU+YIxPQbodgOJnd9FjW9gOo6WAhAAf ofzJZX42h0tvM3p3/fuwWvzVnsgeygmi069bNMeP1oGmP+FsHrp7IeYZCAn0AySy/Gtj NdiA== X-Gm-Message-State: APjAAAUjqka0KZ/IWQMfteT/or3Tl1MPjYF4qs+u6GOJS1IhqLnUSsbj c2u3IgyZ6gzljnVRixYeThn2e4QxaXA= X-Google-Smtp-Source: APXvYqxqKv6WWNciba68uPk0kIU3rBCKGbe1Ujcl3ZgFs8VRqYzGMczHkriCqLwoBlQ9tVccKnPXhg== X-Received: by 2002:a50:aa0f:: with SMTP id o15mr27806729edc.129.1554903777890; Wed, 10 Apr 2019 06:42:57 -0700 (PDT) Received: from alrua-x1.borgediget.toke.dk (borgediget.toke.dk. [85.204.121.218]) by smtp.gmail.com with ESMTPSA id i8sm10398041eda.1.2019.04.10.06.42.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Apr 2019 06:42:57 -0700 (PDT) Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id C7F0F1804A4; Wed, 10 Apr 2019 15:42:56 +0200 (CEST) From: Toke =?utf-8?Q?H=C3=B8iland-J=C3=B8rgensen?= To: Jason Wang , David Woodhouse , netdev@vger.kernel.org Subject: Re: Tun congestion/BQL In-Reply-To: <8c64c80d-165c-076b-fca3-5374edc87853@redhat.com> References: <2e310fc6ee847d20dd23692fd1db733e607602f5.camel@infradead.org> <1506fcbbfb7ab7a1e448b7b6cbf45f703bfcc80f.camel@infradead.org> <8c64c80d-165c-076b-fca3-5374edc87853@redhat.com> X-Clacks-Overhead: GNU Terry Pratchett Date: Wed, 10 Apr 2019 15:42:56 +0200 Message-ID: <87ftqqugbj.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 Jason Wang writes: > On 2019/4/10 下午9:01, David Woodhouse wrote: >> On Wed, 2019-04-10 at 15:01 +0300, David Woodhouse wrote: >>> --- a/drivers/net/tun.c >>> +++ b/drivers/net/tun.c >>> @@ -1125,7 +1128,9 @@ static netdev_tx_t tun_net_xmit(struct sk_buff >>> *skb, struct net_device *dev) >>> if (tfile->flags & TUN_FASYNC) >>> kill_fasync(&tfile->fasync, SIGIO, POLL_IN); >>> tfile->socket.sk->sk_data_ready(tfile->socket.sk); >>> >>> + if (!ptr_ring_empty(&tfile->tx_ring)) >>> + netif_stop_queue(tun->dev); >>> rcu_read_unlock(); >>> return NETDEV_TX_OK; >>> >>> >> Hm, that should be using ptr_ring_full() shouldn't it? So... >> >> --- a/drivers/net/tun.c >> +++ b/drivers/net/tun.c >> @@ -1121,6 +1121,9 @@ static netdev_tx_t tun_net_xmit(struct s >> if (ptr_ring_produce(&tfile->tx_ring, skb)) >> goto drop; >> >> + if (ptr_ring_full(&tfile->tx_ring)) >> + netif_stop_queue(tun->dev); >> + >> /* Notify and wake up reader process */ >> if (tfile->flags & TUN_FASYNC) >> kill_fasync(&tfile->fasync, SIGIO, POLL_IN); >> @@ -2229,6 +2232,7 @@ static ssize_t tun_do_read(struct tun_st >> consume_skb(skb); >> } >> >> + netif_wake_queue(tun->dev); >> return ret; >> } >> >> >> 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. 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). 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... -Toke