From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 141C8C48BE8 for ; Fri, 18 Jun 2021 13:37:20 +0000 (UTC) Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by mail.kernel.org (Postfix) with ESMTP id 9096B611CC for ; Fri, 18 Jun 2021 13:37:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9096B611CC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9BCFC40150; Fri, 18 Jun 2021 15:37:18 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id C7D2D40142 for ; Fri, 18 Jun 2021 15:37:16 +0200 (CEST) IronPort-SDR: SRPWk5Vdnxo0JgLyawD47xApNudcHJJrkddim7w3IgVgOSAbvrA7Z0XSkqRYPISU80fADnB5DQ UfMcilo/pxmg== X-IronPort-AV: E=McAfee;i="6200,9189,10018"; a="193684369" X-IronPort-AV: E=Sophos;i="5.83,283,1616482800"; d="scan'208";a="193684369" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jun 2021 06:37:15 -0700 IronPort-SDR: id0x+04dBOps7kw/3f0qBiYTcfWKMUzY3oS9yCjzZ6ocY3wbds8fVvSFqIMFE7K4OKFxCS4rHw oydgJUFhQX2w== X-IronPort-AV: E=Sophos;i="5.83,283,1616482800"; d="scan'208";a="422224451" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.213.219.119]) ([10.213.219.119]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jun 2021 06:37:14 -0700 To: wangyunjian , dev@dpdk.org Cc: liucheng11@huawei.com, dingxiaoxiong@huawei.com References: <4ebfe0d38b335a437edc9c58368153d005f562ce.1622460655.git.wangyunjian@huawei.com> From: Ferruh Yigit X-User: ferruhy Message-ID: <0d996824-6015-18d6-c730-1821a34aae0c@intel.com> Date: Fri, 18 Jun 2021 14:37:10 +0100 MIME-Version: 1.0 In-Reply-To: <4ebfe0d38b335a437edc9c58368153d005f562ce.1622460655.git.wangyunjian@huawei.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] 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 5/31/2021 1:09 PM, 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 (e.g 32 & (32 - 1) = 0), and > it will not fill the alloc_q. When the alloc_q's free count is > zero, it will drop the packet in kernel kni. > nack Both 'read' & 'write' pointers can be max 'len-1', so 'read - write - 1' can't be 'len'. For above example first part can't be '32'. But if you are observing a problem, can you please describe it a little more, it may be because of something else. > In this patch, we set the allocq_free as the min between > MAX_MBUF_BURST_NUM and the free count of the alloc_q. > > Signed-off-by: Cheng Liu > Signed-off-by: Yunjian Wang > --- > lib/kni/rte_kni.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/lib/kni/rte_kni.c b/lib/kni/rte_kni.c > index 9dae6a8d7c..20d8f20cef 100644 > --- a/lib/kni/rte_kni.c > +++ b/lib/kni/rte_kni.c > @@ -677,8 +677,9 @@ kni_allocate_mbufs(struct rte_kni *kni) > return; > } > > - allocq_free = (kni->alloc_q->read - kni->alloc_q->write - 1) > - & (MAX_MBUF_BURST_NUM - 1); > + allocq_free = kni_fifo_free_count(kni->alloc_q); > + allocq_free = (allocq_free > MAX_MBUF_BURST_NUM) ? > + MAX_MBUF_BURST_NUM : allocq_free; > for (i = 0; i < allocq_free; i++) { > pkts[i] = rte_pktmbuf_alloc(kni->pktmbuf_pool); > if (unlikely(pkts[i] == NULL)) { >