Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6452076rwd; Mon, 5 Jun 2023 19:08:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ58aeaG+4TVd92TDtK1FSGdaJTchKcqk1oEmkqhe9arQ/dOqHH4EaEwazj23VkggYVBBJ6E X-Received: by 2002:a05:622a:54e:b0:3f8:a00e:7905 with SMTP id m14-20020a05622a054e00b003f8a00e7905mr698728qtx.24.1686017331808; Mon, 05 Jun 2023 19:08:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686017331; cv=none; d=google.com; s=arc-20160816; b=C0y8CmF5obvHYFT4XhDckwYYamCn253U6evghUvWJBi956lbU8LEQVnniQgA+79Kk5 UCz9yULyQdrags7L1ZzaQ5sjj2n72XzSYSEAyiEBk1asY2AApxC+frfUhq/+UqfEfwYv 1TaYJNzC/Pt5kzbz4adEAkzxDMZ5G5V3CaaonXdHlRIiXkGWSRQZmdTdVPB7l46beVeS Y2w9S8i7VgSL5C64dXUkcEaBYejyUpkmqYfAnKS86wTjkla+E7w66P+K8fJOlGY5F8/t +ux/C2m3qafyC7dQqaKwt0M+wp6JN6ZJL+UEy3Y/g5GmdGtUDqwluEdb1S/bOOytwgZy XF/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:references:cc:to:from:date:subject :message-id; bh=ipazUu7OJiXcuVXN8H9YHmgUk2stlLLW60HQiRTlMNw=; b=bHznGFn22KfxZuNdwboh8FHflyxLXSofABrSwKaHDByuNnUcsqIROeUeylwKELTy62 XnBEb2zAYl1qlHcykHhibQyXKtKUgriquNnKL+GIOCB03jjkr71piUc4RQSDE6tpmoRO qYvA8OScacIZSQs136dCnmyuW/o9xIIzqZBDGMkZNL9tZytjuGivNV4gpduBudsYf+pk TvMTZLSHK4JTz1xIevdIOnjpjS2AcivPJc9qlNUNMYmwk4vVfyXlEv9U91hlwaXO6Sb/ f6pk69pwHia4ZA/OPmnT838ZRDxqoufCrFy024LV/AIJkf9QTq6uEf2lrsJbB/u7D03x lL4Q== 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 p21-20020a05622a00d500b003f5a33acdd4si5738361qtw.18.2023.06.05.19.08.37; Mon, 05 Jun 2023 19:08:51 -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 S232580AbjFFB5o (ORCPT + 99 others); Mon, 5 Jun 2023 21:57:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230472AbjFFB5n (ORCPT ); Mon, 5 Jun 2023 21:57:43 -0400 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F4E9ED; Mon, 5 Jun 2023 18:57:40 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R251e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046060;MF=xuanzhuo@linux.alibaba.com;NM=1;PH=DS;RN=13;SR=0;TI=SMTPD_---0VkU4BR6_1686016655; Received: from localhost(mailfrom:xuanzhuo@linux.alibaba.com fp:SMTPD_---0VkU4BR6_1686016655) by smtp.aliyun-inc.com; Tue, 06 Jun 2023 09:57:36 +0800 Message-ID: <1686016374.4953902-2-xuanzhuo@linux.alibaba.com> Subject: Re: [RFC PATCH net] virtio_net: Prevent napi_weight changes with VIRTIO_NET_F_NOTF_COAL support Date: Tue, 6 Jun 2023 09:52:54 +0800 From: Xuan Zhuo To: Brett Creeley Cc: , , , , , , , , , , , , References: <20230605210237.60988-1-brett.creeley@amd.com> In-Reply-To: <20230605210237.60988-1-brett.creeley@amd.com> X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,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, 5 Jun 2023 14:02:36 -0700, Brett Creeley wrote: > Commit 699b045a8e43 ("net: virtio_net: notifications coalescing > support") added support for VIRTIO_NET_F_NOTF_COAL. The get_coalesce > call made changes to report "1" in tx_max_coalesced_frames if > VIRTIO_NET_F_NOTF_COAL is not supported and napi.weight is non-zero. > However, the napi_weight value could still be changed by the > set_coalesce call regardless of whether or not the device supports > VIRTIO_NET_F_NOTF_COAL. > > It seems like the tx_max_coalesced_frames value should not control more > than 1 thing (i.e. napi_weight and the device's tx_max_packets). So, fix > this by only allowing the napi_weight change if VIRTIO_NET_F_NOTF_COAL > is not supported by the virtio device. @Jason I wonder should we keep this function to change the napi weight by the coalesec command. Thanks. > > It wasn't clear to me if this was the intended behavior, so that's why > I'm sending this as an RFC patch initially. Based on the feedback, I > will resubmit as an official patch. > > Fixes: 699b045a8e43 ("net: virtio_net: notifications coalescing support") > Signed-off-by: Brett Creeley > --- > drivers/net/virtio_net.c | 24 +++++++++++++----------- > 1 file changed, 13 insertions(+), 11 deletions(-) > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > index 486b5849033d..e28387866909 100644 > --- a/drivers/net/virtio_net.c > +++ b/drivers/net/virtio_net.c > @@ -2990,19 +2990,21 @@ static int virtnet_set_coalesce(struct net_device *dev, > int ret, i, napi_weight; > bool update_napi = false; > > - /* Can't change NAPI weight if the link is up */ > - napi_weight = ec->tx_max_coalesced_frames ? NAPI_POLL_WEIGHT : 0; > - if (napi_weight ^ vi->sq[0].napi.weight) { > - if (dev->flags & IFF_UP) > - return -EBUSY; > - else > - update_napi = true; > - } > - > - if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_NOTF_COAL)) > + if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_NOTF_COAL)) { > ret = virtnet_send_notf_coal_cmds(vi, ec); > - else > + } else { > + /* Can't change NAPI weight if the link is up */ > + napi_weight = ec->tx_max_coalesced_frames ? > + NAPI_POLL_WEIGHT : 0; > + if (napi_weight ^ vi->sq[0].napi.weight) { > + if (dev->flags & IFF_UP) > + return -EBUSY; > + else > + update_napi = true; > + } > + > ret = virtnet_coal_params_supported(ec); > + } > > if (ret) > return ret; > -- > 2.17.1 >