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 2CE0CA0093; Fri, 17 Jun 2022 14:38:45 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0DD1F410FC; Fri, 17 Jun 2022 14:38:44 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 772A840698 for ; Fri, 17 Jun 2022 14:38:42 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25H3v4x2006661 for ; Fri, 17 Jun 2022 05:38:41 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=Ar9ff6ICCYysUijtGU12d92Jy6RujOM/W2ZlxhgQ3A8=; b=S8dGOQ1qXuLK+4IZ+rzWGz0HrqPpb/2bnjS8YWrwxiQbOKzNLZO80+Y1Sv8lT7Yh0q0L wz3O0lL+JnFIxL4V5YbPThTnqC7wtiTYg7J/Lyb+XNGmad6DRNC3B/JOE2yJbXkDYpRe ky7v60oPuYN3ywFHCTiVjcGujGtpgKCjE+vJ/iOSF5uffZj+Ya16xtjdw1kvUXro9P+x H5AO++/AxRlBa1TNAFHDRVGveNNTKHJF+Vd1IOrYSTibIcK78XlR145NMzdWpq7cNl5O qanOvJ57/18PrQ+E03wvzO04K/nRQ72juFZAS8Nrl4ojUvflRG8ojJu6tLoqMLDvfOXj EQ== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3grj5h9s9s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Fri, 17 Jun 2022 05:38:41 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 17 Jun 2022 05:38:40 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 17 Jun 2022 05:38:40 -0700 Received: from localhost.localdomain (unknown [10.28.34.39]) by maili.marvell.com (Postfix) with ESMTP id 971AA3F7084; Fri, 17 Jun 2022 05:38:38 -0700 (PDT) From: Volodymyr Fialko To: , Jerin Jacob CC: , Volodymyr Fialko Subject: [PATCH v2 1/2] app/eventdev: add null checks for cop allocations Date: Fri, 17 Jun 2022 14:38:17 +0200 Message-ID: <20220617123818.3359117-2-vfialko@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220617123818.3359117-1-vfialko@marvell.com> References: <20220617123818.3359117-1-vfialko@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: a5NT62FIp5QefHE7pgGeswWxlTQEYnhO X-Proofpoint-ORIG-GUID: a5NT62FIp5QefHE7pgGeswWxlTQEYnhO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.64.514 definitions=2022-06-17_08,2022-06-16_01,2022-02-23_01 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 Crypto operation allocation may fail in case when total size of queue pairs are bigger then the pool size. Signed-off-by: Volodymyr Fialko --- app/test-eventdev/test_perf_common.c | 40 ++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/app/test-eventdev/test_perf_common.c b/app/test-eventdev/test_perf_common.c index b41785492e..a5e031873d 100644 --- a/app/test-eventdev/test_perf_common.c +++ b/app/test-eventdev/test_perf_common.c @@ -367,6 +367,7 @@ crypto_adapter_enq_op_new(struct prod_data *p) struct evt_options *opt = t->opt; uint16_t qp_id = p->ca.cdev_qp_id; uint8_t cdev_id = p->ca.cdev_id; + uint64_t alloc_failures = 0; uint32_t flow_counter = 0; struct rte_crypto_op *op; struct rte_mbuf *m; @@ -386,9 +387,17 @@ crypto_adapter_enq_op_new(struct prod_data *p) op = rte_crypto_op_alloc(t->ca_op_pool, RTE_CRYPTO_OP_TYPE_SYMMETRIC); + if (unlikely(op == NULL)) { + alloc_failures++; + continue; + } + m = rte_pktmbuf_alloc(pool); - if (m == NULL) + if (unlikely(m == NULL)) { + alloc_failures++; + rte_crypto_op_free(op); continue; + } rte_pktmbuf_append(m, len); sym_op = op->sym; @@ -404,6 +413,11 @@ crypto_adapter_enq_op_new(struct prod_data *p) op = rte_crypto_op_alloc(t->ca_op_pool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC); + if (unlikely(op == NULL)) { + alloc_failures++; + continue; + } + asym_op = op->asym; asym_op->modex.base.data = modex_test_case.base.data; asym_op->modex.base.length = modex_test_case.base.len; @@ -418,6 +432,10 @@ crypto_adapter_enq_op_new(struct prod_data *p) count++; } + + if (opt->verbose_level > 1 && alloc_failures) + printf("%s(): lcore %d allocation failures: %"PRIu64"\n", + __func__, rte_lcore_id(), alloc_failures); } static inline void @@ -430,6 +448,7 @@ crypto_adapter_enq_op_fwd(struct prod_data *p) const uint64_t nb_pkts = t->nb_pkts; struct rte_mempool *pool = t->pool; struct evt_options *opt = t->opt; + uint64_t alloc_failures = 0; uint32_t flow_counter = 0; struct rte_crypto_op *op; struct rte_event ev; @@ -455,9 +474,17 @@ crypto_adapter_enq_op_fwd(struct prod_data *p) op = rte_crypto_op_alloc(t->ca_op_pool, RTE_CRYPTO_OP_TYPE_SYMMETRIC); + if (unlikely(op == NULL)) { + alloc_failures++; + continue; + } + m = rte_pktmbuf_alloc(pool); - if (m == NULL) + if (unlikely(m == NULL)) { + alloc_failures++; + rte_crypto_op_free(op); continue; + } rte_pktmbuf_append(m, len); sym_op = op->sym; @@ -473,6 +500,11 @@ crypto_adapter_enq_op_fwd(struct prod_data *p) op = rte_crypto_op_alloc(t->ca_op_pool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC); + if (unlikely(op == NULL)) { + alloc_failures++; + continue; + } + asym_op = op->asym; asym_op->modex.base.data = modex_test_case.base.data; asym_op->modex.base.length = modex_test_case.base.len; @@ -489,6 +521,10 @@ crypto_adapter_enq_op_fwd(struct prod_data *p) count++; } + + if (opt->verbose_level > 1 && alloc_failures) + printf("%s(): lcore %d allocation failures: %"PRIu64"\n", + __func__, rte_lcore_id(), alloc_failures); } static inline int -- 2.25.1