From patchwork Wed Aug 28 14:49:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eelco Chaudron X-Patchwork-Id: 58133 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 970931BEEE; Wed, 28 Aug 2019 16:49:46 +0200 (CEST) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 109561BE82 for ; Wed, 28 Aug 2019 16:49:45 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7E4F730832C0; Wed, 28 Aug 2019 14:49:44 +0000 (UTC) Received: from netdev64.ntdv.lab.eng.bos.redhat.com (wsfd-netdev64.ntdv.lab.eng.bos.redhat.com [10.19.188.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id 008065D70D; Wed, 28 Aug 2019 14:49:41 +0000 (UTC) From: Eelco Chaudron To: maxime.coquelin@redhat.com, tiwei.bie@intel.com, zhihong.wang@intel.com Cc: dev@dpdk.org Date: Wed, 28 Aug 2019 10:49:39 -0400 Message-Id: <25d9aeb9ba061b45d394081cc0cc7a347f7dfb2e.1567003335.git.echaudro@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 28 Aug 2019 14:49:44 +0000 (UTC) Subject: [dpdk-dev] [PATCH] vhost: add device opr when notification to guest is sent X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This patch adds an operation callback which gets called every time the library is waking up the guest trough an eventfd_write() call. This can be used by 3rd party application, like OVS, to track the number of times interrupts where generated. This might be of interest to find out system-call were called in the fast path. Signed-off-by: Eelco Chaudron Reviewed-by: Maxime Coquelin --- lib/librte_vhost/rte_vhost.h | 10 +++++++++- lib/librte_vhost/vhost.h | 15 ++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/lib/librte_vhost/rte_vhost.h b/lib/librte_vhost/rte_vhost.h index 7fb1729..878e339 100644 --- a/lib/librte_vhost/rte_vhost.h +++ b/lib/librte_vhost/rte_vhost.h @@ -172,7 +172,15 @@ struct vhost_device_ops { int (*new_connection)(int vid); void (*destroy_connection)(int vid); - void *reserved[2]; /**< Reserved for future extension */ + /** + * This callback gets called each time a guest gets notified + * about waiting packets. This is the interrupt handling trough + * the eventfd_write(callfd), which can be used for counting these + * "slow" syscalls. + */ + void (*guest_notified)(int vid); + + void *reserved[1]; /**< Reserved for future extension */ }; /** diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h index 884befa..5131a97 100644 --- a/lib/librte_vhost/vhost.h +++ b/lib/librte_vhost/vhost.h @@ -543,13 +543,19 @@ void *vhost_alloc_copy_ind_table(struct virtio_net *dev, if ((vhost_need_event(vhost_used_event(vq), new, old) && (vq->callfd >= 0)) || - unlikely(!signalled_used_valid)) + unlikely(!signalled_used_valid)) { eventfd_write(vq->callfd, (eventfd_t) 1); + if (dev->notify_ops->guest_notified) + dev->notify_ops->guest_notified(dev->vid); + } } else { /* Kick the guest if necessary. */ if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT) - && (vq->callfd >= 0)) + && (vq->callfd >= 0)) { eventfd_write(vq->callfd, (eventfd_t)1); + if (dev->notify_ops->guest_notified) + dev->notify_ops->guest_notified(dev->vid); + } } } @@ -600,8 +606,11 @@ void *vhost_alloc_copy_ind_table(struct virtio_net *dev, if (vhost_need_event(off, new, old)) kick = true; kick: - if (kick) + if (kick) { eventfd_write(vq->callfd, (eventfd_t)1); + if (dev->notify_ops->guest_notified) + dev->notify_ops->guest_notified(dev->vid); + } } static __rte_always_inline void