From: Phil Yang <phil.yang@arm.com>
To: rsanford@akamai.com, erik.g.carrillo@intel.com, dev@dpdk.org
Cc: david.marchand@redhat.com, anatoly.burakov@intel.com,
thomas@monjalon.net, jerinj@marvell.com, hemant.agrawal@nxp.com,
Honnappa.Nagarahalli@arm.com, gavin.hu@arm.com,
phil.yang@arm.com, nd@arm.com,
Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>,
stable@dpdk.org
Subject: [dpdk-dev] [PATCH 1/2] lib/timer: protect timer subsystem initialized with lock
Date: Mon, 24 Feb 2020 14:42:18 +0800 [thread overview]
Message-ID: <1582526539-14360-1-git-send-email-phil.yang@arm.com> (raw)
From: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
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@dpdk.org
Signed-off-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Reviewed-by: Gavin Hu <gavin.hu@arm.com>
Reviewed-by: Phil Yang <phil.yang@arm.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 89f2707..269e921 100644
--- a/lib/librte_timer/rte_timer.c
+++ b/lib/librte_timer/rte_timer.c
@@ -145,11 +145,13 @@ 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)
- return -EALREADY;
-
rte_mcfg_timer_lock();
+ if (rte_timer_subsystem_initialized) {
+ rte_mcfg_timer_unlock();
+ return -EALREADY;
+ }
+
mz = rte_memzone_lookup(mz_name);
if (mz == NULL) {
mz = rte_memzone_reserve_aligned(mz_name, mem_size,
@@ -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.7.4
next reply other threads:[~2020-02-24 6:42 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-24 6:42 Phil Yang [this message]
2020-02-24 6:42 ` [dpdk-dev] [PATCH 2/2] lib/timer: relax barrier for status update Phil Yang
2020-04-08 10:23 ` Phil Yang
2020-04-08 21:10 ` Carrillo, Erik G
2020-04-08 21:16 ` Honnappa Nagarahalli
2020-04-08 21:26 ` Carrillo, Erik G
2020-04-08 21:56 ` Honnappa Nagarahalli
2020-04-09 19:29 ` Carrillo, Erik G
2020-04-10 4:39 ` Phil Yang
2020-04-20 16:05 ` [dpdk-dev] [PATCH v2] " Phil Yang
2020-04-23 20:06 ` Honnappa Nagarahalli
2020-04-24 1:26 ` Carrillo, Erik G
2020-04-24 7:27 ` Phil Yang
2020-04-24 7:24 ` [dpdk-dev] [PATCH v3] " Phil Yang
2020-04-25 17:17 ` Thomas Monjalon
2020-04-26 7:36 ` Phil Yang
2020-04-26 12:18 ` Carrillo, Erik G
2020-04-26 14:20 ` Phil Yang
2020-04-26 19:30 ` Carrillo, Erik G
2020-04-26 14:45 ` [dpdk-dev] [PATCH v4] " Phil Yang
2020-04-26 20:06 ` Thomas Monjalon
2020-04-25 14:36 ` [dpdk-dev] [PATCH v2] " Thomas Monjalon
2020-04-25 15:51 ` Phil Yang
2020-04-25 16:07 ` Thomas Monjalon
2020-02-25 22:26 ` [dpdk-dev] [PATCH 1/2] lib/timer: protect timer subsystem initialized with lock Carrillo, Erik G
2020-04-25 17:21 ` [dpdk-dev] [dpdk-stable] " Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1582526539-14360-1-git-send-email-phil.yang@arm.com \
--to=phil.yang@arm.com \
--cc=Honnappa.Nagarahalli@arm.com \
--cc=anatoly.burakov@intel.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=erik.g.carrillo@intel.com \
--cc=gavin.hu@arm.com \
--cc=hemant.agrawal@nxp.com \
--cc=jerinj@marvell.com \
--cc=nd@arm.com \
--cc=rsanford@akamai.com \
--cc=stable@dpdk.org \
--cc=thomas@monjalon.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).