From: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
To: Brett Creeley <brett.creeley@amd.com>
Cc: <brett.creeley@amd.com>, <shannon.nelson@amd.com>,
<linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>,
<virtualization@lists.linux-foundation.org>,
<alvaro.karsz@solid-run.com>, <pabeni@redhat.com>,
<kuba@kernel.org>, <edumazet@google.com>, <davem@davemloft.net>,
<xuanzhuo@linux.alibaba.com>, <jasowang@redhat.com>,
<mst@redhat.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 [thread overview]
Message-ID: <1686016374.4953902-2-xuanzhuo@linux.alibaba.com> (raw)
In-Reply-To: <20230605210237.60988-1-brett.creeley@amd.com>
On Mon, 5 Jun 2023 14:02:36 -0700, Brett Creeley <brett.creeley@amd.com> 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 <brett.creeley@amd.com>
> ---
> 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
>
next prev parent reply other threads:[~2023-06-06 1:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-05 21:02 Brett Creeley
2023-06-06 1:52 ` Xuan Zhuo [this message]
2023-06-06 2:03 ` Jason Wang
2023-06-06 2:02 ` Jason Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1686016374.4953902-2-xuanzhuo@linux.alibaba.com \
--to=xuanzhuo@linux.alibaba.com \
--cc=alvaro.karsz@solid-run.com \
--cc=brett.creeley@amd.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jasowang@redhat.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shannon.nelson@amd.com \
--cc=virtualization@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®