Thread (34 messages) 34 messages, 4 authors, 2023-11-02

Re: [PATCH net-next 5/5] virtio-net: support tx netdim

From: "Michael S. Tsirkin" <mst@redhat.com>
Date: 2023-10-25 05:50:50
Also in: virtualization

On Wed, Oct 25, 2023 at 11:35:43AM +0800, Jason Wang wrote:
On Thu, Oct 12, 2023 at 3:44 PM Heng Qi [off-list ref] wrote:
quoted
Similar to rx netdim, this patch supports adaptive tx
coalescing moderation for the virtio-net.

Signed-off-by: Heng Qi <redacted>
---
 drivers/net/virtio_net.c | 143 ++++++++++++++++++++++++++++++++-------
 1 file changed, 119 insertions(+), 24 deletions(-)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 6ad2890a7909..1c680cb09d48 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -154,6 +154,15 @@ struct send_queue {

        struct virtnet_sq_stats stats;

+       /* The number of tx notifications */
+       u16 calls;
+
+       /* Is dynamic interrupt moderation enabled? */
+       bool dim_enabled;
+
+       /* Dynamic Interrupt Moderation */
+       struct dim dim;
+
        struct virtnet_interrupt_coalesce intr_coal;

        struct napi_struct napi;
@@ -317,8 +326,9 @@ struct virtnet_info {
        u8 duplex;
        u32 speed;

-       /* Is rx dynamic interrupt moderation enabled? */
+       /* Is dynamic interrupt moderation enabled? */
        bool rx_dim_enabled;
+       bool tx_dim_enabled;

        /* Interrupt coalescing settings */
        struct virtnet_interrupt_coalesce intr_coal_tx;
@@ -464,19 +474,40 @@ static bool virtqueue_napi_complete(struct napi_struct *napi,
        return false;
 }

+static void virtnet_tx_dim_work(struct work_struct *work);
+
+static void virtnet_tx_dim_update(struct virtnet_info *vi, struct send_queue *sq)
+{
+       struct virtnet_sq_stats *stats = &sq->stats;
+       struct dim_sample cur_sample = {};
+
+       u64_stats_update_begin(&sq->stats.syncp);
+       dim_update_sample(sq->calls, stats->packets,
+                         stats->bytes, &cur_sample);
+       u64_stats_update_end(&sq->stats.syncp);
+
+       net_dim(&sq->dim, cur_sample);
+}
+
 static void skb_xmit_done(struct virtqueue *vq)
 {
        struct virtnet_info *vi = vq->vdev->priv;
-       struct napi_struct *napi = &vi->sq[vq2txq(vq)].napi;
+       struct send_queue *sq = &vi->sq[vq2txq(vq)];
+       struct napi_struct *napi = &sq->napi;
+
+       sq->calls++;
I wonder what's the impact of this counters for netdim. As we have a
mode of orphan skb in xmit.

We need to test to see.

Thanks
Agreed, performance patches should come with performance results.

-- 
MST
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help