From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id D9ACE6A6F for ; Fri, 19 Aug 2016 14:51:57 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP; 19 Aug 2016 05:51:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,544,1464678000"; d="scan'208";a="1038480368" Received: from unknown (HELO dpdk5.sh.intel.com) ([10.239.129.118]) by orsmga002.jf.intel.com with ESMTP; 19 Aug 2016 05:51:45 -0700 From: Zhihong Wang To: dev@dpdk.org Cc: maxime.coquelin@redhat.com, yuanhan.liu@linux.intel.com Date: Fri, 19 Aug 2016 01:43:45 -0400 Message-Id: <1471585430-125925-1-git-send-email-zhihong.wang@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1471319402-112998-1-git-send-email-zhihong.wang@intel.com> References: <1471319402-112998-1-git-send-email-zhihong.wang@intel.com> Subject: [dpdk-dev] [PATCH v3 0/5] vhost: optimize enqueue X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Aug 2016 12:51:58 -0000 This patch set optimizes the vhost enqueue function. It implements the vhost logic from scratch into a single function designed for high performance and good maintainability, and improves CPU efficiency significantly by optimizing cache access, which means: * For fast frontends (eg. DPDK virtio pmd), higher performance (maximum throughput) can be achieved. * For slow frontends (eg. kernel virtio-net), better scalability can be achieved, each vhost core can support more connections since it takes less cycles to handle each single frontend. The main optimization techniques are: 1. Reorder code to reduce CPU pipeline stall cycles. 2. Batch update the used ring for better efficiency. 3. Prefetch descriptor to hide cache latency. 4. Remove useless volatile attribute to allow compiler optimization. Code reordering and batch used ring update bring most of the performance improvements. In the existing code there're 2 callbacks for vhost enqueue: * virtio_dev_merge_rx for mrg_rxbuf turned on cases. * virtio_dev_rx for mrg_rxbuf turned off cases. The performance of the existing code is not optimal, especially when the mrg_rxbuf feature turned on. Also, having 2 separated functions increases maintenance efforts. --- Changes in v3: 1. Remove unnecessary memset which causes frontend stall on SNB & IVB. 2. Rename variables to follow naming convention. 3. Rewrite enqueue and delete the obsolete in the same patch. --- Changes in v2: 1. Split the big function into several small ones. 2. Use multiple patches to explain each optimization. 3. Add comments. Zhihong Wang (5): vhost: rewrite enqueue vhost: remove useless volatile vhost: add desc prefetch vhost: batch update used ring vhost: optimize cache access lib/librte_vhost/vhost-net.h | 6 +- lib/librte_vhost/vhost_rxtx.c | 573 +++++++++++++++--------------------------- lib/librte_vhost/virtio-net.c | 15 +- 3 files changed, 220 insertions(+), 374 deletions(-) -- 2.7.4