From: "Michael S. Tsirkin" <mst@redhat.com>
To: Alvaro Karsz <alvaro.karsz@solid-run.com>
Cc: virtualization@lists.linux-foundation.org,
netdev@vger.kernel.org, Jason Wang <jasowang@redhat.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Subject: Re: [PATCH] virtio_net: send notification coalescing command only if value changed
Date: Wed, 21 Dec 2022 07:33:16 -0500 [thread overview]
Message-ID: <20221221073256-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20221221120618.652074-1-alvaro.karsz@solid-run.com>
On Wed, Dec 21, 2022 at 02:06:18PM +0200, Alvaro Karsz wrote:
> Don't send a VIRTIO_NET_CTRL_NOTF_COAL_TX_SET or
> VIRTIO_NET_CTRL_NOTF_COAL_RX_SET command if the coalescing parameters
> haven't changed.
>
> Signed-off-by: Alvaro Karsz <alvaro.karsz@solid-run.com>
Why do we bother? Resending needs more code and helps
reliability ...
> ---
> drivers/net/virtio_net.c | 48 ++++++++++++++++++++++------------------
> 1 file changed, 27 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 7723b2a49d8..1d7118de62a 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -2760,31 +2760,37 @@ static int virtnet_send_notf_coal_cmds(struct virtnet_info *vi,
> struct virtio_net_ctrl_coal_tx coal_tx;
> struct virtio_net_ctrl_coal_rx coal_rx;
>
> - coal_tx.tx_usecs = cpu_to_le32(ec->tx_coalesce_usecs);
> - coal_tx.tx_max_packets = cpu_to_le32(ec->tx_max_coalesced_frames);
> - sg_init_one(&sgs_tx, &coal_tx, sizeof(coal_tx));
> -
> - if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_NOTF_COAL,
> - VIRTIO_NET_CTRL_NOTF_COAL_TX_SET,
> - &sgs_tx))
> - return -EINVAL;
> + if (ec->tx_coalesce_usecs != vi->tx_usecs ||
> + ec->tx_max_coalesced_frames != vi->tx_max_packets) {
> + coal_tx.tx_usecs = cpu_to_le32(ec->tx_coalesce_usecs);
> + coal_tx.tx_max_packets = cpu_to_le32(ec->tx_max_coalesced_frames);
> + sg_init_one(&sgs_tx, &coal_tx, sizeof(coal_tx));
> +
> + if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_NOTF_COAL,
> + VIRTIO_NET_CTRL_NOTF_COAL_TX_SET,
> + &sgs_tx))
> + return -EINVAL;
>
> - /* Save parameters */
> - vi->tx_usecs = ec->tx_coalesce_usecs;
> - vi->tx_max_packets = ec->tx_max_coalesced_frames;
> + /* Save parameters */
> + vi->tx_usecs = ec->tx_coalesce_usecs;
> + vi->tx_max_packets = ec->tx_max_coalesced_frames;
> + }
>
> - coal_rx.rx_usecs = cpu_to_le32(ec->rx_coalesce_usecs);
> - coal_rx.rx_max_packets = cpu_to_le32(ec->rx_max_coalesced_frames);
> - sg_init_one(&sgs_rx, &coal_rx, sizeof(coal_rx));
> + if (ec->rx_coalesce_usecs != vi->rx_usecs ||
> + ec->rx_max_coalesced_frames != vi->rx_max_packets) {
> + coal_rx.rx_usecs = cpu_to_le32(ec->rx_coalesce_usecs);
> + coal_rx.rx_max_packets = cpu_to_le32(ec->rx_max_coalesced_frames);
> + sg_init_one(&sgs_rx, &coal_rx, sizeof(coal_rx));
>
> - if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_NOTF_COAL,
> - VIRTIO_NET_CTRL_NOTF_COAL_RX_SET,
> - &sgs_rx))
> - return -EINVAL;
> + if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_NOTF_COAL,
> + VIRTIO_NET_CTRL_NOTF_COAL_RX_SET,
> + &sgs_rx))
> + return -EINVAL;
>
> - /* Save parameters */
> - vi->rx_usecs = ec->rx_coalesce_usecs;
> - vi->rx_max_packets = ec->rx_max_coalesced_frames;
> + /* Save parameters */
> + vi->rx_usecs = ec->rx_coalesce_usecs;
> + vi->rx_max_packets = ec->rx_max_coalesced_frames;
> + }
>
> return 0;
> }
> --
> 2.32.0
next prev parent reply other threads:[~2022-12-21 12:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-21 12:06 [PATCH] virtio_net: send notification coalescing command only if value changed Alvaro Karsz
2022-12-21 12:33 ` Michael S. Tsirkin [this message]
2022-12-21 12:44 ` Alvaro Karsz
2022-12-21 13:01 ` Michael S. Tsirkin
2022-12-21 13:10 ` Alvaro Karsz
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=20221221073256-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=alvaro.karsz@solid-run.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jasowang@redhat.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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;
as well as URLs for NNTP newsgroup(s).