From patchwork Sat Sep 23 20:31:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Scheurich X-Patchwork-Id: 29132 X-Patchwork-Delegate: yuanhan.liu@linux.intel.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 EC12D1AEF5; Sat, 23 Sep 2017 22:31:39 +0200 (CEST) Received: from sesbmg22.ericsson.net (sesbmg22.ericsson.net [193.180.251.48]) by dpdk.org (Postfix) with ESMTP id AE94B7CFD for ; Sat, 23 Sep 2017 22:31:38 +0200 (CEST) X-AuditID: c1b4fb30-66bff70000007145-a0-59c6c4aa5bc3 Received: from ESESSHC005.ericsson.se (Unknown_Domain [153.88.183.33]) by sesbmg22.ericsson.net (Symantec Mail Security) with SMTP id B0.A3.28997.AA4C6C95; Sat, 23 Sep 2017 22:31:38 +0200 (CEST) Received: from ESESSMB107.ericsson.se ([169.254.7.166]) by ESESSHC005.ericsson.se ([153.88.183.33]) with mapi id 14.03.0352.000; Sat, 23 Sep 2017 22:31:37 +0200 From: Jan Scheurich To: "'dev@dpdk.org'" Thread-Topic: [PATCH v3] vhost: Expose virtio interrupt need on rte_vhost API Thread-Index: AdM0qvMtmEYHE931SOqKPNtAgfQLVA== Date: Sat, 23 Sep 2017 20:31:37 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [153.88.183.150] MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrDLMWRmVeSWpSXmKPExsUyM2K7ou6qI8ciDZ5f4bN492k7kwOjx68F S1kDGKO4bFJSczLLUov07RK4MjrX5RfsFa/oXnOUqYGxX7iLkZNDQsBE4tKmT2xdjFwcQgJH GCX6lzxnhnCWMEosXTODtYuRg4NNwEBi9m4HkAYRAWWJWce2s4HYwgIeElNeb2aFiPtKbDjy gAXC1pNY29/MBGKzCKhKXNr8jQlkDC9QzdItmSBhRgExie+n1oCVMAuIS9x6Mp8J4h4BiSV7 zjND2KISLx//Y4WwlSRWbL/ECFGvI7Fg9yc2CFtbYtnC12D1vAKCEidnPmGZwCg0C8nYWUha ZiFpmYWkZQEjyypG0eLU4qTcdCMjvdSizOTi4vw8vbzUkk2MwDA+uOW3wQ7Gl88dDzEKcDAq 8fCe3HosUog1say4MvcQowQHs5II7+JDQCHelMTKqtSi/Pii0pzU4kOM0hwsSuK8jvsuRAgJ pCeWpGanphakFsFkmTg4pRoYm9haGcRezsnMubX/l5nqb9bigr85f4M2Z1fuPnTEI5VBQ9j6 cCGnD/uehN2/lCIM5Tk2dXwzmVni8G75Pk+xtVutEmIsNDbf+igVcuXLIpkH/74s8PPlO7cy QjKCQ5Hzbn/3Q6fjH1LFn3/vj9vouuFXiJKsW9LMeRcyxYr53SdOsGQNlEhQYinOSDTUYi4q TgQAT1UK918CAAA= Subject: [dpdk-dev] [PATCH v3] vhost: Expose virtio interrupt need on rte_vhost API 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" Performance tests with the OVS DPDK datapath have shown that the tx throughput over a vhostuser port into a VM with an interrupt-based virtio driver is limited by the overhead incurred by virtio interrupts. The OVS PMD spends up to 30% of its cycles in system calls kicking the eventfd. Also the core running the vCPU is heavily loaded with generating the virtio interrupts in KVM on the host and handling these interrupts in the virtio-net driver in the guest. This limits the throughput to about 500-700 Kpps with a single vCPU. OVS is trying to address this issue by batching packets to a vhostuser port for some time to limit the virtio interrupt frequency. With a 50 us batching period we have measured an iperf3 throughput increase by 15% and a PMD utilization decrease from 45% to 30%. On the other hand, guests using virtio PMDs do not profit from time-based tx batching. Instead they experience a 2-3% performance penalty and an average latency increase of 30-40 us. OVS therefore intends to apply time-based tx batching only for vhostuser tx queues that need to trigger virtio interrupts. Today this information is hidden inside the rte_vhost library and not accessible to users of the API. This patch adds a function to the API to query it. Signed-off-by: Jan Scheurich --- v2 -> v3: Fixed even more white-space errors and warnings v1 -> v2: Fixed too long commit lines Fixed white-space errors and warnings lib/librte_vhost/rte_vhost.h | 12 ++++++++++++ lib/librte_vhost/vhost.c | 19 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/lib/librte_vhost/rte_vhost.h b/lib/librte_vhost/rte_vhost.h index 8c974eb..d62338b 100644 --- a/lib/librte_vhost/rte_vhost.h +++ b/lib/librte_vhost/rte_vhost.h @@ -444,6 +444,18 @@ int rte_vhost_get_vhost_vring(int vid, uint16_t vring_idx, */ uint32_t rte_vhost_rx_queue_count(int vid, uint16_t qid); +/** + * Does the virtio driver request interrupts for a vhost tx queue? + * + * @param vid + * vhost device ID + * @param qid + * virtio queue index in mq case + * @return + * 1 if true, 0 if false + */ +int rte_vhost_tx_interrupt_requested(int vid, uint16_t qid); + #ifdef __cplusplus } #endif diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c index 0b6aa1c..c6e636e 100644 --- a/lib/librte_vhost/vhost.c +++ b/lib/librte_vhost/vhost.c @@ -503,3 +503,22 @@ struct virtio_net * return *((volatile uint16_t *)&vq->avail->idx) - vq->last_avail_idx; } + +int rte_vhost_tx_interrupt_requested(int vid, uint16_t qid) +{ + struct virtio_net *dev; + struct vhost_virtqueue *vq; + + dev = get_device(vid); + if (dev == NULL) + return 0; + + vq = dev->virtqueue[qid]; + if (vq == NULL) + return 0; + + if (unlikely(vq->enabled == 0 || vq->avail == NULL)) + return 0; + + return !(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT); +}