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 9EC71A0509; Thu, 14 Apr 2022 19:35:10 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3F21740687; Thu, 14 Apr 2022 19:35:10 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id 232624067C for ; Thu, 14 Apr 2022 19:35:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1649957709; x=1681493709; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CCcLXr+UNhFvXerbTnR025pNjMSFpjGI+QDeaZAgBwg=; b=JTjn2ILeSL0KClNMZ0LBq5ibtuEEXLHR4jR8xQGxxGXTo8S4S/r6WXa8 IE2kuPWFKMRGaERCv7uB8h0IhNGJ9S4DbPKzYTUsRX9bObx2wWqoXPeJe uZJx4hqAmbKN4f+F7aTvtGV28BZHiMDHwQjCTllAAOgoeKTq4El765XTr MRIrxJidTUD/mdiAcRt4jMjPMB2SxOdiLnb0bRae3sCqigpFmnGqoLZ+0 jRZIu2vtQorBy+GDzHefCitSIvbiYOjP77Tw/9doIvUCcmnx1MGHNrS3g fsHNSZbYNtNzQKEICGyrAQte8QYDyqWbNgNOE88FcCJ9CocbDAS1ezuOK g==; X-IronPort-AV: E=McAfee;i="6400,9594,10317"; a="243576207" X-IronPort-AV: E=Sophos;i="5.90,260,1643702400"; d="scan'208";a="243576207" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Apr 2022 10:35:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,260,1643702400"; d="scan'208";a="573907113" Received: from txandevlnx322.an.intel.com ([10.123.117.44]) by orsmga008.jf.intel.com with ESMTP; 14 Apr 2022 10:35:06 -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 v4] kni: optimize alloc queue release Date: Thu, 14 Apr 2022 12:35:04 -0500 Message-Id: <20220414173504.771998-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 existing implementation, for freeing one entry of alloc queue all the objects of the mempool are traversed to find a match. 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 v4: * update 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