From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E2088A0548; Tue, 22 Jun 2021 14:27:49 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 642B84003F; Tue, 22 Jun 2021 14:27:49 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id 156CD4003C; Tue, 22 Jun 2021 14:27:46 +0200 (CEST) IronPort-SDR: w3ccoiZnfmqcK7jf6Ee8z8+epqnMcM+KbYOvaXn62Imjm20fWZCi3PiyUuqoJmx0p2QbDYenLr EMnHLw84Uyfw== X-IronPort-AV: E=McAfee;i="6200,9189,10022"; a="228597711" X-IronPort-AV: E=Sophos;i="5.83,291,1616482800"; d="scan'208";a="228597711" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2021 05:27:42 -0700 IronPort-SDR: m5rCKM+RG3NAJKB9V365v4G1Sth9rDI3kjZCXAvWEuOpF09TskLdR3gXS/dpLRPhMQHDzGKw8r /9hxOwoRKHSA== X-IronPort-AV: E=Sophos;i="5.83,291,1616482800"; d="scan'208";a="486897417" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.213.201.251]) ([10.213.201.251]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2021 05:27:39 -0700 To: wangyunjian , dev@dpdk.org Cc: thomas@monjalon.net, gowrishankar.m@linux.vnet.ibm.com, dingxiaoxiong@huawei.com, stable@dpdk.org, Cheng Liu References: <4ebfe0d38b335a437edc9c58368153d005f562ce.1622460655.git.wangyunjian@huawei.com> <4aebf99afe5bae2b25f2e5445a32243ffd6f7e97.1624359204.git.wangyunjian@huawei.com> From: Ferruh Yigit X-User: ferruhy Message-ID: <4edb86a1-7629-9cc8-8068-702318234904@intel.com> Date: Tue, 22 Jun 2021 13:27:35 +0100 MIME-Version: 1.0 In-Reply-To: <4aebf99afe5bae2b25f2e5445a32243ffd6f7e97.1624359204.git.wangyunjian@huawei.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v2] kni: fix wrong mbuf alloc count in kni_allocate_mbufs X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" On 6/22/2021 11:57 AM, wangyunjian wrote: > From: Yunjian Wang > > In kni_allocate_mbufs(), we alloc mbuf for alloc_q as this code. > allocq_free = (kni->alloc_q->read - kni->alloc_q->write - 1) \ > & (MAX_MBUF_BURST_NUM - 1); > The value of allocq_free maybe zero, for example : > The ring size is 1024. After init, write = read = 0. Then we fill > kni->alloc_q to full. At this time, write = 1023, read = 0. > > Then the kernel send 32 packets to userspace. At this time, write > = 1023, read = 32. And then the userspace receive this 32 packets. > Then fill the kni->alloc_q, (32 - 1023 - 1) & 31 = 0, fill nothing. > ... > Then the kernel send 32 packets to userspace. At this time, write > = 1023, read = 992. And then the userspace receive this 32 packets. > Then fill the kni->alloc_q, (992 - 1023 - 1) & 31 = 0, fill nothing. > > Then the kernel send 32 packets to userspace. The kni->alloc_q only > has 31 mbufs and will drop one packet. > > Absolutely, this is a special scene. Normally, it will fill some > mbufs everytime, but may not enough for the kernel to use. > > In this patch, we always keep the kni->alloc_q to full for the kernel > to use. > > Fixes: 49da4e82cf94 ("kni: allocate no more mbuf than empty slots in queue") > Cc: stable@dpdk.org > > Signed-off-by: Cheng Liu > Signed-off-by: Yunjian Wang Acked-by: Ferruh Yigit What do you think to change patch title to something like: kni: fix mbuf allocation for alloc FIFO