From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id A752A5A5C for ; Mon, 16 May 2016 13:20:38 +0200 (CEST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP; 16 May 2016 04:20:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,627,1455004800"; d="scan'208";a="104591964" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.237.221.111]) ([10.237.221.111]) by fmsmga004.fm.intel.com with ESMTP; 16 May 2016 04:20:31 -0700 To: ALeX Wang , dev@dpdk.org References: From: Ferruh Yigit Message-ID: <5739ACFF.4000506@intel.com> Date: Mon, 16 May 2016 12:20:31 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] possible kni bug and proposed fix 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: Mon, 16 May 2016 11:20:39 -0000 On 5/15/2016 5:48 AM, ALeX Wang wrote: > Hi, > > When using the kni module to test my application inside > debian (virtualbox) VM (kernel version 4.4), I get the > > "KNI: Out of memory" > > from syslog every time I `tcpreply` packets through > the kni interface. > > After checking source code, I saw that when I call > 'rte_kni_rx_burst()', no matter how many packets > are actually retrieved, we always call 'kni_allocate_mbufs()' > and try allocate 'MAX_MBUF_BURST_NUM' more > mbufs... I fix the issue via using this patch below, > > Could you confirm if this is an actual bug? > Hi Alex, I don't think this is a bug. kni_allocate_mbufs() will allocate MAX_MBUF_BURST_NUM mbufs as you mentioned. And will fill alloc_q with these mubfs _until it gets full_. And if the alloc_q is full and there are remaining mbufs, they will be freed. So for some cases this isn't the most optimized way, but there is no defect. Since you are getting "KNI: Out of memory", somewhere else can be missing freeing mbufs. mbufs freeing done in rte_kni_tx_burst(), I can guess two cases that can cause problem: a) not calling rte_kni_tx_burst() frequent, so that all free mbufs consumed. b) calling rte_kni_tx_burst() with number of mbufs bigger than MAX_MBUF_BURST_NUM, because this function frees at most MAX_MBUF_BURST_NUM of mbufs, but if you are calling calling rte_kni_tx_burst() with bigger numbers, this will cause mbufs to stuck in free_q Regards, ferruh