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 3252DA0506; Wed, 13 Apr 2022 07:49:03 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C4CCA4069D; Wed, 13 Apr 2022 07:49:02 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id D5B5B4068B for ; Wed, 13 Apr 2022 07:49:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1649828941; x=1681364941; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QK21g68IHCidaebV/OgLzxQ16h/OIDfMNDUktL68leI=; b=Ecoa2g2MAeX8r6WpY3HEk4BKy7W3L714kdBk9pfkRSnpLImIbFAiWl4z C+Zho/dC6lNlVRrrH2FysLbdTRTYPnY0PeKzvU0dWzL1pwwmDdlTjmlqW R0ksoqDDAg/i82Vv69estE28doNoHNYxPsCpUib0USAODmfJiPKlR9BQT x0+I/CzgTG0HmVOGRTUVUsVR3BkaqJFnWTz4vivdI91tzN9ucXwgr/r09 N0T+ZzwJzUwyq9f4Sa6I1NHqhIOiYTD6Uydg8T0E1YE7Dhkrylheyqr5M qZMRWw1N+qG6M7d/BE1b32+KK7H0zdx7+ajxQ4nn71Ip3higc4eUucPD3 Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10315"; a="262333120" X-IronPort-AV: E=Sophos;i="5.90,255,1643702400"; d="scan'208";a="262333120" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Apr 2022 22:49:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,255,1643702400"; d="scan'208";a="573123055" Received: from txandevlnx322.an.intel.com ([10.123.117.44]) by orsmga008.jf.intel.com with ESMTP; 12 Apr 2022 22:48:58 -0700 From: Naga Harish K S V To: ferruh.yigit@intel.com Cc: jay.jayatheerthan@intel.com, dev@dpdk.org Subject: [PATCH v2] kni: optimize alloc queue release Date: Wed, 13 Apr 2022 00:48:56 -0500 Message-Id: <20220413054856.3054752-1-s.v.naga.harish.k@intel.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220413054048.3052817-1-s.v.naga.harish.k@intel.com> References: <20220413054048.3052817-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 sppeds up the freeing process. Signed-off-by: Naga Harish K S V --- v2: * fix checkpatch errors --- 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