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 3AA05A050D; Wed, 13 Apr 2022 16:57:44 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E20CE40694; Wed, 13 Apr 2022 16:57:43 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mails.dpdk.org (Postfix) with ESMTP id A833A4068E for ; Wed, 13 Apr 2022 16:57:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1649861861; x=1681397861; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=33mgRUwkz3fYSZTH+LSt/UXPk5lJ2F3HG4Fm713pBPw=; b=OBD+VJKJWJ91WS5cyhJEHxNm9ZPzDAoUvipDzG4YZNxsLmRJzje/U9dV Rs0aOmkgydnPFUMJYQvF1IgP3gTouiRBvZAQQZaWlado37WA/yA7lFkOX n+QhK+svprjmdiDnsEDc/73wmtEMEUMj0667L4zE793v9ElMdsMYnsXvh ulJK5StQ0kM7Q9QxwKHcjUzo6noF6BEeId/S6/+NHIqs40gtFCVBaXQBH 9tkbQoBsXl0lGELsSrUxu5yjszPfVCmdN6+tB2wv1+HoHdxmBE+JzlETg TNZrbCNVmHUZaWmD0jnIRQJg9D1JTOQ9jKN5R/tyqnZaxnNBvQzUqh2rT Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10315"; a="262869568" X-IronPort-AV: E=Sophos;i="5.90,257,1643702400"; d="scan'208";a="262869568" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Apr 2022 07:57:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,257,1643702400"; d="scan'208";a="573304444" Received: from txandevlnx322.an.intel.com ([10.123.117.44]) by orsmga008.jf.intel.com with ESMTP; 13 Apr 2022 07:57:40 -0700 From: Naga Harish K S V To: ferruh.yigit@xilinx.com, ferruh.yigit@intel.com Cc: jay.jayatheerthan@intel.com, dev@dpdk.org Subject: [PATCH v3] kni: optimize alloc queue release Date: Wed, 13 Apr 2022 09:57:17 -0500 Message-Id: <20220413145717.3661947-1-s.v.naga.harish.k@intel.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220413054856.3054752-1-s.v.naga.harish.k@intel.com> References: <20220413054856.3054752-1-s.v.naga.harish.k@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 the kni alloc queue is filled with physical addresses of mbufs for kernel consumption. Any unused mbufs in the alloc queue are freed during shutdown sequence in rte_kni_release. In the current existing implementation, for freeing one entry of alloc queue all the objects of the mempool are traversed. This process is repeated for all the objects of the alloc queue which consumes lot of cpu cycles. Instead of using mempool object iteration method,use ``rte_mem_iova2virt()`` api to get the virtual address for the physical addresses of alloc_q objects. This speeds up the freeing process. Signed-off-by: Naga Harish K S V --- v2: * fix checkpatch errors v3: * fix commit message as per review comments --- lib/kni/rte_kni.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/lib/kni/rte_kni.c b/lib/kni/rte_kni.c index 7971c56bb4..f443e5b2fc 100644 --- a/lib/kni/rte_kni.c +++ b/lib/kni/rte_kni.c @@ -375,26 +375,19 @@ va2pa_all(struct rte_mbuf *mbuf) } static void -obj_free(struct rte_mempool *mp __rte_unused, void *opaque, void *obj, - unsigned obj_idx __rte_unused) -{ - struct rte_mbuf *m = obj; - void *mbuf_phys = opaque; - - if (va2pa(m) == mbuf_phys) - rte_pktmbuf_free(m); -} - -static void -kni_free_fifo_phy(struct rte_mempool *mp, struct rte_kni_fifo *fifo) +kni_free_fifo_phy(struct rte_kni_fifo *fifo) { void *mbuf_phys; int ret; + struct rte_mbuf *m; do { ret = kni_fifo_get(fifo, &mbuf_phys, 1); - if (ret) - rte_mempool_obj_iter(mp, obj_free, mbuf_phys); + if (ret) { + m = (struct rte_mbuf *) + rte_mem_iova2virt((rte_iova_t)mbuf_phys); + rte_pktmbuf_free(m); + } } while (ret); } @@ -440,7 +433,7 @@ rte_kni_release(struct rte_kni *kni) if (kni_fifo_count(kni->rx_q)) RTE_LOG(ERR, KNI, "Fail to free all Rx-q items\n"); - kni_free_fifo_phy(kni->pktmbuf_pool, kni->alloc_q); + kni_free_fifo_phy(kni->alloc_q); kni_free_fifo(kni->tx_q); kni_free_fifo(kni->free_q); -- 2.23.0