From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf0-f42.google.com (mail-lf0-f42.google.com [209.85.215.42]) by dpdk.org (Postfix) with ESMTP id EC2A25A44 for ; Wed, 11 Jan 2017 05:57:34 +0100 (CET) Received: by mail-lf0-f42.google.com with SMTP id m78so107980926lfg.2 for ; Tue, 10 Jan 2017 20:57:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brain4net.com; s=google; h=from:to:cc:subject:date:message-id; bh=ErPaYe787mOKTyUotyQ/1ObYblxdEQ2AziZtYJ/nhBI=; b=hTLJPzZXjLSFRn8G+Kb0YQFnuxNUcKdoht4IX9ZEzNAPuchbiNLG6NFqsPj3dScOBb h26wK6iSjh7YUM08GgGBT4b1TsclcEy9hk4NXjW7mH6R6em+nMyNPdAzhVSU6Jsb3G17 d9UGpQ8Gr9Ce2aCQecl6pbMrljYJKqZj0I2nU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ErPaYe787mOKTyUotyQ/1ObYblxdEQ2AziZtYJ/nhBI=; b=gGsz8oIH3Ka4J0ofZYFj1KjMAbWSnPf4lWmz+xh2h/LETh+G1rrHu05sS7sNtMxBCv TqHkoWwtnXBS/P4ulebX0Qg+Ejz4Qvmjb/SrwXlYIRHyuLinP1xuLSVO9nZa18v5LaA/ Nty9vbndhnIwjIC1u3bDoFZpjjp4eawEr7yQTJpbckf2GX6csL6kHF2CaF6O9vGGrrda ihMBDmfSZP035WUEvjlUqw55zWpestZCUw3gaTTW05jd7jkFri1baU1T7er5vtWes9Ko +KKb38wSdgJ6pC/IVuvmSARTkgcXbbUhcNT9XU0leVz7TkLj9Q+CmSrfiVaFPl+nV9+N akpg== X-Gm-Message-State: AIkVDXJGmuO0l1cYn8jqsjWAcz7rfq6XCqONFYWcDyJQnG7IuQN6Sy+yZBNEyreg8rHuPIaZ X-Received: by 10.46.9.216 with SMTP id 207mr2550473ljj.4.1484110654476; Tue, 10 Jan 2017 20:57:34 -0800 (PST) Received: from localhost.localdomain ([91.201.72.212]) by smtp.gmail.com with ESMTPSA id 87sm670071lft.27.2017.01.10.20.57.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Jan 2017 20:57:34 -0800 (PST) From: Sergey Vyazmitinov To: ferruh.yigit@intel.com Cc: dev@dpdk.org, Sergey Vyazmitinov Date: Fri, 30 Dec 2016 06:23:15 +0700 Message-Id: <1483053795-8489-1-git-send-email-s.vyazmitinov@brain4net.com> X-Mailer: git-send-email 2.7.4 Subject: [dpdk-dev] [PATCH] kni: fast data availability check in thread_single loop 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: , X-List-Received-Date: Wed, 11 Jan 2017 04:57:35 -0000 This allow to significant reduces packets processing latency. Signed-off-by: Sergey Vyazmitinov --- .../linuxapp/eal/include/exec-env/rte_kni_common.h | 6 ++++ lib/librte_eal/linuxapp/kni/kni_misc.c | 33 ++++++++++++++++------ 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h index 09713b0..8183a8e 100644 --- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h +++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h @@ -109,6 +109,12 @@ struct rte_kni_fifo { void *volatile buffer[]; /**< The buffer contains mbuf pointers */ }; +static inline int +kni_fifo_empty(struct rte_kni_fifo *fifo) +{ + return fifo->write == fifo->read; +} + /* * The kernel image of the rte_mbuf struct, with only the relevant fields. * Padding is necessary to assure the offsets of these fields diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c index 497db9b..4bf9bfa 100644 --- a/lib/librte_eal/linuxapp/kni/kni_misc.c +++ b/lib/librte_eal/linuxapp/kni/kni_misc.c @@ -45,6 +45,7 @@ MODULE_AUTHOR("Intel Corporation"); MODULE_DESCRIPTION("Kernel Module for managing kni devices"); #define KNI_RX_LOOP_NUM 1000 +#define KNI_RX_DATA_LOOP_NUM 2500 #define KNI_MAX_DEVICES 32 @@ -129,25 +130,39 @@ static struct pernet_operations kni_net_ops = { #endif }; -static int -kni_thread_single(void *data) +static inline void +kni_thread_single_rx_data_loop(struct kni_net *knet) { - struct kni_net *knet = data; - int j; struct kni_dev *dev; + int i; - while (!kthread_should_stop()) { - down_read(&knet->kni_list_lock); - for (j = 0; j < KNI_RX_LOOP_NUM; j++) { - list_for_each_entry(dev, &knet->kni_list_head, list) { + for (i = 0; i < KNI_RX_DATA_LOOP_NUM; ++i) { + list_for_each_entry(dev, &knet->kni_list_head, list) { + /* Burst dequeue from rx_q */ + if (!kni_fifo_empty((struct rte_kni_fifo *)dev->rx_q)) { #ifdef RTE_KNI_VHOST kni_chk_vhost_rx(dev); #else kni_net_rx(dev); #endif - kni_net_poll_resp(dev); } } + } + list_for_each_entry(dev, &knet->kni_list_head, list) { + kni_net_poll_resp(dev); + } +} + +static int +kni_thread_single(void *data) +{ + struct kni_net *knet = data; + int j; + + while (!kthread_should_stop()) { + down_read(&knet->kni_list_lock); + for (j = 0; j < KNI_RX_LOOP_NUM; j++) + kni_thread_single_rx_data_loop(knet); up_read(&knet->kni_list_lock); #ifdef RTE_KNI_PREEMPT_DEFAULT /* reschedule out for a while */ -- 2.7.4