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 56F52A0506; Wed, 13 Apr 2022 07:40:55 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E91D84069D; Wed, 13 Apr 2022 07:40:54 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mails.dpdk.org (Postfix) with ESMTP id 81C234068B for ; Wed, 13 Apr 2022 07:40:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1649828453; x=1681364453; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=KrUneKvwawVCZjHlyJQypT6vU/wRWImQF4sErrQpmuM=; b=FJko/IyFYnauCURQ2sEzqgzDPFp9HRvmzIjDcD1gGXORZpwf2LVSHdYl DbWEoA213gPWRL4VhWFc3J1ODnAmBQPq0+BGCdX9UPqs/eBofjs1szO0C FstlJD6eGSRCy6AuZeUs5Rjc76mSkjN75GYQevCv5AKQ8w7Hzce162wC9 3MKKM3fhBhZc/ndTJnzbu0nRrBR2uDddWMXYklmY12/ClX+DA5nUqyDlD fd4t06m/0H6WyJl6frXKRoiiW5WhybHb52AXjbD+sI0DfuICo8qEKHwov UwORBqq8jMWVkn29wuessOICfMonGSw9MPYHmKQItpRyH2XjWDAhuh+Cu A==; X-IronPort-AV: E=McAfee;i="6400,9594,10315"; a="349016505" X-IronPort-AV: E=Sophos;i="5.90,255,1643702400"; d="scan'208";a="349016505" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Apr 2022 22:40:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,255,1643702400"; d="scan'208";a="573120555" Received: from txandevlnx322.an.intel.com ([10.123.117.44]) by orsmga008.jf.intel.com with ESMTP; 12 Apr 2022 22:40:51 -0700 From: Naga Harish K S V To: ferruh.yigit@intel.com Cc: jay.jayatheerthan@intel.com, dev@dpdk.org Subject: [PATCH] kni: optimize alloc queue release Date: Wed, 13 Apr 2022 00:40:48 -0500 Message-Id: <20220413054048.3052817-1-s.v.naga.harish.k@intel.com> X-Mailer: git-send-email 2.23.0 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 takes 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 --- 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