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 23786A0093; Fri, 16 Dec 2022 11:33:18 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 282CD42D44; Fri, 16 Dec 2022 11:32:53 +0100 (CET) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id A200242D15 for ; Fri, 16 Dec 2022 11:32:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1671186767; x=1702722767; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=W13xRyxlrIa4xBmfBv3H9XI9q1PbqMJGofbYW6U+Wd4=; b=AIAvLOz4L3fgBNCTPXdNzMKGiUEsmpDYU1CC5Hwo66SJ5N34w7fSGTdg ytWLKnqFZpDo1Y/TMY4Mi780R8+o0tqXsY6XhQsLdjwOYm5fBtYodHrqm ENdcEjZXZB6lS6zX6v1Jdg2VHnZ49Rbccl0dvNYMS4PLiBB60nsK8vzJx 8TL+aaT3VyQbjWPrG11tKyDLi5kX/jceORaqG53AEyOehjWGyyyabPH7l JrvD/isqJW+XQdjORSFE8vNRSOrqg+5k39E/c6RdsXhCg8KTEgtbQZLvE ZVog5M4XBG1nmXW690qYnAXYws6+3I6EEXNzDszTLltDXH9WoWIckTv4+ w==; X-IronPort-AV: E=McAfee;i="6500,9779,10562"; a="306616625" X-IronPort-AV: E=Sophos;i="5.96,249,1665471600"; d="scan'208";a="306616625" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Dec 2022 02:32:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10562"; a="713230896" X-IronPort-AV: E=Sophos;i="5.96,249,1665471600"; d="scan'208";a="713230896" Received: from dpdk-mingxial-01.sh.intel.com ([10.67.119.112]) by fmsmga008.fm.intel.com with ESMTP; 16 Dec 2022 02:32:37 -0800 From: Mingxia Liu To: dev@dpdk.org Cc: jingjing.wu@intel.com, beilei.xing@intel.com, qi.z.zhang@intel.com, Mingxia Liu Subject: [PATCH 7/7] common/idpf: update mbuf_alloc_failed multi-thread process Date: Fri, 16 Dec 2022 09:37:06 +0000 Message-Id: <20221216093706.2453812-8-mingxia.liu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221216093706.2453812-1-mingxia.liu@intel.com> References: <20221216093706.2453812-1-mingxia.liu@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 As the variable mbuf_alloc_failed is operated by more than thread, change it to type rte_atomic64_t and operated by rte_atomic64_xx() function, this will avoid multithreading issue. Signed-off-by: Mingxia Liu --- drivers/common/idpf/idpf_common_rxtx.c | 10 ++++++---- drivers/common/idpf/idpf_common_rxtx.h | 2 +- drivers/common/idpf/idpf_common_rxtx_avx512.c | 12 ++++++++---- drivers/net/idpf/idpf_ethdev.c | 5 +++-- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/drivers/common/idpf/idpf_common_rxtx.c b/drivers/common/idpf/idpf_common_rxtx.c index cec99d2951..dd8e761834 100644 --- a/drivers/common/idpf/idpf_common_rxtx.c +++ b/drivers/common/idpf/idpf_common_rxtx.c @@ -592,7 +592,8 @@ idpf_split_rx_bufq_refill(struct idpf_rx_queue *rx_bufq) next_avail = 0; rx_bufq->nb_rx_hold -= delta; } else { - rx_bufq->rx_stats.mbuf_alloc_failed += nb_desc - next_avail; + rte_atomic64_add(&(rx_bufq->rx_stats.mbuf_alloc_failed), + nb_desc - next_avail); RX_LOG(DEBUG, "RX mbuf alloc failed port_id=%u queue_id=%u", rx_bufq->port_id, rx_bufq->queue_id); return; @@ -611,7 +612,8 @@ idpf_split_rx_bufq_refill(struct idpf_rx_queue *rx_bufq) next_avail += nb_refill; rx_bufq->nb_rx_hold -= nb_refill; } else { - rx_bufq->rx_stats.mbuf_alloc_failed += nb_desc - next_avail; + rte_atomic64_add(&(rx_bufq->rx_stats.mbuf_alloc_failed), + nb_desc - next_avail); RX_LOG(DEBUG, "RX mbuf alloc failed port_id=%u queue_id=%u", rx_bufq->port_id, rx_bufq->queue_id); } @@ -1088,7 +1090,7 @@ idpf_singleq_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, nmb = rte_mbuf_raw_alloc(rxq->mp); if (unlikely(nmb == NULL)) { - rxq->rx_stats.mbuf_alloc_failed++; + rte_atomic64_inc(&(rxq->rx_stats.mbuf_alloc_failed)); RX_LOG(DEBUG, "RX mbuf alloc failed port_id=%u " "queue_id=%u", rxq->port_id, rxq->queue_id); break; @@ -1197,7 +1199,7 @@ idpf_singleq_recv_scatter_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, nmb = rte_mbuf_raw_alloc(rxq->mp); if (unlikely(!nmb)) { - rxq->rx_stats.mbuf_alloc_failed++; + rte_atomic64_inc(&(rxq->rx_stats.mbuf_alloc_failed)); RX_LOG(DEBUG, "RX mbuf alloc failed port_id=%u " "queue_id=%u", rxq->port_id, rxq->queue_id); break; diff --git a/drivers/common/idpf/idpf_common_rxtx.h b/drivers/common/idpf/idpf_common_rxtx.h index eee9fdbd9e..0209750187 100644 --- a/drivers/common/idpf/idpf_common_rxtx.h +++ b/drivers/common/idpf/idpf_common_rxtx.h @@ -91,7 +91,7 @@ #define PF_GLTSYN_SHTIME_H_5 (PF_TIMESYNC_BAR4_BASE + 0x13C) struct idpf_rx_stats { - uint64_t mbuf_alloc_failed; + rte_atomic64_t mbuf_alloc_failed; }; struct idpf_rx_queue { diff --git a/drivers/common/idpf/idpf_common_rxtx_avx512.c b/drivers/common/idpf/idpf_common_rxtx_avx512.c index 5a91ed610e..1fc110cc94 100644 --- a/drivers/common/idpf/idpf_common_rxtx_avx512.c +++ b/drivers/common/idpf/idpf_common_rxtx_avx512.c @@ -38,7 +38,8 @@ idpf_singleq_rearm_common(struct idpf_rx_queue *rxq) dma_addr0); } } - rxq->rx_stats.mbuf_alloc_failed += IDPF_RXQ_REARM_THRESH; + rte_atomic64_add(&(rxq->rx_stats.mbuf_alloc_failed), + IDPF_RXQ_REARM_THRESH); return; } struct rte_mbuf *mb0, *mb1, *mb2, *mb3; @@ -167,7 +168,8 @@ idpf_singleq_rearm(struct idpf_rx_queue *rxq) dma_addr0); } } - rxq->rx_stats.mbuf_alloc_failed += IDPF_RXQ_REARM_THRESH; + rte_atomic64_add(&(rxq->rx_stats.mbuf_alloc_failed), + IDPF_RXQ_REARM_THRESH); return; } } @@ -562,7 +564,8 @@ idpf_splitq_rearm_common(struct idpf_rx_queue *rx_bufq) dma_addr0); } } - rx_bufq->rx_stats.mbuf_alloc_failed += IDPF_RXQ_REARM_THRESH; + rte_atomic64_add(&(rx_bufq->rx_stats.mbuf_alloc_failed), + IDPF_RXQ_REARM_THRESH); return; } @@ -635,7 +638,8 @@ idpf_splitq_rearm(struct idpf_rx_queue *rx_bufq) dma_addr0); } } - rx_bufq->rx_stats.mbuf_alloc_failed += IDPF_RXQ_REARM_THRESH; + rte_atomic64_add(&(rx_bufq->rx_stats.mbuf_alloc_failed), + IDPF_RXQ_REARM_THRESH); return; } } diff --git a/drivers/net/idpf/idpf_ethdev.c b/drivers/net/idpf/idpf_ethdev.c index 97c03118e0..1a7dab1844 100644 --- a/drivers/net/idpf/idpf_ethdev.c +++ b/drivers/net/idpf/idpf_ethdev.c @@ -256,7 +256,8 @@ idpf_get_mbuf_alloc_failed_stats(struct rte_eth_dev *dev) for (i = 0; i < dev->data->nb_rx_queues; i++) { rxq = dev->data->rx_queues[i]; - mbuf_alloc_failed += rxq->rx_stats.mbuf_alloc_failed; + mbuf_alloc_failed += + rte_atomic64_read(&(rxq->rx_stats.mbuf_alloc_failed)); } return mbuf_alloc_failed; @@ -303,7 +304,7 @@ idpf_reset_mbuf_alloc_failed_stats(struct rte_eth_dev *dev) for (i = 0; i < dev->data->nb_rx_queues; i++) { rxq = dev->data->rx_queues[i]; - rxq->rx_stats.mbuf_alloc_failed = 0; + rte_atomic64_set(&(rxq->rx_stats.mbuf_alloc_failed), 0); } } -- 2.25.1