Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3315290rwb; Tue, 16 Aug 2022 00:02:40 -0700 (PDT) X-Google-Smtp-Source: AA6agR6I1JVlcDLwlZYymdShd8HLOJegaCgfVXbYF7BrhQC5bOgV0t+k/rvnJcexSR5K+SCAJZIZ X-Received: by 2002:aa7:cd51:0:b0:440:595d:aeed with SMTP id v17-20020aa7cd51000000b00440595daeedmr17593394edw.143.1660633360728; Tue, 16 Aug 2022 00:02:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660633360; cv=none; d=google.com; s=arc-20160816; b=iwBjjLG5m+cWMm8qRTDLusI5q3e65GPhX8jvdX1l7WoYz/4X0HP032v+GF+pcc4+38 t2cU2FJPlTUP2Wjbe60f+Yi53MEGV53X9YsVKmQhoYtuW9lnZDbxMt6xnVrmuee3O+fT T34aNFQqkLq3dQvjFJdByJnZ/r5l1GzR9fAhhPkBaSkyvSzgVmefmuHFEzNLaYWjrC1u QDK+kqhgubrC638je4wGDyG63X4ygac0geobjUzd++FULQQ7Cli97urn2yPEXvd0saP8 F//Jj+lg8btDnPDYeK1K5fYwDtgnDWp3udIgrKMKn64s7vwgZW5b9+w5lCP9A3omHiNv 1eeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:sender:dkim-signature; bh=jXfmFWyPTI+/X9q6YSHrJyPzaAFzd5pRVR1VGmA59ow=; b=bsMbFD07clGpSwd4LRpcJ4ipbw0Bk/TMjBMr/yqseKA1mmab2UDELugDwkrbzdBqFH Gc6XPWU8HZuPcyEUueALJ15XDtvgeZGRuyZhBILI2fM1UWzSWGJ4AKMenGihsE+fUXSz zgVwAhdeTO77/9XPp0yp7sDFqZfwSEI92d4i0aoKmsIMzqzT+9FWFX1dB0j+d+jzq44G iowhGDSBu8v2VsC+bAZiWNZQ+2tllsXMzp/5xVq25PNdyU/GuYgtayV8h0bcEY2lL0kL bJZ5cCyXmrgxhvv2kpjWF94lZao5c2JiMQoX6F99eRuaYuewZ3fiUsytMbMyDUeUi8SB gjuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ZUpPnnTP; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g27-20020a056402321b00b0043c233945f4si8326049eda.477.2022.08.16.00.02.12; Tue, 16 Aug 2022 00:02:40 -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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ZUpPnnTP; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229749AbiHPGEK (ORCPT + 99 others); Tue, 16 Aug 2022 02:04:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229781AbiHPGDt (ORCPT ); Tue, 16 Aug 2022 02:03:49 -0400 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B022C2E19CD; Mon, 15 Aug 2022 16:36:24 -0700 (PDT) Received: by mail-pj1-x102b.google.com with SMTP id ha11so8262108pjb.2; Mon, 15 Aug 2022 16:36:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc; bh=jXfmFWyPTI+/X9q6YSHrJyPzaAFzd5pRVR1VGmA59ow=; b=ZUpPnnTP2SeMrbSXwPX7TejLi5n/sg43tnIuviaoBDPf7szFy14G/Zm/d34T16qUeV tU9ym01zECetIx2f/W5H651WscbCumYf3f3L9u2Mmqf2kJ1g+l4TvGDNh9X3GWZdtjr3 PxLVyDsbcz3zvyLyiTuVSCkcYJOJWifqML0hzBaFvU4xbhdaDq6+zxdCNZZTWV7lHMXs pWggQ/K4SKGSJID46FK3VA7StW/Vga2++z50+dGb7X33RU5w+Zs13ehrcVlCuoJ42txk XbMIJWcmqsI9Wo3ymQnnJUWGUEUqNFSbrgJvY/WxEwdY5bmR9fqSQ03LPs/pyN/hffDt 8xhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc; bh=jXfmFWyPTI+/X9q6YSHrJyPzaAFzd5pRVR1VGmA59ow=; b=Kd35td+R9AWG3wPulBKYQRz6dO3UA0kRQWHoHFI8CankTUdxtstje4UkngImEHg+kE FmsOxvf9CQOea+G15f5gNxMCEiHnZfx28Ca6FcHMGSdK7k4l2JK+G5gLMjwGNTGF00Wh ka4Pj+OTvt9Z3xXsVAxsK04nPkN09jviWMlYjuDfIorXQ1b1VmNtgqMpqVCaG8m71nQh xXvoQhtEesAWlf7Jw/yYu1nmefOwHCbu2lnAFDGyPmvzU/AA74ixrZ7w7UXEXcDBKblo Eo2PUodn8dofM7xDc/kt/BwIFmOQPxLb1yrrhi+K4iwIxehE4JY49lWouCMzxziKYPo7 ePkQ== X-Gm-Message-State: ACgBeo070RquXtOtNX488T3a8tNCqxIXaL6lqvPscZRavOqeulGadp4u tpUmQVB3HAwX791IY+ZAnT8= X-Received: by 2002:a17:903:11cd:b0:170:cde8:18b7 with SMTP id q13-20020a17090311cd00b00170cde818b7mr19364760plh.165.1660606583904; Mon, 15 Aug 2022 16:36:23 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id q3-20020a17090a304300b001f2c22fa4ddsm4959475pjl.50.2022.08.15.16.36.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Aug 2022 16:36:21 -0700 (PDT) Sender: Guenter Roeck Date: Mon, 15 Aug 2022 16:36:18 -0700 From: Guenter Roeck To: "Michael S. Tsirkin" Cc: linux-kernel@vger.kernel.org, Xuan Zhuo , Jason Wang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, Linus Torvalds , Jens Axboe , James Bottomley , "Martin K. Petersen" , Greg KH , Andres Freund Subject: Re: [PATCH v3 1/5] virtio_net: Revert "virtio_net: set the default max ring size by find_vqs()" Message-ID: <20220815233618.GA653119@roeck-us.net> References: <20220815215938.154999-1-mst@redhat.com> <20220815215938.154999-2-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220815215938.154999-2-mst@redhat.com> X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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, Aug 15, 2022 at 06:00:25PM -0400, Michael S. Tsirkin wrote: > This reverts commit 762faee5a2678559d3dc09d95f8f2c54cd0466a7. > > This has been reported to trip up guests on GCP (Google Cloud). > The reason is that virtio_find_vqs_ctx_size is broken on legacy > devices. We can in theory fix virtio_find_vqs_ctx_size but > in fact the patch itself has several other issues: > > - It treats unknown speed as < 10G > - It leaves userspace no way to find out the ring size set by hypervisor > - It tests speed when link is down > - It ignores the virtio spec advice: > Both \field{speed} and \field{duplex} can change, thus the driver > is expected to re-read these values after receiving a > configuration change notification. > - It is not clear the performance impact has been tested properly > > Revert the patch for now. > > Reported-by: Andres Freund > Link: https://lore.kernel.org/r/20220814212610.GA3690074%40roeck-us.net > Link: https://lore.kernel.org/r/20220815070203.plwjx7b3cyugpdt7%40awork3.anarazel.de > Link: https://lore.kernel.org/r/3df6bb82-1951-455d-a768-e9e1513eb667%40www.fastmail.com > Link: https://lore.kernel.org/r/FCDC5DDE-3CDD-4B8A-916F-CA7D87B547CE%40anarazel.de > Fixes: 762faee5a267 ("virtio_net: set the default max ring size by find_vqs()") > Cc: Xuan Zhuo > Cc: Jason Wang > Signed-off-by: Michael S. Tsirkin > Tested-by: Andres Freund > Tested-by: From: Guenter Roeck s/From: // > --- > drivers/net/virtio_net.c | 42 ++++------------------------------------ > 1 file changed, 4 insertions(+), 38 deletions(-) > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > index d934774e9733..ece00b84e3a7 100644 > --- a/drivers/net/virtio_net.c > +++ b/drivers/net/virtio_net.c > @@ -3432,29 +3432,6 @@ static unsigned int mergeable_min_buf_len(struct virtnet_info *vi, struct virtqu > (unsigned int)GOOD_PACKET_LEN); > } > > -static void virtnet_config_sizes(struct virtnet_info *vi, u32 *sizes) > -{ > - u32 i, rx_size, tx_size; > - > - if (vi->speed == SPEED_UNKNOWN || vi->speed < SPEED_10000) { > - rx_size = 1024; > - tx_size = 1024; > - > - } else if (vi->speed < SPEED_40000) { > - rx_size = 1024 * 4; > - tx_size = 1024 * 4; > - > - } else { > - rx_size = 1024 * 8; > - tx_size = 1024 * 8; > - } > - > - for (i = 0; i < vi->max_queue_pairs; i++) { > - sizes[rxq2vq(i)] = rx_size; > - sizes[txq2vq(i)] = tx_size; > - } > -} > - > static int virtnet_find_vqs(struct virtnet_info *vi) > { > vq_callback_t **callbacks; > @@ -3462,7 +3439,6 @@ static int virtnet_find_vqs(struct virtnet_info *vi) > int ret = -ENOMEM; > int i, total_vqs; > const char **names; > - u32 *sizes; > bool *ctx; > > /* We expect 1 RX virtqueue followed by 1 TX virtqueue, followed by > @@ -3490,15 +3466,10 @@ static int virtnet_find_vqs(struct virtnet_info *vi) > ctx = NULL; > } > > - sizes = kmalloc_array(total_vqs, sizeof(*sizes), GFP_KERNEL); > - if (!sizes) > - goto err_sizes; > - > /* Parameters for control virtqueue, if any */ > if (vi->has_cvq) { > callbacks[total_vqs - 1] = NULL; > names[total_vqs - 1] = "control"; > - sizes[total_vqs - 1] = 64; > } > > /* Allocate/initialize parameters for send/receive virtqueues */ > @@ -3513,10 +3484,8 @@ static int virtnet_find_vqs(struct virtnet_info *vi) > ctx[rxq2vq(i)] = true; > } > > - virtnet_config_sizes(vi, sizes); > - > - ret = virtio_find_vqs_ctx_size(vi->vdev, total_vqs, vqs, callbacks, > - names, sizes, ctx, NULL); > + ret = virtio_find_vqs_ctx(vi->vdev, total_vqs, vqs, callbacks, > + names, ctx, NULL); > if (ret) > goto err_find; > > @@ -3536,8 +3505,6 @@ static int virtnet_find_vqs(struct virtnet_info *vi) > > > err_find: > - kfree(sizes); > -err_sizes: > kfree(ctx); > err_ctx: > kfree(names); > @@ -3897,9 +3864,6 @@ static int virtnet_probe(struct virtio_device *vdev) > vi->curr_queue_pairs = num_online_cpus(); > vi->max_queue_pairs = max_queue_pairs; > > - virtnet_init_settings(dev); > - virtnet_update_settings(vi); > - > /* Allocate/initialize the rx/tx queues, and invoke find_vqs */ > err = init_vqs(vi); > if (err) > @@ -3912,6 +3876,8 @@ static int virtnet_probe(struct virtio_device *vdev) > netif_set_real_num_tx_queues(dev, vi->curr_queue_pairs); > netif_set_real_num_rx_queues(dev, vi->curr_queue_pairs); > > + virtnet_init_settings(dev); > + > if (virtio_has_feature(vdev, VIRTIO_NET_F_STANDBY)) { > vi->failover = net_failover_create(vi->dev); > if (IS_ERR(vi->failover)) { > -- > MST >