Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/11306/?format=api
http://patchwork.dpdk.org/api/patches/11306/?format=api", "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/1457540381-20274-14-git-send-email-olivier.matz@6wind.com/", "project": { "id": 1, "url": "http://patchwork.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<1457540381-20274-14-git-send-email-olivier.matz@6wind.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1457540381-20274-14-git-send-email-olivier.matz@6wind.com", "date": "2016-03-09T16:19:19", "name": "[dpdk-dev,RFC,13/35] mempool: create the internal ring in a specific function", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "ce5d66441cb0f8ed843c42559ebdd421ce790cf8", "submitter": { "id": 8, "url": "http://patchwork.dpdk.org/api/people/8/?format=api", "name": "Olivier Matz", "email": "olivier.matz@6wind.com" }, "delegate": null, "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/1457540381-20274-14-git-send-email-olivier.matz@6wind.com/mbox/", "series": [], "comments": "http://patchwork.dpdk.org/api/patches/11306/comments/", "check": "pending", "checks": "http://patchwork.dpdk.org/api/patches/11306/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@dpdk.org", "Delivered-To": "patchwork@dpdk.org", "Received": [ "from [92.243.14.124] (localhost [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id BA2835597;\n\tWed, 9 Mar 2016 17:22:29 +0100 (CET)", "from proxy.6wind.com (host.76.145.23.62.rev.coltfrance.com\n\t[62.23.145.76]) by dpdk.org (Postfix) with ESMTP id EC03437B2\n\tfor <dev@dpdk.org>; Wed, 9 Mar 2016 17:22:14 +0100 (CET)", "from glumotte.dev.6wind.com (unknown [10.16.0.195])\n\tby proxy.6wind.com (Postfix) with ESMTP id E4BFA249A0\n\tfor <dev@dpdk.org>; Wed, 9 Mar 2016 17:21:31 +0100 (CET)" ], "From": "Olivier Matz <olivier.matz@6wind.com>", "To": "dev@dpdk.org", "Date": "Wed, 9 Mar 2016 17:19:19 +0100", "Message-Id": "<1457540381-20274-14-git-send-email-olivier.matz@6wind.com>", "X-Mailer": "git-send-email 2.1.4", "In-Reply-To": "<1457540381-20274-1-git-send-email-olivier.matz@6wind.com>", "References": "<1457540381-20274-1-git-send-email-olivier.matz@6wind.com>", "Subject": "[dpdk-dev] [RFC 13/35] mempool: create the internal ring in a\n\tspecific function", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "patches and discussions about DPDK <dev.dpdk.org>", "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://dpdk.org/ml/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "This makes the code of rte_mempool_create() clearer, and it will make\nthe introduction of external mempool handler easier (in another patch\nseries). Indeed, this function contains the specific part when a ring is\nused, but it could be replaced by something else in the future.\n\nThis commit also adds a socket_id field in the mempool structure that\nis used by this new function.\n\nSigned-off-by: Olivier Matz <olivier.matz@6wind.com>\n---\n lib/librte_mempool/rte_mempool.c | 55 +++++++++++++++++++++++++---------------\n lib/librte_mempool/rte_mempool.h | 1 +\n 2 files changed, 36 insertions(+), 20 deletions(-)", "diff": "diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c\nindex 4145e2e..d533484 100644\n--- a/lib/librte_mempool/rte_mempool.c\n+++ b/lib/librte_mempool/rte_mempool.c\n@@ -431,6 +431,35 @@ rte_mempool_create(const char *name, unsigned n, unsigned elt_size,\n \t\t\t\t\t MEMPOOL_PG_SHIFT_MAX);\n }\n \n+/* create the internal ring */\n+static int\n+rte_mempool_ring_create(struct rte_mempool *mp)\n+{\n+\tint rg_flags = 0;\n+\tchar rg_name[RTE_RING_NAMESIZE];\n+\tstruct rte_ring *r;\n+\n+\tsnprintf(rg_name, sizeof(rg_name), RTE_MEMPOOL_MZ_FORMAT, mp->name);\n+\n+\t/* ring flags */\n+\tif (mp->flags & MEMPOOL_F_SP_PUT)\n+\t\trg_flags |= RING_F_SP_ENQ;\n+\tif (mp->flags & MEMPOOL_F_SC_GET)\n+\t\trg_flags |= RING_F_SC_DEQ;\n+\n+\t/* Allocate the ring that will be used to store objects.\n+\t * Ring functions will return appropriate errors if we are\n+\t * running as a secondary process etc., so no checks made\n+\t * in this function for that condition. */\n+\tr = rte_ring_create(rg_name, rte_align32pow2(mp->size + 1),\n+\t\tmp->socket_id, rg_flags);\n+\tif (r == NULL)\n+\t\treturn -rte_errno;\n+\n+\tmp->ring = r;\n+\treturn 0;\n+}\n+\n /*\n * Create the mempool over already allocated chunk of memory.\n * That external memory buffer can consists of physically disjoint pages.\n@@ -447,15 +476,12 @@ rte_mempool_xmem_create(const char *name, unsigned n, unsigned elt_size,\n \t\tconst phys_addr_t paddr[], uint32_t pg_num, uint32_t pg_shift)\n {\n \tchar mz_name[RTE_MEMZONE_NAMESIZE];\n-\tchar rg_name[RTE_RING_NAMESIZE];\n \tstruct rte_mempool_list *mempool_list;\n \tstruct rte_mempool *mp = NULL;\n \tstruct rte_tailq_entry *te = NULL;\n-\tstruct rte_ring *r = NULL;\n \tconst struct rte_memzone *mz;\n \tsize_t mempool_size;\n \tint mz_flags = RTE_MEMZONE_1GB|RTE_MEMZONE_SIZE_HINT_ONLY;\n-\tint rg_flags = 0;\n \tvoid *obj;\n \tstruct rte_mempool_objsz objsz;\n \tvoid *startaddr;\n@@ -498,12 +524,6 @@ rte_mempool_xmem_create(const char *name, unsigned n, unsigned elt_size,\n \tif (flags & MEMPOOL_F_NO_CACHE_ALIGN)\n \t\tflags |= MEMPOOL_F_NO_SPREAD;\n \n-\t/* ring flags */\n-\tif (flags & MEMPOOL_F_SP_PUT)\n-\t\trg_flags |= RING_F_SP_ENQ;\n-\tif (flags & MEMPOOL_F_SC_GET)\n-\t\trg_flags |= RING_F_SC_DEQ;\n-\n \t/* calculate mempool object sizes. */\n \tif (!rte_mempool_calc_obj_size(elt_size, flags, &objsz)) {\n \t\trte_errno = EINVAL;\n@@ -512,15 +532,6 @@ rte_mempool_xmem_create(const char *name, unsigned n, unsigned elt_size,\n \n \trte_rwlock_write_lock(RTE_EAL_MEMPOOL_RWLOCK);\n \n-\t/* allocate the ring that will be used to store objects */\n-\t/* Ring functions will return appropriate errors if we are\n-\t * running as a secondary process etc., so no checks made\n-\t * in this function for that condition */\n-\tsnprintf(rg_name, sizeof(rg_name), RTE_MEMPOOL_MZ_FORMAT, name);\n-\tr = rte_ring_create(rg_name, rte_align32pow2(n+1), socket_id, rg_flags);\n-\tif (r == NULL)\n-\t\tgoto exit_unlock;\n-\n \t/*\n \t * reserve a memory zone for this mempool: private data is\n \t * cache-aligned\n@@ -589,7 +600,7 @@ rte_mempool_xmem_create(const char *name, unsigned n, unsigned elt_size,\n \tmemset(mp, 0, sizeof(*mp));\n \tsnprintf(mp->name, sizeof(mp->name), \"%s\", name);\n \tmp->phys_addr = mz->phys_addr;\n-\tmp->ring = r;\n+\tmp->socket_id = socket_id;\n \tmp->size = n;\n \tmp->flags = flags;\n \tmp->elt_size = objsz.elt_size;\n@@ -600,6 +611,9 @@ rte_mempool_xmem_create(const char *name, unsigned n, unsigned elt_size,\n \tmp->private_data_size = private_data_size;\n \tSTAILQ_INIT(&mp->elt_list);\n \n+\tif (rte_mempool_ring_create(mp) < 0)\n+\t\tgoto exit_unlock;\n+\n \t/*\n \t * local_cache pointer is set even if cache_size is zero.\n \t * The local_cache points to just past the elt_pa[] array.\n@@ -651,7 +665,8 @@ rte_mempool_xmem_create(const char *name, unsigned n, unsigned elt_size,\n \n exit_unlock:\n \trte_rwlock_write_unlock(RTE_EAL_MEMPOOL_RWLOCK);\n-\trte_ring_free(r);\n+\tif (mp != NULL)\n+\t\trte_ring_free(mp->ring);\n \trte_free(te);\n \n \treturn NULL;\ndiff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h\nindex ca37120..5b760f0 100644\n--- a/lib/librte_mempool/rte_mempool.h\n+++ b/lib/librte_mempool/rte_mempool.h\n@@ -188,6 +188,7 @@ struct rte_mempool {\n \tstruct rte_ring *ring; /**< Ring to store objects. */\n \tphys_addr_t phys_addr; /**< Phys. addr. of mempool struct. */\n \tint flags; /**< Flags of the mempool. */\n+\tint socket_id; /**< Socket id passed at mempool creation. */\n \tuint32_t size; /**< Size of the mempool. */\n \tuint32_t cache_size; /**< Size of per-lcore local cache. */\n \tuint32_t cache_flushthresh;\n", "prefixes": [ "dpdk-dev", "RFC", "13/35" ] }{ "id": 11306, "url": "