Show a patch.

GET /api/patches/73348/
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 73348,
    "url": "https://patches.dpdk.org/api/patches/73348/",
    "web_url": "https://patches.dpdk.org/patch/73348/",
    "project": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/projects/1/",
        "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"
    },
    "msgid": "<20200706205234.8040-10-david.marchand@redhat.com>",
    "date": "2020-07-06T20:52:33",
    "name": "[v6,09/10] mempool/bucket: handle non-EAL lcores",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "b3d63315aef99967aed8abc3f129bfc67164e24b",
    "submitter": {
        "id": 1173,
        "url": "https://patches.dpdk.org/api/people/1173/",
        "name": "David Marchand",
        "email": "david.marchand@redhat.com"
    },
    "delegate": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/users/1/",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "https://patches.dpdk.org/patch/73348/mbox/",
    "series": [
        {
            "id": 10826,
            "url": "https://patches.dpdk.org/api/series/10826/",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=10826",
            "date": "2020-07-06T20:52:25",
            "name": "Register non-EAL threads as lcore",
            "version": 6,
            "mbox": "https://patches.dpdk.org/series/10826/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/73348/comments/",
    "check": "fail",
    "checks": "https://patches.dpdk.org/api/patches/73348/checks/",
    "tags": {},
    "headers": {
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "Return-Path": "<dev-bounces@dpdk.org>",
        "To": "dev@dpdk.org",
        "X-MC-Unique": "CuXSzhAnPDqzUNYAPqq8ow-1",
        "Message-Id": "<20200706205234.8040-10-david.marchand@redhat.com>",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1594068821;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=QaD8q7zrJoaFhamg+6+Jx2/vdX4GSNTeXrQek1CdV3U=;\n b=cy/D/6sb9a/ITgRlDbo+MjMce6DcFRl7sl3UI+TyqquVlC04tjku02sjgWgsc4eSppPg/q\n PhuXzuh4WVVR+iz+aRvnv5cLnbYdct92s6GT1X5ZAqb9RPe0bMSVcxTiL0x4lEs/rx2fgJ\n IX5eZZNnmHIMMVgpAz95u2gTe2HtOlE=",
        "X-Scanned-By": "MIMEDefang 2.84 on 10.5.11.22",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "X-BeenThere": "dev@dpdk.org",
        "Received": [
            "from dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 9F242A00C5;\n\tMon,  6 Jul 2020 22:54:24 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id F19C41DD9E;\n\tMon,  6 Jul 2020 22:53:43 +0200 (CEST)",
            "from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com\n [205.139.110.61]) by dpdk.org (Postfix) with ESMTP id 442971DDD4\n for <dev@dpdk.org>; Mon,  6 Jul 2020 22:53:42 +0200 (CEST)",
            "from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com\n [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id\n us-mta-312-CuXSzhAnPDqzUNYAPqq8ow-1; Mon, 06 Jul 2020 16:53:37 -0400",
            "from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com\n [10.5.11.22])\n (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n (No client certificate requested)\n by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A057019057A0;\n Mon,  6 Jul 2020 20:53:35 +0000 (UTC)",
            "from dmarchan.remote.csb (unknown [10.40.195.188])\n by smtp.corp.redhat.com (Postfix) with ESMTP id 3D37D10013D7;\n Mon,  6 Jul 2020 20:53:31 +0000 (UTC)"
        ],
        "Subject": "[dpdk-dev] [PATCH v6 09/10] mempool/bucket: handle non-EAL lcores",
        "In-Reply-To": "<20200706205234.8040-1-david.marchand@redhat.com>",
        "Authentication-Results": "relay.mimecast.com;\n auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com",
        "X-Mimecast-Spam-Score": "0",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "Cc": "jerinjacobk@gmail.com, bruce.richardson@intel.com, mdr@ashroe.eu,\n thomas@monjalon.net, arybchenko@solarflare.com, ktraynor@redhat.com,\n ian.stokes@intel.com, i.maximets@ovn.org, olivier.matz@6wind.com,\n konstantin.ananyev@intel.com,\n \"Artem V. Andreev\" <artem.andreev@oktetlabs.ru>",
        "Precedence": "list",
        "From": "David Marchand <david.marchand@redhat.com>",
        "Content-Transfer-Encoding": "8bit",
        "MIME-Version": "1.0",
        "References": "<20200610144506.30505-1-david.marchand@redhat.com>\n <20200706205234.8040-1-david.marchand@redhat.com>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>",
        "Errors-To": "dev-bounces@dpdk.org",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "Content-Type": "text/plain; charset=US-ASCII",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Date": "Mon,  6 Jul 2020 22:52:33 +0200",
        "X-Mimecast-Originator": "redhat.com",
        "X-Mailman-Version": "2.1.15"
    },
    "content": "Convert to new lcore API to support non-EAL lcores.\n\nSigned-off-by: David Marchand <david.marchand@redhat.com>\nReviewed-by: Andrew Rybchenko <arybchenko@solarflare.com>\n---\nChanges since v3:\n- addressed Andrew comments,\n\n---\n drivers/mempool/bucket/rte_mempool_bucket.c | 130 ++++++++++++--------\n 1 file changed, 81 insertions(+), 49 deletions(-)",
    "diff": "diff --git a/drivers/mempool/bucket/rte_mempool_bucket.c b/drivers/mempool/bucket/rte_mempool_bucket.c\nindex 5ce1ef16fb..8b9daa9782 100644\n--- a/drivers/mempool/bucket/rte_mempool_bucket.c\n+++ b/drivers/mempool/bucket/rte_mempool_bucket.c\n@@ -55,6 +55,7 @@ struct bucket_data {\n \tstruct rte_ring *shared_orphan_ring;\n \tstruct rte_mempool *pool;\n \tunsigned int bucket_mem_size;\n+\tvoid *lcore_callback_handle;\n };\n \n static struct bucket_stack *\n@@ -345,6 +346,23 @@ bucket_dequeue_contig_blocks(struct rte_mempool *mp, void **first_obj_table,\n \treturn 0;\n }\n \n+struct bucket_count_per_lcore_ctx {\n+\tconst struct bucket_data *bd;\n+\tunsigned int count;\n+};\n+\n+static int\n+bucket_count_per_lcore(unsigned int lcore_id, void *arg)\n+{\n+\tstruct bucket_count_per_lcore_ctx *bplc = arg;\n+\n+\tbplc->count += bplc->bd->obj_per_bucket *\n+\t\tbplc->bd->buckets[lcore_id]->top;\n+\tbplc->count +=\n+\t\trte_ring_count(bplc->bd->adoption_buffer_rings[lcore_id]);\n+\treturn 0;\n+}\n+\n static void\n count_underfilled_buckets(struct rte_mempool *mp,\n \t\t\t  void *opaque,\n@@ -373,23 +391,64 @@ count_underfilled_buckets(struct rte_mempool *mp,\n static unsigned int\n bucket_get_count(const struct rte_mempool *mp)\n {\n-\tconst struct bucket_data *bd = mp->pool_data;\n-\tunsigned int count =\n-\t\tbd->obj_per_bucket * rte_ring_count(bd->shared_bucket_ring) +\n-\t\trte_ring_count(bd->shared_orphan_ring);\n-\tunsigned int i;\n+\tstruct bucket_count_per_lcore_ctx bplc;\n \n-\tfor (i = 0; i < RTE_MAX_LCORE; i++) {\n-\t\tif (!rte_lcore_is_enabled(i))\n-\t\t\tcontinue;\n-\t\tcount += bd->obj_per_bucket * bd->buckets[i]->top +\n-\t\t\trte_ring_count(bd->adoption_buffer_rings[i]);\n-\t}\n+\tbplc.bd = mp->pool_data;\n+\tbplc.count = bplc.bd->obj_per_bucket *\n+\t\trte_ring_count(bplc.bd->shared_bucket_ring);\n+\tbplc.count += rte_ring_count(bplc.bd->shared_orphan_ring);\n \n+\trte_lcore_iterate(bucket_count_per_lcore, &bplc);\n \trte_mempool_mem_iter((struct rte_mempool *)(uintptr_t)mp,\n-\t\t\t     count_underfilled_buckets, &count);\n+\t\t\t     count_underfilled_buckets, &bplc.count);\n+\n+\treturn bplc.count;\n+}\n+\n+static int\n+bucket_init_per_lcore(unsigned int lcore_id, void *arg)\n+{\n+\tchar rg_name[RTE_RING_NAMESIZE];\n+\tstruct bucket_data *bd = arg;\n+\tstruct rte_mempool *mp;\n+\tint rg_flags;\n+\tint rc;\n+\n+\tmp = bd->pool;\n+\tbd->buckets[lcore_id] = bucket_stack_create(mp,\n+\t\tmp->size / bd->obj_per_bucket);\n+\tif (bd->buckets[lcore_id] == NULL)\n+\t\tgoto error;\n+\n+\trc = snprintf(rg_name, sizeof(rg_name), RTE_MEMPOOL_MZ_FORMAT \".a%u\",\n+\t\tmp->name, lcore_id);\n+\tif (rc < 0 || rc >= (int)sizeof(rg_name))\n+\t\tgoto error;\n+\n+\trg_flags = RING_F_SC_DEQ;\n+\tif (mp->flags & MEMPOOL_F_SP_PUT)\n+\t\trg_flags |= RING_F_SP_ENQ;\n+\tbd->adoption_buffer_rings[lcore_id] = rte_ring_create(rg_name,\n+\t\trte_align32pow2(mp->size + 1), mp->socket_id, rg_flags);\n+\tif (bd->adoption_buffer_rings[lcore_id] == NULL)\n+\t\tgoto error;\n \n-\treturn count;\n+\treturn 0;\n+error:\n+\trte_free(bd->buckets[lcore_id]);\n+\tbd->buckets[lcore_id] = NULL;\n+\treturn -1;\n+}\n+\n+static void\n+bucket_uninit_per_lcore(unsigned int lcore_id, void *arg)\n+{\n+\tstruct bucket_data *bd = arg;\n+\n+\trte_ring_free(bd->adoption_buffer_rings[lcore_id]);\n+\tbd->adoption_buffer_rings[lcore_id] = NULL;\n+\trte_free(bd->buckets[lcore_id]);\n+\tbd->buckets[lcore_id] = NULL;\n }\n \n static int\n@@ -399,7 +458,6 @@ bucket_alloc(struct rte_mempool *mp)\n \tint rc = 0;\n \tchar rg_name[RTE_RING_NAMESIZE];\n \tstruct bucket_data *bd;\n-\tunsigned int i;\n \tunsigned int bucket_header_size;\n \tsize_t pg_sz;\n \n@@ -429,36 +487,17 @@ bucket_alloc(struct rte_mempool *mp)\n \t/* eventually this should be a tunable parameter */\n \tbd->bucket_stack_thresh = (mp->size / bd->obj_per_bucket) * 4 / 3;\n \n+\tbd->lcore_callback_handle = rte_lcore_callback_register(\"bucket\",\n+\t\tbucket_init_per_lcore, bucket_uninit_per_lcore, bd);\n+\tif (bd->lcore_callback_handle == NULL) {\n+\t\trc = -ENOMEM;\n+\t\tgoto no_mem_for_stacks;\n+\t}\n+\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-\tfor (i = 0; i < RTE_MAX_LCORE; i++) {\n-\t\tif (!rte_lcore_is_enabled(i))\n-\t\t\tcontinue;\n-\t\tbd->buckets[i] =\n-\t\t\tbucket_stack_create(mp, mp->size / bd->obj_per_bucket);\n-\t\tif (bd->buckets[i] == NULL) {\n-\t\t\trc = -ENOMEM;\n-\t\t\tgoto no_mem_for_stacks;\n-\t\t}\n-\t\trc = snprintf(rg_name, sizeof(rg_name),\n-\t\t\t      RTE_MEMPOOL_MZ_FORMAT \".a%u\", mp->name, i);\n-\t\tif (rc < 0 || rc >= (int)sizeof(rg_name)) {\n-\t\t\trc = -ENAMETOOLONG;\n-\t\t\tgoto no_mem_for_stacks;\n-\t\t}\n-\t\tbd->adoption_buffer_rings[i] =\n-\t\t\trte_ring_create(rg_name, rte_align32pow2(mp->size + 1),\n-\t\t\t\t\tmp->socket_id,\n-\t\t\t\t\trg_flags | RING_F_SC_DEQ);\n-\t\tif (bd->adoption_buffer_rings[i] == NULL) {\n-\t\t\trc = -rte_errno;\n-\t\t\tgoto no_mem_for_stacks;\n-\t\t}\n-\t}\n-\n \trc = snprintf(rg_name, sizeof(rg_name),\n \t\t      RTE_MEMPOOL_MZ_FORMAT \".0\", mp->name);\n \tif (rc < 0 || rc >= (int)sizeof(rg_name)) {\n@@ -498,11 +537,8 @@ bucket_alloc(struct rte_mempool *mp)\n \trte_ring_free(bd->shared_orphan_ring);\n cannot_create_shared_orphan_ring:\n invalid_shared_orphan_ring:\n+\trte_lcore_callback_unregister(bd->lcore_callback_handle);\n no_mem_for_stacks:\n-\tfor (i = 0; i < RTE_MAX_LCORE; i++) {\n-\t\trte_free(bd->buckets[i]);\n-\t\trte_ring_free(bd->adoption_buffer_rings[i]);\n-\t}\n \trte_free(bd);\n no_mem_for_data:\n \trte_errno = -rc;\n@@ -512,16 +548,12 @@ bucket_alloc(struct rte_mempool *mp)\n static void\n bucket_free(struct rte_mempool *mp)\n {\n-\tunsigned int i;\n \tstruct bucket_data *bd = mp->pool_data;\n \n \tif (bd == NULL)\n \t\treturn;\n \n-\tfor (i = 0; i < RTE_MAX_LCORE; i++) {\n-\t\trte_free(bd->buckets[i]);\n-\t\trte_ring_free(bd->adoption_buffer_rings[i]);\n-\t}\n+\trte_lcore_callback_unregister(bd->lcore_callback_handle);\n \n \trte_ring_free(bd->shared_orphan_ring);\n \trte_ring_free(bd->shared_bucket_ring);\n",
    "prefixes": [
        "v6",
        "09/10"
    ]
}