From: Anatoly Burakov <anatoly.burakov@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 04/10] rte_ring: make ring tailq fully local
Date: Fri, 20 Jun 2014 16:42:19 +0100 [thread overview]
Message-ID: <a53023e8c422e3a3a5578bf5adcc560c002c4c94.1403277437.git.anatoly.burakov@intel.com> (raw)
In-Reply-To: <cover.1403084449.git.anatoly.burakov@intel.com>
In-Reply-To: <cover.1403277437.git.anatoly.burakov@intel.com>
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
lib/librte_eal/linuxapp/eal/eal_ivshmem.c | 17 ++++++++++++++--
lib/librte_ring/Makefile | 4 ++--
lib/librte_ring/rte_ring.c | 33 +++++++++++++++++++++++--------
lib/librte_ring/rte_ring.h | 2 --
4 files changed, 42 insertions(+), 14 deletions(-)
diff --git a/lib/librte_eal/linuxapp/eal/eal_ivshmem.c b/lib/librte_eal/linuxapp/eal/eal_ivshmem.c
index 4ad76a7..fa5f4e3 100644
--- a/lib/librte_eal/linuxapp/eal/eal_ivshmem.c
+++ b/lib/librte_eal/linuxapp/eal/eal_ivshmem.c
@@ -50,6 +50,7 @@
#include <rte_errno.h>
#include <rte_ring.h>
#include <rte_mempool.h>
+#include <rte_malloc.h>
#include <rte_common.h>
#include <rte_ivshmem.h>
#include <rte_tailq_elem.h>
@@ -101,7 +102,7 @@ static int memseg_idx;
static int pagesz;
/* Tailq heads to add rings to */
-TAILQ_HEAD(rte_ring_list, rte_ring);
+TAILQ_HEAD(rte_ring_list, rte_tailq_entry);
/*
* Utility functions
@@ -754,6 +755,7 @@ rte_eal_ivshmem_obj_init(void)
struct ivshmem_segment * seg;
struct rte_memzone * mz;
struct rte_ring * r;
+ struct rte_tailq_entry *te;
unsigned i, ms, idx;
uint64_t offset;
@@ -808,6 +810,8 @@ rte_eal_ivshmem_obj_init(void)
mcfg->memzone_idx++;
}
+ rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+
/* find rings */
for (i = 0; i < mcfg->memzone_idx; i++) {
mz = &mcfg->memzone[i];
@@ -819,10 +823,19 @@ rte_eal_ivshmem_obj_init(void)
r = (struct rte_ring*) (mz->addr_64);
- TAILQ_INSERT_TAIL(ring_list, r, next);
+ te = rte_zmalloc("RING_TAILQ_ENTRY", sizeof(*te), 0);
+ if (te == NULL) {
+ RTE_LOG(ERR, EAL, "Cannot allocate ring tailq entry!\n");
+ return -1;
+ }
+
+ te->data = (void *) r;
+
+ TAILQ_INSERT_TAIL(ring_list, te, next);
RTE_LOG(DEBUG, EAL, "Found ring: '%s' at %p\n", r->name, mz->addr);
}
+ rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
#ifdef RTE_LIBRTE_IVSHMEM_DEBUG
rte_memzone_dump(stdout);
diff --git a/lib/librte_ring/Makefile b/lib/librte_ring/Makefile
index 550507d..2380a43 100644
--- a/lib/librte_ring/Makefile
+++ b/lib/librte_ring/Makefile
@@ -42,7 +42,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_RING) := rte_ring.c
# install includes
SYMLINK-$(CONFIG_RTE_LIBRTE_RING)-include := rte_ring.h
-# this lib needs eal
-DEPDIRS-$(CONFIG_RTE_LIBRTE_RING) += lib/librte_eal
+# this lib needs eal and rte_malloc
+DEPDIRS-$(CONFIG_RTE_LIBRTE_RING) += lib/librte_eal lib/librte_malloc
include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/lib/librte_ring/rte_ring.c b/lib/librte_ring/rte_ring.c
index 2fe4024..d2ff3fe 100644
--- a/lib/librte_ring/rte_ring.c
+++ b/lib/librte_ring/rte_ring.c
@@ -75,6 +75,7 @@
#include <rte_log.h>
#include <rte_memory.h>
#include <rte_memzone.h>
+#include <rte_malloc.h>
#include <rte_launch.h>
#include <rte_tailq.h>
#include <rte_eal.h>
@@ -89,7 +90,7 @@
#include "rte_ring.h"
-TAILQ_HEAD(rte_ring_list, rte_ring);
+TAILQ_HEAD(rte_ring_list, rte_tailq_entry);
/* true if x is a power of 2 */
#define POWEROF2(x) ((((x)-1) & (x)) == 0)
@@ -155,6 +156,7 @@ rte_ring_create(const char *name, unsigned count, int socket_id,
{
char mz_name[RTE_MEMZONE_NAMESIZE];
struct rte_ring *r;
+ struct rte_tailq_entry *te;
const struct rte_memzone *mz;
ssize_t ring_size;
int mz_flags = 0;
@@ -173,6 +175,13 @@ rte_ring_create(const char *name, unsigned count, int socket_id,
return NULL;
}
+ te = rte_zmalloc("RING_TAILQ_ENTRY", sizeof(*te), 0);
+ if (te == NULL) {
+ RTE_LOG(ERR, RING, "Cannot reserve memory for tailq\n");
+ rte_errno = ENOMEM;
+ return NULL;
+ }
+
rte_snprintf(mz_name, sizeof(mz_name), "%s%s", RTE_RING_MZ_PREFIX, name);
rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
@@ -186,10 +195,14 @@ rte_ring_create(const char *name, unsigned count, int socket_id,
/* no need to check return value here, we already checked the
* arguments above */
rte_ring_init(r, name, count, flags);
- TAILQ_INSERT_TAIL(ring_list, r, next);
+
+ te->data = (void *) r;
+
+ TAILQ_INSERT_TAIL(ring_list, te, next);
} else {
r = NULL;
RTE_LOG(ERR, RING, "Cannot reserve memory\n");
+ rte_free(te);
}
rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
@@ -272,7 +285,7 @@ rte_ring_dump(FILE *f, const struct rte_ring *r)
void
rte_ring_list_dump(FILE *f)
{
- const struct rte_ring *mp;
+ const struct rte_tailq_entry *te;
struct rte_ring_list *ring_list;
/* check that we have an initialised tail queue */
@@ -284,8 +297,8 @@ rte_ring_list_dump(FILE *f)
rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
- TAILQ_FOREACH(mp, ring_list, next) {
- rte_ring_dump(f, mp);
+ TAILQ_FOREACH(te, ring_list, next) {
+ rte_ring_dump(f, (struct rte_ring *) te->data);
}
rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
@@ -295,7 +308,8 @@ rte_ring_list_dump(FILE *f)
struct rte_ring *
rte_ring_lookup(const char *name)
{
- struct rte_ring *r;
+ struct rte_tailq_entry *te;
+ struct rte_ring *r = NULL;
struct rte_ring_list *ring_list;
/* check that we have an initialized tail queue */
@@ -307,15 +321,18 @@ rte_ring_lookup(const char *name)
rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
- TAILQ_FOREACH(r, ring_list, next) {
+ TAILQ_FOREACH(te, ring_list, next) {
+ r = (struct rte_ring *) te->data;
if (strncmp(name, r->name, RTE_RING_NAMESIZE) == 0)
break;
}
rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
- if (r == NULL)
+ if (te == NULL) {
rte_errno = ENOENT;
+ return NULL;
+ }
return r;
}
diff --git a/lib/librte_ring/rte_ring.h b/lib/librte_ring/rte_ring.h
index 4f3e20f..3920830 100644
--- a/lib/librte_ring/rte_ring.h
+++ b/lib/librte_ring/rte_ring.h
@@ -138,8 +138,6 @@ struct rte_ring_debug_stats {
* a problem.
*/
struct rte_ring {
- TAILQ_ENTRY(rte_ring) next; /**< Next in list. */
-
char name[RTE_RING_NAMESIZE]; /**< Name of the ring. */
int flags; /**< Flags supplied at creation. */
--
1.8.1.4
next prev parent reply other threads:[~2014-06-20 15:42 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-13 15:29 [dpdk-dev] [PATCH 0/7] Make DPDK tailqs " Anatoly Burakov
2014-06-13 15:29 ` [dpdk-dev] [PATCH 1/7] rte_tailq: change rte_dummy to rte_tailq_entry, add data pointer Anatoly Burakov
2014-06-13 15:29 ` [dpdk-dev] [PATCH 2/7] rte_ring: make ring tailq completely local Anatoly Burakov
2014-06-13 15:29 ` [dpdk-dev] [PATCH 3/7] rte_hash: make rte_hash tailq fully local Anatoly Burakov
2014-06-13 15:29 ` [dpdk-dev] [PATCH 4/7] rte_fbk_hash: make rte_fbk_hash " Anatoly Burakov
2014-06-13 15:29 ` [dpdk-dev] [PATCH 5/7] rte_mempool: make mempool " Anatoly Burakov
2014-06-13 15:29 ` [dpdk-dev] [PATCH 6/7] rte_lpm: make lpm " Anatoly Burakov
2014-06-13 15:29 ` [dpdk-dev] [PATCH 7/7] rte_lpm6: make lpm6 " Anatoly Burakov
2014-06-17 9:57 ` [dpdk-dev] [PATCH 0/7] Make DPDK tailqs " Burakov, Anatoly
2014-06-17 15:35 ` [dpdk-dev] [PATCH 0/9] " Anatoly Burakov
2014-06-17 15:35 ` [dpdk-dev] [PATCH 1/9] eal: map shared config into exact same address as primary process Anatoly Burakov
2014-06-17 16:29 ` Ananyev, Konstantin
2014-06-18 9:25 ` Burakov, Anatoly
2014-06-17 15:36 ` [dpdk-dev] [PATCH 2/9] rte_tailq: change rte_dummy to rte_tailq_entry, add data pointer Anatoly Burakov
2014-06-17 15:36 ` [dpdk-dev] [PATCH 3/9] rte_ring: make ring tailq fully local Anatoly Burakov
2014-06-17 15:36 ` [dpdk-dev] [PATCH 4/9] rte_hash: make rte_hash " Anatoly Burakov
2014-06-17 15:36 ` [dpdk-dev] [PATCH 5/9] rte_fbk_hash: make rte_fbk_hash " Anatoly Burakov
2014-06-17 15:36 ` [dpdk-dev] [PATCH 6/9] rte_mempool: make mempool " Anatoly Burakov
2014-06-17 15:36 ` [dpdk-dev] [PATCH 7/9] rte_lpm: make lpm " Anatoly Burakov
2014-06-17 15:36 ` [dpdk-dev] [PATCH 8/9] rte_lpm6: make lpm6 " Anatoly Burakov
2014-06-17 15:36 ` [dpdk-dev] [PATCH 9/9] rte_acl: make acl " Anatoly Burakov
2014-06-18 11:27 ` [dpdk-dev] [PATCH v3 0/9] Make DPDK tailqs " Anatoly Burakov
2014-06-18 11:27 ` [dpdk-dev] [PATCH v3 1/9] eal: map shared config into exact same address as primary process Anatoly Burakov
2014-06-18 11:27 ` [dpdk-dev] [PATCH v3 2/9] rte_tailq: change rte_dummy to rte_tailq_entry, add data pointer Anatoly Burakov
2014-06-18 11:27 ` [dpdk-dev] [PATCH v3 3/9] rte_ring: make ring tailq fully local Anatoly Burakov
2014-06-18 11:27 ` [dpdk-dev] [PATCH v3 4/9] rte_hash: make rte_hash " Anatoly Burakov
2014-06-18 11:27 ` [dpdk-dev] [PATCH v3 5/9] rte_fbk_hash: make rte_fbk_hash " Anatoly Burakov
2014-06-18 11:27 ` [dpdk-dev] [PATCH v3 6/9] rte_mempool: make mempool " Anatoly Burakov
2014-06-18 11:27 ` [dpdk-dev] [PATCH v3 7/9] rte_lpm: make lpm " Anatoly Burakov
2014-06-18 11:27 ` [dpdk-dev] [PATCH v3 8/9] rte_lpm6: make lpm6 " Anatoly Burakov
2014-06-18 11:27 ` [dpdk-dev] [PATCH v3 9/9] rte_acl: make acl " Anatoly Burakov
2014-06-18 14:21 ` [dpdk-dev] [PATCH v3 0/9] Make DPDK tailqs " Ananyev, Konstantin
2014-06-20 15:42 ` [dpdk-dev] [PATCH 00/10] " Anatoly Burakov
2014-06-20 15:42 ` [dpdk-dev] [PATCH 01/10] eal: map shared config into exact same address as primary process Anatoly Burakov
2014-06-20 15:42 ` [dpdk-dev] [PATCH 02/10] eal: use --base-virtaddr for mapping rte_config as well Anatoly Burakov
2014-06-20 15:42 ` [dpdk-dev] [PATCH 03/10] rte_tailq: change rte_dummy to rte_tailq_entry, add data pointer Anatoly Burakov
2014-06-20 15:42 ` Anatoly Burakov [this message]
2014-06-20 15:42 ` [dpdk-dev] [PATCH 05/10] rte_hash: make rte_hash tailq fully local Anatoly Burakov
2014-06-20 15:42 ` [dpdk-dev] [PATCH 06/10] rte_fbk_hash: make rte_fbk_hash " Anatoly Burakov
2014-06-20 15:42 ` [dpdk-dev] [PATCH 07/10] rte_mempool: make mempool " Anatoly Burakov
2014-06-20 15:42 ` [dpdk-dev] [PATCH 08/10] rte_lpm: make lpm " Anatoly Burakov
2014-06-20 15:42 ` [dpdk-dev] [PATCH 09/10] rte_lpm6: make lpm6 " Anatoly Burakov
2014-06-20 15:42 ` [dpdk-dev] [PATCH 10/10] rte_acl: make acl " Anatoly Burakov
2014-07-22 22:12 ` [dpdk-dev] [PATCH 00/10] Make DPDK tailqs " 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=a53023e8c422e3a3a5578bf5adcc560c002c4c94.1403277437.git.anatoly.burakov@intel.com \
--to=anatoly.burakov@intel.com \
--cc=dev@dpdk.org \
/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).