[dpdk-stable] patch 'timer: protect initialization with lock' has been queued to stable release 19.11.3

luca.boccassi at gmail.com luca.boccassi at gmail.com
Tue May 19 15:04:16 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 ccc676944f86c16151db2516a9bce37274c73f3b Mon Sep 17 00:00:00 2001
From: Honnappa Nagarahalli <honnappa.nagarahalli at arm.com>
Date: Mon, 24 Feb 2020 14:42:18 +0800
Subject: [PATCH] timer: protect initialization with lock

[ upstream commit 68f7f31aaa7479d36ae1d1e7853940ce4874cba7 ]

rte_timer_subsystem_initialized is a global variable that can be
accessed by multiple processes simultaneously. Hence, any access
to rte_timer_subsystem_initialized should be protected by
rte_mcfg_timer_lock.

Fixes: f9d6cd8bfe9e ("timer: fix resource leak in finalize")

Signed-off-by: Honnappa Nagarahalli <honnappa.nagarahalli at arm.com>
Reviewed-by: Gavin Hu <gavin.hu at arm.com>
Reviewed-by: Phil Yang <phil.yang at arm.com>
Acked-by: Erik Gabriel Carrillo <erik.g.carrillo at intel.com>
---
 lib/librte_timer/rte_timer.c | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/lib/librte_timer/rte_timer.c b/lib/librte_timer/rte_timer.c
index 4680a91b58..99862a3ba1 100644
--- a/lib/librte_timer/rte_timer.c
+++ b/lib/librte_timer/rte_timer.c
@@ -145,10 +145,12 @@ rte_timer_subsystem_init(void)
 	const size_t mem_size = data_arr_size + sizeof(*rte_timer_mz_refcnt);
 	bool do_full_init = true;
 
-	if (rte_timer_subsystem_initialized)
+	rte_mcfg_timer_lock();
+
+	if (rte_timer_subsystem_initialized) {
+		rte_mcfg_timer_unlock();
 		return -EALREADY;
-
-	rte_mcfg_timer_lock();
+	}
 
 	mz = rte_memzone_lookup(mz_name);
 	if (mz == NULL) {
@@ -183,27 +185,29 @@ rte_timer_subsystem_init(void)
 	rte_timer_data_arr[default_data_id].internal_flags |= FL_ALLOCATED;
 	(*rte_timer_mz_refcnt)++;
 
-	rte_mcfg_timer_unlock();
-
 	rte_timer_subsystem_initialized = 1;
 
+	rte_mcfg_timer_unlock();
+
 	return 0;
 }
 
 void
 rte_timer_subsystem_finalize(void)
 {
-	if (!rte_timer_subsystem_initialized)
-		return;
-
 	rte_mcfg_timer_lock();
 
+	if (!rte_timer_subsystem_initialized) {
+		rte_mcfg_timer_unlock();
+		return;
+	}
+
 	if (--(*rte_timer_mz_refcnt) == 0)
 		rte_memzone_free(rte_timer_data_mz);
 
-	rte_mcfg_timer_unlock();
-
 	rte_timer_subsystem_initialized = 0;
+
+	rte_mcfg_timer_unlock();
 }
 
 /* Initialize the timer handle tim for use */
-- 
2.20.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2020-05-19 14:04:49.393882410 +0100
+++ 0121-timer-protect-initialization-with-lock.patch	2020-05-19 14:04:44.392651562 +0100
@@ -1,15 +1,16 @@
-From 68f7f31aaa7479d36ae1d1e7853940ce4874cba7 Mon Sep 17 00:00:00 2001
+From ccc676944f86c16151db2516a9bce37274c73f3b Mon Sep 17 00:00:00 2001
 From: Honnappa Nagarahalli <honnappa.nagarahalli at arm.com>
 Date: Mon, 24 Feb 2020 14:42:18 +0800
 Subject: [PATCH] timer: protect initialization with lock
 
+[ upstream commit 68f7f31aaa7479d36ae1d1e7853940ce4874cba7 ]
+
 rte_timer_subsystem_initialized is a global variable that can be
 accessed by multiple processes simultaneously. Hence, any access
 to rte_timer_subsystem_initialized should be protected by
 rte_mcfg_timer_lock.
 
 Fixes: f9d6cd8bfe9e ("timer: fix resource leak in finalize")
-Cc: stable at dpdk.org
 
 Signed-off-by: Honnappa Nagarahalli <honnappa.nagarahalli at arm.com>
 Reviewed-by: Gavin Hu <gavin.hu at arm.com>
@@ -20,7 +21,7 @@
  1 file changed, 14 insertions(+), 10 deletions(-)
 
 diff --git a/lib/librte_timer/rte_timer.c b/lib/librte_timer/rte_timer.c
-index 89f27074f8..269e92114c 100644
+index 4680a91b58..99862a3ba1 100644
 --- a/lib/librte_timer/rte_timer.c
 +++ b/lib/librte_timer/rte_timer.c
 @@ -145,10 +145,12 @@ rte_timer_subsystem_init(void)


More information about the stable mailing list