From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 887F94266A; Tue, 3 Oct 2023 14:36:18 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0E6904026C; Tue, 3 Oct 2023 14:36:18 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 0B18E4026B for ; Tue, 3 Oct 2023 14:36:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696336576; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=B6kiahh0TVRKrJgFJQY6+XjhSl6sFVJ/usTksO9qJgI=; b=YGToSSskto84uz6P23zyvrj9m84GaqRHY/3mjlv1oiwIglozJI3yxtILqtPEP/8OOoHGpM VsFnx+RWDEGWWdKUlJGHzdpZXBEzY6c84TstrLpq+lVx+3uw+7TfZJFFQNe153I8y97b/U 3K864BnEcblMx1F4dwG926FvNFHhHZM= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-383-Ms1h5u9yPiiBH83RvqvMyg-1; Tue, 03 Oct 2023 08:36:15 -0400 X-MC-Unique: Ms1h5u9yPiiBH83RvqvMyg-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-9adad8f306fso71034566b.0 for ; Tue, 03 Oct 2023 05:36:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696336574; x=1696941374; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eZ/SwEmLjy7fxohVvfDNQkK2fnve7CC3L3ioglMzKSM=; b=b2ghfVehAb3UKlzhHWqMoRCa+f13DrTtlibMo72c0Ewo04TUZw6j4FecYSHhDS4tFc c/NMNXORzZD99EAWjZscnsW9yXUW8BtFx58AXZ941B/D/g1zt5cWBvyavzNi0iGygBhe 4NjKHzzqggh3ry8tbcLqWF9dionbr7ryvY/ysk8ZkSXahS8y+PojhCvBKlhhWoa5Le/l x7AgleG8mHaG8/8jIDNGsiWmDOFbsyu74xzydlVxZLRQEu3qhZPNduTsn3AgYaRuQbLx EcF6ls2RCtFrpAJ1AX2peFR0Kkb2uJSD8Q6XuTK5mXfEDq+GsNBpsaasY86DfMbTAfWT JvPQ== X-Gm-Message-State: AOJu0YyujRXWGqlrutlB7tUtWu4n03MtrvqDg47EXn+L5W56BMTHIEmu 5SdH7i5Dt7EHnPiSuAbMnT8KAKSUQI1K1H3GI9x1NoTLeMGps0D5T4wJo82G9FklSYEaYm7AXdZ 9qD8= X-Received: by 2002:a17:907:770e:b0:9ae:738b:86d0 with SMTP id kw14-20020a170907770e00b009ae738b86d0mr13914366ejc.66.1696336574187; Tue, 03 Oct 2023 05:36:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE0sh7xpgRBz4EtSJz7gTnilLk4f/YuN2E7zmR0p3UmcXMqFuv1su68xiPs0H5igtbdmR528Q== X-Received: by 2002:a17:907:770e:b0:9ae:738b:86d0 with SMTP id kw14-20020a170907770e00b009ae738b86d0mr13914335ejc.66.1696336573726; Tue, 03 Oct 2023 05:36:13 -0700 (PDT) Received: from [10.39.193.242] (5920ab7b.static.cust.trined.nl. [89.32.171.123]) by smtp.gmail.com with ESMTPSA id w25-20020a170906481900b0099bc2d1429csm1021672ejq.72.2023.10.03.05.36.12 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Oct 2023 05:36:13 -0700 (PDT) From: Eelco Chaudron To: Maxime Coquelin Cc: dev@dpdk.org, david.marchand@redhat.com, chenbo.xia@outlook.com Subject: Re: [PATCH v3] vhost: add IRQ suppression Date: Tue, 03 Oct 2023 14:36:12 +0200 X-Mailer: MailMate (1.14r5964) Message-ID: In-Reply-To: <20230929103809.765417-1-maxime.coquelin@redhat.com> References: <20230929103809.765417-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Content-Transfer-Encoding: quoted-printable X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On 29 Sep 2023, at 12:38, Maxime Coquelin wrote: > Guest notifications offloading, which has been introduced > in v23.07, aims at offloading syscalls out of the datapath. > > This patch optimizes the offloading by not offloading the > guest notification for a given virtqueue if one is already > being offloaded by the application. > > With a single VDUSE device, we can already see few > notifications being suppressed when doing throughput > testing with Iperf3. We can expect to see much more being > suppressed when the offloading thread is under pressure. > > Signed-off-by: Maxime Coquelin Thanks for adding this Maxime. I did some tests with OVS and my old determi= nism patchset, and it works perfectly. I have two small nits, but this change looks good to me. Acked-by: Eelco Chaudron > --- > > v3: s/0/false/ (David) > > lib/vhost/vhost.c | 4 ++++ > lib/vhost/vhost.h | 27 +++++++++++++++++++++------ > 2 files changed, 25 insertions(+), 6 deletions(-) > > diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c > index c03bb9c6eb..7fde412ef3 100644 > --- a/lib/vhost/vhost.c > +++ b/lib/vhost/vhost.c > @@ -49,6 +49,8 @@ static const struct vhost_vq_stats_name_off vhost_vq_st= at_strings[] =3D { > =09=09stats.guest_notifications_offloaded)}, > =09{"guest_notifications_error", offsetof(struct vhost_virtqueue, > =09=09stats.guest_notifications_error)}, > +=09{"guest_notifications_suppressed", offsetof(struct vhost_virtqueue, > +=09=09stats.guest_notifications_suppressed)}, > =09{"iotlb_hits", offsetof(struct vhost_virtqueue, stats.iot= lb_hits)}, > =09{"iotlb_misses", offsetof(struct vhost_virtqueue, stats.iot= lb_misses)}, > =09{"inflight_submitted", offsetof(struct vhost_virtqueue, stats.inf= light_submitted)}, > @@ -1517,6 +1519,8 @@ rte_vhost_notify_guest(int vid, uint16_t queue_id) > > =09rte_rwlock_read_lock(&vq->access_lock); > > +=09__atomic_store_n(&vq->irq_pending, false, __ATOMIC_RELEASE); > + > =09if (dev->backend_ops->inject_irq(dev, vq)) { > =09=09if (dev->flags & VIRTIO_DEV_STATS_ENABLED) > =09=09=09__atomic_fetch_add(&vq->stats.guest_notifications_error, > diff --git a/lib/vhost/vhost.h b/lib/vhost/vhost.h > index 9723429b1c..5fc9035a1f 100644 > --- a/lib/vhost/vhost.h > +++ b/lib/vhost/vhost.h > @@ -156,6 +156,7 @@ struct virtqueue_stats { > =09uint64_t iotlb_misses; > =09uint64_t inflight_submitted; > =09uint64_t inflight_completed; > +=09uint64_t guest_notifications_suppressed; > =09/* Counters below are atomic, and should be incremented as such. */ > =09uint64_t guest_notifications; > =09uint64_t guest_notifications_offloaded; > @@ -346,6 +347,8 @@ struct vhost_virtqueue { > > =09struct vhost_vring_addr ring_addrs; > =09struct virtqueue_stats=09stats; > + > +=09bool irq_pending; nit: Other elements in this structure have the names aligned, not sure if t= his should be done for this item also. > } __rte_cache_aligned; > > /* Virtio device status as per Virtio specification */ > @@ -908,12 +911,24 @@ vhost_need_event(uint16_t event_idx, uint16_t new_i= dx, uint16_t old) > static __rte_always_inline void > vhost_vring_inject_irq(struct virtio_net *dev, struct vhost_virtqueue *v= q) > { > -=09if (dev->notify_ops->guest_notify && > -=09 dev->notify_ops->guest_notify(dev->vid, vq->index)) { > -=09=09if (dev->flags & VIRTIO_DEV_STATS_ENABLED) > -=09=09=09__atomic_fetch_add(&vq->stats.guest_notifications_offloaded, > -=09=09=09=091, __ATOMIC_RELAXED); > -=09=09return; > +=09bool expected =3D false; > + > +=09if (dev->notify_ops->guest_notify) { > +=09=09if (__atomic_compare_exchange_n(&vq->irq_pending, &expected, true,= 0, > +=09=09=09=09 __ATOMIC_RELEASE, __ATOMIC_RELAXED)) { > +=09=09=09if (dev->notify_ops->guest_notify(dev->vid, vq->index)) { > +=09=09=09=09if (dev->flags & VIRTIO_DEV_STATS_ENABLED) > +=09=09=09=09=09__atomic_fetch_add(&vq->stats.guest_notifications_offload= ed, > +=09=09=09=09=09=091, __ATOMIC_RELAXED); > +=09=09=09=09return; > +=09=09=09} > + > +=09=09=09/* Offloading failed, fallback to direct IRQ injection */ nit: Some comments end with a dot and some do not, not sure what is the pre= ference in DPDK. > +=09=09=09__atomic_store_n(&vq->irq_pending, false, __ATOMIC_RELEASE); > +=09=09} else { > +=09=09=09vq->stats.guest_notifications_suppressed++; > +=09=09=09return; > +=09=09} > =09} > > =09if (dev->backend_ops->inject_irq(dev, vq)) { > -- > 2.41.0