Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp4022627rwr; Mon, 8 May 2023 01:25:37 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4JgEgjXBBn4jbPi2I0599a2KqV6QDcSPDCg6KLGstd1DCg3uiZ5FblxCBkcNpZ7QhFPM4T X-Received: by 2002:a17:90b:2247:b0:246:fd54:58e with SMTP id hk7-20020a17090b224700b00246fd54058emr9656367pjb.1.1683534337309; Mon, 08 May 2023 01:25:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683534337; cv=none; d=google.com; s=arc-20160816; b=EIFupHwA5Vfh+NetbrbdgqUmUe7Ms6x4Ga5bjFFg/TDvLxP5jytdOR1Rg/Gls7x1E9 XqU179ZSRgRnaevZapbIHXd604i4iQQ/xXuJqIotc+OwygAXsLWdCLaJOocWc+5/oglb WMa6zeVHD8LRQeBc01eye4bf7BZ0qKvZuO5fv4hGqe+skexY3YvTbfHnMggd+8X9lzAV 1yKHOdzrSWTlAcYwBwutyCNVuIcF8f3XAqtpgU/+ca/SkNb1+5yV9ODaxiNc8BWTosZV rlJbbeQ7oHNcPQEuASbaebjMbZel+iBhxuomD9WcJB26JDk+srdcw/Ph3oEaMvJ34ZV5 j7RA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:date:subject:message-id; bh=EdgGSpF04tWg0KSfOP3f7zm6MUlNlyHVPV4DC+a3NPc=; b=s5P6DGi5xYniz59OVHDHJlkeIGb5DOLBZeCUuTWyKdTHlAjq38N/1aS+bTqxAMAqGe JAcpSpOyrtq95uwrjTS5/zGddGI1c+jwDA0QHdMqu8WzDNIm8KSl+/e5QZfzhP+42vRL SM/3UP8r+y0QQc+dbBXCYdnjEDQ4iU6JxW1Kju4eXjsdR+sumitg90kj5iP/vBjxgOBU jWQFM+aT0I3wD5YSgOYDo+3t5A8yrlBbui2TgSEN8adlz/Y5DV+LEnS0kvHkQK4ObJY5 L4iHdC/wFiY5vPtQnq5NwYfjQJ8Yfrmc5JobJsxWwrfiTgH0R8UTCQl/1Qw2iP3C8wZQ zbSQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ot1-20020a17090b3b4100b002508259bbbbsi2136259pjb.125.2023.05.08.01.25.25; Mon, 08 May 2023 01:25:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233098AbjEHHpP (ORCPT + 99 others); Mon, 8 May 2023 03:45:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232779AbjEHHpM (ORCPT ); Mon, 8 May 2023 03:45:12 -0400 Received: from out30-99.freemail.mail.aliyun.com (out30-99.freemail.mail.aliyun.com [115.124.30.99]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C9E81A1DC; Mon, 8 May 2023 00:45:10 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R161e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045176;MF=xuanzhuo@linux.alibaba.com;NM=1;PH=DS;RN=13;SR=0;TI=SMTPD_---0Vi0xjwt_1683531906; Received: from localhost(mailfrom:xuanzhuo@linux.alibaba.com fp:SMTPD_---0Vi0xjwt_1683531906) by smtp.aliyun-inc.com; Mon, 08 May 2023 15:45:07 +0800 Message-ID: <1683531716.238961-1-xuanzhuo@linux.alibaba.com> Subject: Re: [PATCH] virtio_net: set default mtu to 1500 when 'Device maximum MTU' bigger than 1500 Date: Mon, 8 May 2023 15:41:56 +0800 From: Xuan Zhuo To: "Michael S. Tsirkin" Cc: huangml@yusur.tech, zy@yusur.tech, Jason Wang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "open list:VIRTIO CORE AND NET DRIVERS" , "open list:NETWORKING DRIVERS" , open list , Hao Chen , hengqi@linux.alibaba.com References: <20230506021529.396812-1-chenh@yusur.tech> <1683341417.0965195-4-xuanzhuo@linux.alibaba.com> <07b6b325-9a15-222f-e618-d149b57cbac2@yusur.tech> <20230507045627-mutt-send-email-mst@kernel.org> <1683511319.099806-2-xuanzhuo@linux.alibaba.com> <20230508020953-mutt-send-email-mst@kernel.org> <1683526688.7492425-1-xuanzhuo@linux.alibaba.com> <20230508024147-mutt-send-email-mst@kernel.org> In-Reply-To: <20230508024147-mutt-send-email-mst@kernel.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 8 May 2023 02:43:24 -0400, "Michael S. Tsirkin" wr= ote: > On Mon, May 08, 2023 at 02:18:08PM +0800, Xuan Zhuo wrote: > > On Mon, 8 May 2023 02:15:46 -0400, "Michael S. Tsirkin" wrote: > > > On Mon, May 08, 2023 at 10:01:59AM +0800, Xuan Zhuo wrote: > > > > On Sun, 7 May 2023 04:58:58 -0400, "Michael S. Tsirkin" wrote: > > > > > On Sat, May 06, 2023 at 04:56:35PM +0800, Hao Chen wrote: > > > > > > > > > > > > > > > > > > =E5=9C=A8 2023/5/6 10:50, Xuan Zhuo =E5=86=99=E9=81=93: > > > > > > > On Sat, 6 May 2023 10:15:29 +0800, Hao Chen wrote: > > > > > > > > When VIRTIO_NET_F_MTU(3) Device maximum MTU reporting is su= pported. > > > > > > > > If offered by the device, device advises driver about the v= alue of its > > > > > > > > maximum MTU. If negotiated, the driver uses mtu as the maxi= mum > > > > > > > > MTU value. But there the driver also uses it as default mtu, > > > > > > > > some devices may have a maximum MTU greater than 1500, this= may > > > > > > > > cause some large packages to be discarded, > > > > > > > > > > > > > > You mean tx packet? > > > > > > Yes. > > > > > > > > > > > > > > If yes, I do not think this is the problem of driver. > > > > > > > > > > > > > > Maybe you should give more details about the discard. > > > > > > > > > > > > > In the current code, if the maximum MTU supported by the virtio= net hardware > > > > > > is 9000, the default MTU of the virtio net driver will also be = set to 9000. > > > > > > When sending packets through "ping -s 5000", if the peer router= does not > > > > > > support negotiating a path MTU through ICMP packets, the packet= s will be > > > > > > discarded. If the peer router supports negotiating path mtu thr= ough ICMP > > > > > > packets, the host side will perform packet sharding processing = based on the > > > > > > negotiated path mtu, which is generally within 1500. > > > > > > This is not a bugfix patch, I think setting the default mtu to = within 1500 > > > > > > would be more suitable here.Thanks. > > > > > > > > > > I don't think VIRTIO_NET_F_MTU is appropriate for support for jum= bo packets. > > > > > The spec says: > > > > > The device MUST forward transmitted packets of up to mtu (plus l= ow level ethernet header length) size with > > > > > gso_type NONE or ECN, and do so without fragmentation, after VIR= TIO_NET_F_MTU has been success- > > > > > fully negotiated. > > > > > VIRTIO_NET_F_MTU has been designed for all kind of tunneling devi= ces, > > > > > and this is why we set mtu to max by default. > > > > > > > > > > For things like jumbo frames where MTU might or might not be avai= lable, > > > > > a new feature would be more appropriate. > > > > > > > > > > > > So for jumbo frame, what is the problem? > > > > > > > > We are trying to do this. @Heng > > > > > > > > Thanks. > > > > > > It is not a problem as such. But VIRTIO_NET_F_MTU will set the > > > default MTU not just the maximum one, because spec seems to > > > say it can. > > > > I see. > > > > In the case of Jumbo Frame, we also hope that the driver will set the d= efault > > directly to the max mtu. Just like what you said "Bigger packets =3D be= tter > > performance." > > > > I don't know, in any scenario, when the hardware supports a large mtu, = but we do > > not want the user to use it by default. > > When other devices on the same LAN have mtu set to 1500 and > won't accept bigger packets. So, that depends on pmtu/tcp-probe-mtu. If the os without pmtu/tcp-probe-mtu has a bigger mtu, then it's big packet will lost. Thanks. > > > Of course, the scene that this patch > > wants to handle does exist, but I have never thought that this is a pro= blem at > > the driver level. > > > > Thanks. > > > > > > > > > > > > > > > > > > > > > > > > > > > so I changed the MTU to a more > > > > > > > > general 1500 when 'Device maximum MTU' bigger than 1500. > > > > > > > > > > > > > > > > Signed-off-by: Hao Chen > > > > > > > > --- > > > > > > > > drivers/net/virtio_net.c | 5 ++++- > > > > > > > > 1 file changed, 4 insertions(+), 1 deletion(-) > > > > > > > > > > > > > > > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_= net.c > > > > > > > > index 8d8038538fc4..e71c7d1b5f29 100644 > > > > > > > > --- a/drivers/net/virtio_net.c > > > > > > > > +++ b/drivers/net/virtio_net.c > > > > > > > > @@ -4040,7 +4040,10 @@ static int virtnet_probe(struct virt= io_device *vdev) > > > > > > > > goto free; > > > > > > > > } > > > > > > > > > > > > > > > > - dev->mtu =3D mtu; > > > > > > > > + if (mtu > 1500) > > > > > > > > > > > > > > s/1500/ETH_DATA_LEN/ > > > > > > > > > > > > > > Thanks. > > > > > > > > > > > > > > > + dev->mtu =3D 1500; > > > > > > > > + else > > > > > > > > + dev->mtu =3D mtu; > > > > > > > > dev->max_mtu =3D mtu; > > > > > > > > } > > > > > > > > > > > > > > > > -- > > > > > > > > 2.27.0 > > > > > > > > > > > > > > > > >