[dpdk-stable] patch 'net/ena/base: make allocation macros thread-safe' has been queued to stable release 19.11.3

luca.boccassi at gmail.com luca.boccassi at gmail.com
Tue May 19 15:03:11 CEST 2020


Hi,

FYI, your patch has been queued to stable release 19.11.3

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 05/21/20. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Thanks.

Luca Boccassi

---
>From d5cfa58c057548ddee9aac3e1993905df10e4c88 Mon Sep 17 00:00:00 2001
From: Igor Chauskin <igorch at amazon.com>
Date: Wed, 8 Apr 2020 10:28:53 +0200
Subject: [PATCH] net/ena/base: make allocation macros thread-safe

[ upstream commit b14fcac035fd8514851c9140a4e26d765b61c532 ]

Memory allocation region id could possibly be non-unique
due to non-atomic increment, causing allocation failure.

Fixes: 9ba7981ec992 ("ena: add communication layer for DPDK")

Signed-off-by: Igor Chauskin <igorch at amazon.com>
Reviewed-by: Michal Krawczyk <mk at semihalf.com>
Reviewed-by: Guy Tzalik <gtzalik at amazon.com>
---
 drivers/net/ena/base/ena_plat_dpdk.h | 10 ++++++----
 drivers/net/ena/ena_ethdev.c         |  2 +-
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ena/base/ena_plat_dpdk.h b/drivers/net/ena/base/ena_plat_dpdk.h
index 9e1492cac4..db9d1bb36b 100644
--- a/drivers/net/ena/base/ena_plat_dpdk.h
+++ b/drivers/net/ena/base/ena_plat_dpdk.h
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright (c) 2015-2019 Amazon.com, Inc. or its affiliates.
+ * Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates.
  * All rights reserved.
  */
 
@@ -178,7 +178,7 @@ do {                                                                   \
  * Each rte_memzone should have unique name.
  * To satisfy it, count number of allocations and add it to name.
  */
-extern uint32_t ena_alloc_cnt;
+extern rte_atomic32_t ena_alloc_cnt;
 
 #define ENA_MEM_ALLOC_COHERENT(dmadev, size, virt, phys, handle)	\
 	do {								\
@@ -186,7 +186,8 @@ extern uint32_t ena_alloc_cnt;
 		char z_name[RTE_MEMZONE_NAMESIZE];			\
 		ENA_TOUCH(dmadev); ENA_TOUCH(handle);			\
 		snprintf(z_name, sizeof(z_name),			\
-				"ena_alloc_%d", ena_alloc_cnt++);	\
+			 "ena_alloc_%d",				\
+			 rte_atomic32_add_return(&ena_alloc_cnt, 1));	\
 		mz = rte_memzone_reserve(z_name, size, SOCKET_ID_ANY,	\
 				RTE_MEMZONE_IOVA_CONTIG);		\
 		handle = mz;						\
@@ -211,7 +212,8 @@ extern uint32_t ena_alloc_cnt;
 		char z_name[RTE_MEMZONE_NAMESIZE];			\
 		ENA_TOUCH(dmadev); ENA_TOUCH(dev_node);			\
 		snprintf(z_name, sizeof(z_name),			\
-				"ena_alloc_%d", ena_alloc_cnt++);	\
+			 "ena_alloc_%d",				\
+			 rte_atomic32_add_return(&ena_alloc_cnt, 1));	\
 		mz = rte_memzone_reserve(z_name, size, node,		\
 				RTE_MEMZONE_IOVA_CONTIG);		\
 		mem_handle = mz;					\
diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index 8bbd80dfb3..758d68d10b 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c
@@ -89,7 +89,7 @@ struct ena_stats {
  * Each rte_memzone should have unique name.
  * To satisfy it, count number of allocation and add it to name.
  */
-uint32_t ena_alloc_cnt;
+rte_atomic32_t ena_alloc_cnt;
 
 static const struct ena_stats ena_stats_global_strings[] = {
 	ENA_STAT_GLOBAL_ENTRY(wd_expired),
-- 
2.20.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2020-05-19 14:04:46.794713641 +0100
+++ 0056-net-ena-base-make-allocation-macros-thread-safe.patch	2020-05-19 14:04:44.204648155 +0100
@@ -1,13 +1,14 @@
-From b14fcac035fd8514851c9140a4e26d765b61c532 Mon Sep 17 00:00:00 2001
+From d5cfa58c057548ddee9aac3e1993905df10e4c88 Mon Sep 17 00:00:00 2001
 From: Igor Chauskin <igorch at amazon.com>
 Date: Wed, 8 Apr 2020 10:28:53 +0200
 Subject: [PATCH] net/ena/base: make allocation macros thread-safe
 
+[ upstream commit b14fcac035fd8514851c9140a4e26d765b61c532 ]
+
 Memory allocation region id could possibly be non-unique
 due to non-atomic increment, causing allocation failure.
 
 Fixes: 9ba7981ec992 ("ena: add communication layer for DPDK")
-Cc: stable at dpdk.org
 
 Signed-off-by: Igor Chauskin <igorch at amazon.com>
 Reviewed-by: Michal Krawczyk <mk at semihalf.com>
@@ -18,7 +19,7 @@
  2 files changed, 7 insertions(+), 5 deletions(-)
 
 diff --git a/drivers/net/ena/base/ena_plat_dpdk.h b/drivers/net/ena/base/ena_plat_dpdk.h
-index b611fb204b..70261bdbc6 100644
+index 9e1492cac4..db9d1bb36b 100644
 --- a/drivers/net/ena/base/ena_plat_dpdk.h
 +++ b/drivers/net/ena/base/ena_plat_dpdk.h
 @@ -1,5 +1,5 @@
@@ -28,7 +29,7 @@
   * All rights reserved.
   */
  
-@@ -180,7 +180,7 @@ do {                                                                   \
+@@ -178,7 +178,7 @@ do {                                                                   \
   * Each rte_memzone should have unique name.
   * To satisfy it, count number of allocations and add it to name.
   */
@@ -37,7 +38,7 @@
  
  #define ENA_MEM_ALLOC_COHERENT(dmadev, size, virt, phys, handle)	\
  	do {								\
-@@ -188,7 +188,8 @@ extern uint32_t ena_alloc_cnt;
+@@ -186,7 +186,8 @@ extern uint32_t ena_alloc_cnt;
  		char z_name[RTE_MEMZONE_NAMESIZE];			\
  		ENA_TOUCH(dmadev); ENA_TOUCH(handle);			\
  		snprintf(z_name, sizeof(z_name),			\
@@ -47,7 +48,7 @@
  		mz = rte_memzone_reserve(z_name, size, SOCKET_ID_ANY,	\
  				RTE_MEMZONE_IOVA_CONTIG);		\
  		handle = mz;						\
-@@ -213,7 +214,8 @@ extern uint32_t ena_alloc_cnt;
+@@ -211,7 +212,8 @@ extern uint32_t ena_alloc_cnt;
  		char z_name[RTE_MEMZONE_NAMESIZE];			\
  		ENA_TOUCH(dmadev); ENA_TOUCH(dev_node);			\
  		snprintf(z_name, sizeof(z_name),			\
@@ -58,7 +59,7 @@
  				RTE_MEMZONE_IOVA_CONTIG);		\
  		mem_handle = mz;					\
 diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
-index 64aabbbb19..e0ed28419c 100644
+index 8bbd80dfb3..758d68d10b 100644
 --- a/drivers/net/ena/ena_ethdev.c
 +++ b/drivers/net/ena/ena_ethdev.c
 @@ -89,7 +89,7 @@ struct ena_stats {


More information about the stable mailing list