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 EE52AC10F13 for ; Thu, 11 Apr 2019 07:01:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C521521841 for ; Thu, 11 Apr 2019 07:01:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726827AbfDKHBa (ORCPT ); Thu, 11 Apr 2019 03:01:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42558 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725783AbfDKHBa (ORCPT ); Thu, 11 Apr 2019 03:01:30 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DDB93316890B; Thu, 11 Apr 2019 07:01:29 +0000 (UTC) Received: from [10.72.12.119] (ovpn-12-119.pek2.redhat.com [10.72.12.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7818118259; Thu, 11 Apr 2019 07:01:26 +0000 (UTC) Subject: Re: Tun congestion/BQL To: =?UTF-8?Q?Toke_H=c3=b8iland-J=c3=b8rgensen?= , David Woodhouse , netdev@vger.kernel.org References: <2e310fc6ee847d20dd23692fd1db733e607602f5.camel@infradead.org> <1506fcbbfb7ab7a1e448b7b6cbf45f703bfcc80f.camel@infradead.org> <8c64c80d-165c-076b-fca3-5374edc87853@redhat.com> <87ftqqugbj.fsf@toke.dk> From: Jason Wang Message-ID: Date: Thu, 11 Apr 2019 15:01:19 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <87ftqqugbj.fsf@toke.dk> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Thu, 11 Apr 2019 07:01:29 +0000 (UTC) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 2019/4/10 下午9:42, Toke Høiland-Jørgensen wrote: > 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 Yes, but we do have user that don't use qdisc at all. Thanks