From: Anatoly Burakov <anatoly.burakov@intel.com>
To: dev@dpdk.org
Cc: erik.g.carrillo@intel.com
Subject: [dpdk-dev] [PATCH 1/2] eal: add internal locks for timer lib into EAL
Date: Tue, 25 Jun 2019 17:11:41 +0100 [thread overview]
Message-ID: <0743551eba840752223a6447ab4dcaf0731add39.1561478924.git.anatoly.burakov@intel.com> (raw)
In-Reply-To: <cover.1561478924.git.anatoly.burakov@intel.com>
In-Reply-To: <cover.1561478924.git.anatoly.burakov@intel.com>
Currently, timer library has a memory leak because there is no
way to concurrently initialize/deinitialize shared memory because
of race conditions [1].
Add a spinlock to the shared mem config to have a way to
exclusively initialize/deinitialize the timer library without
any races.
[1] See the following email thread:
https://mails.dpdk.org/archives/dev/2019-May/131498.html
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
lib/librte_eal/common/eal_common_mcfg.c | 14 ++++++++++++++
lib/librte_eal/common/eal_memcfg.h | 2 ++
.../common/include/rte_eal_memconfig.h | 18 ++++++++++++++++++
lib/librte_eal/rte_eal_version.map | 2 ++
4 files changed, 36 insertions(+)
diff --git a/lib/librte_eal/common/eal_common_mcfg.c b/lib/librte_eal/common/eal_common_mcfg.c
index 1825d9083..066549432 100644
--- a/lib/librte_eal/common/eal_common_mcfg.c
+++ b/lib/librte_eal/common/eal_common_mcfg.c
@@ -147,3 +147,17 @@ rte_mcfg_mempool_write_unlock(void)
struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
rte_rwlock_write_unlock(&mcfg->mplock);
}
+
+void
+rte_mcfg_timer_lock(void)
+{
+ struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+ rte_spinlock_lock(&mcfg->tlock);
+}
+
+void
+rte_mcfg_timer_unlock(void)
+{
+ struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+ rte_spinlock_unlock(&mcfg->tlock);
+}
diff --git a/lib/librte_eal/common/eal_memcfg.h b/lib/librte_eal/common/eal_memcfg.h
index e1aae32df..00370cece 100644
--- a/lib/librte_eal/common/eal_memcfg.h
+++ b/lib/librte_eal/common/eal_memcfg.h
@@ -11,6 +11,7 @@
#include <rte_memory.h>
#include <rte_memzone.h>
#include <rte_pause.h>
+#include <rte_spinlock.h>
#include <rte_rwlock.h>
#include <rte_tailq.h>
@@ -38,6 +39,7 @@ struct rte_mem_config {
rte_rwlock_t mlock; /**< only used by memzone LIB for thread-safe. */
rte_rwlock_t qlock; /**< used for tailq operation for thread safe. */
rte_rwlock_t mplock; /**< only used by mempool LIB for thread-safe. */
+ rte_spinlock_t tlock; /**< needed for timer lib thread safety. */
rte_rwlock_t memory_hotplug_lock;
/**< indicates whether memory hotplug request is in progress. */
diff --git a/lib/librte_eal/common/include/rte_eal_memconfig.h b/lib/librte_eal/common/include/rte_eal_memconfig.h
index 1b615c892..05a32e12a 100644
--- a/lib/librte_eal/common/include/rte_eal_memconfig.h
+++ b/lib/librte_eal/common/include/rte_eal_memconfig.h
@@ -109,6 +109,24 @@ rte_mcfg_mempool_write_lock(void);
void
rte_mcfg_mempool_write_unlock(void);
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Lock the internal EAL Timer Library lock for exclusive access.
+ */
+void __rte_experimental
+rte_mcfg_timer_lock(void);
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Unlock the internal EAL Timer Library lock for exclusive access.
+ */
+void __rte_experimental
+rte_mcfg_timer_unlock(void);
+
#ifdef __cplusplus
}
#endif
diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map
index c28951f65..bc08fc4df 100644
--- a/lib/librte_eal/rte_eal_version.map
+++ b/lib/librte_eal/rte_eal_version.map
@@ -367,6 +367,8 @@ EXPERIMENTAL {
rte_malloc_heap_memory_detach;
rte_malloc_heap_memory_remove;
rte_malloc_heap_socket_is_external;
+ rte_mcfg_timer_lock;
+ rte_mcfg_timer_unlock;
rte_mem_alloc_validator_register;
rte_mem_alloc_validator_unregister;
rte_mem_check_dma_mask;
--
2.17.1
next prev parent reply other threads:[~2019-06-25 16:11 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-01 19:00 [dpdk-dev] [PATCH] timer: fix resource leak in finalize Erik Gabriel Carrillo
2019-05-01 19:00 ` Erik Gabriel Carrillo
2019-05-02 9:18 ` Burakov, Anatoly
2019-05-02 9:18 ` Burakov, Anatoly
2019-05-02 12:19 ` Carrillo, Erik G
2019-05-02 12:19 ` Carrillo, Erik G
2019-05-02 13:03 ` Burakov, Anatoly
2019-05-02 13:03 ` Burakov, Anatoly
2019-05-02 13:48 ` Carrillo, Erik G
2019-05-02 13:48 ` Carrillo, Erik G
2019-05-03 22:54 ` [dpdk-dev] [PATCH v2] " Erik Gabriel Carrillo
2019-05-03 22:54 ` Erik Gabriel Carrillo
2019-05-07 11:03 ` Burakov, Anatoly
2019-05-07 11:03 ` Burakov, Anatoly
2019-05-07 22:04 ` Carrillo, Erik G
2019-05-07 22:04 ` Carrillo, Erik G
2019-05-08 8:49 ` Burakov, Anatoly
2019-05-08 8:49 ` Burakov, Anatoly
2019-05-08 23:01 ` Carrillo, Erik G
2019-05-08 23:01 ` Carrillo, Erik G
2019-05-09 7:44 ` Thomas Monjalon
2019-05-09 7:44 ` Thomas Monjalon
2019-05-08 22:35 ` [dpdk-dev] [PATCH v3] " Erik Gabriel Carrillo
2019-05-08 22:35 ` Erik Gabriel Carrillo
2019-05-09 8:29 ` Burakov, Anatoly
2019-05-09 8:29 ` Burakov, Anatoly
2019-06-05 9:33 ` Thomas Monjalon
2019-06-05 9:47 ` Burakov, Anatoly
2019-06-25 16:11 ` [dpdk-dev] [PATCH 0/2] Fix timer resource leak Anatoly Burakov
2019-07-05 13:20 ` [dpdk-dev] [PATCH v2 0/1] " Anatoly Burakov
2019-07-05 17:22 ` [dpdk-dev] [PATCH v3 " Anatoly Burakov
2019-07-05 17:22 ` [dpdk-dev] [PATCH v3 1/1] timer: fix resource leak in finalize Anatoly Burakov
2019-07-05 22:06 ` Thomas Monjalon
2019-07-05 13:20 ` [dpdk-dev] [PATCH v2 " Anatoly Burakov
2019-06-25 16:11 ` Anatoly Burakov [this message]
2019-06-27 18:41 ` [dpdk-dev] [PATCH 1/2] eal: add internal locks for timer lib into EAL Carrillo, Erik G
2019-07-04 9:09 ` David Marchand
2019-07-04 10:44 ` Burakov, Anatoly
2019-06-25 16:11 ` [dpdk-dev] [PATCH 2/2] timer: fix resource leak in finalize Anatoly Burakov
2019-06-27 18:48 ` Carrillo, Erik G
2019-07-04 9:10 ` David Marchand
2019-07-04 10:45 ` Burakov, Anatoly
2019-07-04 10:50 ` David Marchand
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=0743551eba840752223a6447ab4dcaf0731add39.1561478924.git.anatoly.burakov@intel.com \
--to=anatoly.burakov@intel.com \
--cc=dev@dpdk.org \
--cc=erik.g.carrillo@intel.com \
/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).