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 9C5C74265E; Thu, 28 Sep 2023 10:44:14 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7F49740273; Thu, 28 Sep 2023 10:44:14 +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 A0CB940150 for ; Thu, 28 Sep 2023 10:44:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695890652; 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=FLZRQ5r0pTdMYcmhz7ZIi99/DrSr6YOse2WoT4ZB9dM=; b=QQHhWYQLgaTTF86/5dm9ycXxZ5KzGS/ZhCzdLZiSKpN1tWkiNP+hPiMRKO1uo4I4/Oojzy qdipBBoWkqeE/99Vr+1f53OcFUfrF1bQIo/5mX3sosMppAZwHf6PyjXSpE02DBeh9/on9k Z6Xjqwd2pOmWooCH6N81Sf9c+naK1W4= Received: from mail-lj1-f199.google.com (mail-lj1-f199.google.com [209.85.208.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-453-BPqrUnZsMFKuKtPopQZYDg-1; Thu, 28 Sep 2023 04:44:09 -0400 X-MC-Unique: BPqrUnZsMFKuKtPopQZYDg-1 Received: by mail-lj1-f199.google.com with SMTP id 38308e7fff4ca-2c135cf124cso171300821fa.2 for ; Thu, 28 Sep 2023 01:44:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695890648; x=1696495448; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FLZRQ5r0pTdMYcmhz7ZIi99/DrSr6YOse2WoT4ZB9dM=; b=m6qx1I12iTaa5rS7ocpUV1xYnkxpPy6lDOhtK7d5bmdV1OkZRCoVA7tSIT8TxjYkv4 FDVRNilpPS29R7zPK/PBHwEaJbaS7m7kDuTya5b3zpFFDnLBsQylXhRy8SbMpeFQNzxM qt0m6KXUiLp+If6EdCfSD6o7jHV1G0PLI6Frwrtz7ChJpOeBEDYGRhofN6KEVLZWHRa5 GnH8lT6nQ9AEkZdfCGdCRttZhUDftlmpj+pUp1B7h9wRyvcq78owp+Ktv4yDJ5leljdi lJzj7eDtWyCbbkp2aHTwQf9z17Cs4YmyWNlyZkRULzB0BYHLt2cfRC4xlcqs5wfH8ii6 3DXg== X-Gm-Message-State: AOJu0YxP1JjI19F3yke7T67D5NBGLDO93FuVBElg5V/UwmO9fhFDiTZ/ yuW/salokMBaFfm8xc8hRWk4iuP8z3fUqSr1EGh7vZ4DoJJOP0KZEKnlEAxE9gfw3grj3RgHc3Y jO/IrrMp/suUZTbUZ+zc= X-Received: by 2002:a2e:8e8c:0:b0:2b9:dd5d:5d0c with SMTP id z12-20020a2e8e8c000000b002b9dd5d5d0cmr552400ljk.52.1695890648471; Thu, 28 Sep 2023 01:44:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IElLrij4PTVdcXvTg3z4VuEcVoHwLdRYFDeiV+rV9sfTXRM3O+BmWo6WB0SrdUM2T5oUuyhVAgj5FUJnb/TriY= X-Received: by 2002:a2e:8e8c:0:b0:2b9:dd5d:5d0c with SMTP id z12-20020a2e8e8c000000b002b9dd5d5d0cmr552390ljk.52.1695890648111; Thu, 28 Sep 2023 01:44:08 -0700 (PDT) MIME-Version: 1.0 References: <20230831144450.3829729-1-maxime.coquelin@redhat.com> In-Reply-To: <20230831144450.3829729-1-maxime.coquelin@redhat.com> From: David Marchand Date: Thu, 28 Sep 2023 10:43:56 +0200 Message-ID: Subject: Re: [PATCH v2] vhost: add IRQ suppression To: Maxime Coquelin Cc: dev@dpdk.org, chenbo.xia@intel.com, echaudro@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" 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 Thu, Aug 31, 2023 at 4:44=E2=80=AFPM 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 > --- > 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 eb6309b681..7794f29c18 100644 > --- a/lib/vhost/vhost.c > +++ b/lib/vhost/vhost.c > @@ -48,6 +48,8 @@ static const struct vhost_vq_stats_name_off vhost_vq_st= at_strings[] =3D { > stats.guest_notifications_offloaded)}, > {"guest_notifications_error", offsetof(struct vhost_virtqueue, > stats.guest_notifications_error)}, > + {"guest_notifications_suppressed", offsetof(struct vhost_virtqueu= e, > + stats.guest_notifications_suppressed)}, > {"iotlb_hits", offsetof(struct vhost_virtqueue, stats= .iotlb_hits)}, > {"iotlb_misses", offsetof(struct vhost_virtqueue, stats= .iotlb_misses)}, > {"inflight_submitted", offsetof(struct vhost_virtqueue, stats= .inflight_submitted)}, > @@ -1516,6 +1518,8 @@ rte_vhost_notify_guest(int vid, uint16_t queue_id) > > rte_rwlock_read_lock(&vq->access_lock); > > + __atomic_store_n(&vq->irq_pending, false, __ATOMIC_RELEASE); > + > if (dev->backend_ops->inject_irq(dev, vq)) { > if (dev->flags & VIRTIO_DEV_STATS_ENABLED) > __atomic_fetch_add(&vq->stats.guest_notifications= _error, > diff --git a/lib/vhost/vhost.h b/lib/vhost/vhost.h > index 9723429b1c..3e78379e48 100644 > --- a/lib/vhost/vhost.h > +++ b/lib/vhost/vhost.h > @@ -156,6 +156,7 @@ struct virtqueue_stats { > uint64_t iotlb_misses; > uint64_t inflight_submitted; > uint64_t inflight_completed; > + uint64_t guest_notifications_suppressed; > /* Counters below are atomic, and should be incremented as such. = */ > uint64_t guest_notifications; > uint64_t guest_notifications_offloaded; > @@ -346,6 +347,8 @@ struct vhost_virtqueue { > > struct vhost_vring_addr ring_addrs; > struct virtqueue_stats stats; > + > + bool irq_pending; > } __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) > { > - if (dev->notify_ops->guest_notify && > - dev->notify_ops->guest_notify(dev->vid, vq->index)) { > - if (dev->flags & VIRTIO_DEV_STATS_ENABLED) > - __atomic_fetch_add(&vq->stats.guest_notifications= _offloaded, > - 1, __ATOMIC_RELAXED); > - return; > + bool expected =3D false; > + > + if (dev->notify_ops->guest_notify) { > + if (__atomic_compare_exchange_n(&vq->irq_pending, &expect= ed, true, 0, > + __ATOMIC_RELEASE, __ATOMIC_RELAXED)) { > + if (dev->notify_ops->guest_notify(dev->vid, vq->i= ndex)) { > + if (dev->flags & VIRTIO_DEV_STATS_ENABLED= ) > + __atomic_fetch_add(&vq->stats.gue= st_notifications_offloaded, > + 1, __ATOMIC_RELAXED); > + return; > + } > + > + /* Offloading failed, fallback to direct IRQ inje= ction */ > + __atomic_store_n(&vq->irq_pending, 0, __ATOMIC_RE= LEASE); Nit: s/0/false/ > + } else { > + vq->stats.guest_notifications_suppressed++; > + return; > + } > } > > if (dev->backend_ops->inject_irq(dev, vq)) { > -- > 2.41.0 > --=20 David Marchand