From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f44.google.com (mail-wm0-f44.google.com [74.125.82.44]) by dpdk.org (Postfix) with ESMTP id 490472C49 for ; Fri, 10 Mar 2017 13:59:34 +0100 (CET) Received: by mail-wm0-f44.google.com with SMTP id n11so10042479wma.0 for ; Fri, 10 Mar 2017 04:59:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:user-agent:in-reply-to :references:mime-version:content-transfer-encoding; bh=SvDE2MTEspIOexkFe2hCypnWH5UsDEvF2/poTqrGMiM=; b=pWuns/+6qciIs7wRfMGEujfqbtrN9yYR1hEvx3O86F7rVIynrjIPEGfgF7jKzkzb3a e1875pfe5sv0yKbqCAEJernuWALpeIsnWE0lHfH1BOr8FCdHilXXcOBAlU3xmw7omkwl 9k6sE4ccmZjQYILEU0nbGfOwlyqCiUwXwIv8yr4grMi9dwW5wKVjcMmmVcTMrN9LMqCD kl01DKqr0Tli9ppSY9cie5ZBnQp1xFG5m1mj4b8ZUFxgvhDFomyaSuiJ/dty3LjewvnE IVQtfqAm0OpEvQFoEWk+nYEW8M7x2oQqDd5D0HSh6AS+YNacs7VaywPm0Zt251ZbBozu efrg== 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:user-agent :in-reply-to:references:mime-version:content-transfer-encoding; bh=SvDE2MTEspIOexkFe2hCypnWH5UsDEvF2/poTqrGMiM=; b=JOZZoEnVsKkYzbCsZ5Hn5Ba4P9MgU9qTdoe95yGI0FT8+Pk0BsCRMmKqfNqOAMPbjd aldmmEp1wyfcaL3tT8yT6NzbruVeltJSDuf0hPSZreqaH4+XlNmSNB/0/pXUyhp1ZrlS CisH3m7c7tcfjfZI5h65OniNzTAonz5dN3NKgIDmB7BaV5HN83jpnFR5hnCD+Zs8gV+V L/aftSrPDB2Z/BPKaOCuaZl+hjCfVM9Lu+Ygn+S6/GVOTVvMioXjizDaDmRslg+XSp/e AU1yo9l8QRO8faB/onbCIXWfCBNxdqRDkAF8ikCv4btI0kqR0CJ/8YKKiA33TKYdFCMx Kx8A== X-Gm-Message-State: AFeK/H3JUujRM9v7mc5AjXZ10jRNpvV3awogxYyB8oblflvxJudgh0mwM/jLKuWbR/jtLVJB X-Received: by 10.28.69.194 with SMTP id l63mr2213876wmi.23.1489150773954; Fri, 10 Mar 2017 04:59:33 -0800 (PST) Received: from xps13.localnet (184.203.134.77.rev.sfr.net. [77.134.203.184]) by smtp.gmail.com with ESMTPSA id g18sm3252694wme.2.2017.03.10.04.59.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Mar 2017 04:59:33 -0800 (PST) From: Thomas Monjalon To: Jay Rolette , Sergey Vyazmitinov , Ferruh Yigit Cc: dev@dpdk.org Date: Fri, 10 Mar 2017 13:59:32 +0100 Message-ID: <3217044.DUek5hOmOi@xps13> User-Agent: KMail/4.14.10 (Linux/4.5.4-1-ARCH; KDE/4.14.11; x86_64; ; ) In-Reply-To: References: <1483053795-8489-1-git-send-email-s.vyazmitinov@brain4net.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [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: Fri, 10 Mar 2017 12:59:34 -0000 2017-01-18 07:11, Jay Rolette: > On Wed, Jan 18, 2017 at 5:05 AM, Sergey Vyazmitinov < > s.vyazmitinov@brain4net.com> wrote: > > > On Thu, Jan 12, 2017 at 12:29 AM, Ferruh Yigit > > wrote: > > > > > On 12/29/2016 11:23 PM, Sergey Vyazmitinov wrote: > > > > This allow to significant reduces packets processing latency. > > > > > > > > Signed-off-by: Sergey Vyazmitinov [...] > > > > --- 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) { > > > > > > When there are multiple KNI interfaces, and lets assume there is traffic > > > too, this will behave like: > > > > > > KNI1x2500 data_packets + KNI2x2500 data_packets .... KNI10x2500 > > > > > > After data packets, KNI1 resp_packet + KNI2 resp_packets ... > > > > > > Won't this scenario also may cause latency? And perhaps jitter according > > > KNI interface traffic loads? > > > > > > This may be good for some use cases, but not sure if this is good for > > all. > > > > > We can decrease KNI_RX_DATA_LOOP_NUM to some reasonable value. > > I can make test to find lower bound. > > Also, the point is in fast check for a new data in interface rx queue. > > May be will be better add some kind of break after several kni_net_rx > > calls. > > Without them loop ends very quickly. > > Anyway, this patch decrease average latency in my case from 4.5ms to > > 0.011ms in ping test with 100000 packets. > > > > If you were seeing latency of 4.5ms, then it is more likely a different > issue. > > At the end of the loop where KNI is reading packets from the queue, it > calls *schedule_timeout_interruptible()* with (by default) a 5us timeout. > However, that call just guarantees that the thread will sleep for AT LEAST > 5us. > > For most x86 Linux distros, HZ = 250 in the kernel, which works out to 4ms. > I'm reasonably certain the latency you are seeing is because the KNI thread > is sleeping and not getting woken up like you might expect. > > When you increased the number of loops happening before the sleep, you > increased how long KNI spends before it sleeps and it happened to be long > enough in your particular test to change your average latency. If you ran > your test for a few minutes and built a histogram of ping times, I bet > you'll see ~4ms of latency pop up regularly. > > More details from when I dug into this behavior previously: > http://dpdk.org/ml/archives/dev/2015-June/018858.html No answer in this discussion. Should we close it in patchwork?