get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 69787,
    "url": "https://patches.dpdk.org/api/patches/69787/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20200505211732.25291-6-honnappa.nagarahalli@arm.com/",
    "project": {
        "id": 1,
        "url": "https://patches.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": "<20200505211732.25291-6-honnappa.nagarahalli@arm.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20200505211732.25291-6-honnappa.nagarahalli@arm.com",
    "date": "2020-05-05T21:17:31",
    "name": "[v4,5/6] service: optimize with c11 atomics",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "8babf250077e46fc971234b2566ff36f91b32abe",
    "submitter": {
        "id": 1045,
        "url": "https://patches.dpdk.org/api/people/1045/?format=api",
        "name": "Honnappa Nagarahalli",
        "email": "honnappa.nagarahalli@arm.com"
    },
    "delegate": {
        "id": 24651,
        "url": "https://patches.dpdk.org/api/users/24651/?format=api",
        "username": "dmarchand",
        "first_name": "David",
        "last_name": "Marchand",
        "email": "david.marchand@redhat.com"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20200505211732.25291-6-honnappa.nagarahalli@arm.com/mbox/",
    "series": [
        {
            "id": 9845,
            "url": "https://patches.dpdk.org/api/series/9845/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=9845",
            "date": "2020-05-05T21:17:26",
            "name": "use c11 atomics for service core lib",
            "version": 4,
            "mbox": "https://patches.dpdk.org/series/9845/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/69787/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/69787/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id D1C25A0352;\n\tTue,  5 May 2020 23:18:30 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 8FD9A1D703;\n\tTue,  5 May 2020 23:17:57 +0200 (CEST)",
            "from foss.arm.com (foss.arm.com [217.140.110.172])\n by dpdk.org (Postfix) with ESMTP id 0C59A1D6F6\n for <dev@dpdk.org>; Tue,  5 May 2020 23:17:56 +0200 (CEST)",
            "from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])\n by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 87C5E31B;\n Tue,  5 May 2020 14:17:55 -0700 (PDT)",
            "from qc2400f-1.austin.arm.com (qc2400f-1.austin.arm.com\n [10.118.14.48])\n by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 723CF3F305;\n Tue,  5 May 2020 14:17:55 -0700 (PDT)"
        ],
        "From": "Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>",
        "To": "dev@dpdk.org,\n\tphil.yang@arm.com,\n\tharry.van.haaren@intel.com",
        "Cc": "thomas@monjalon.net, david.marchand@redhat.com,\n konstantin.ananyev@intel.com, jerinj@marvell.com, hemant.agrawal@nxp.com,\n gage.eads@intel.com, bruce.richardson@intel.com,\n honnappa.nagarahalli@arm.com, nd@arm.com",
        "Date": "Tue,  5 May 2020 16:17:31 -0500",
        "Message-Id": "<20200505211732.25291-6-honnappa.nagarahalli@arm.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20200505211732.25291-1-honnappa.nagarahalli@arm.com>",
        "References": "<1587659482-27133-1-git-send-email-phil.yang@arm.com>\n <20200505211732.25291-1-honnappa.nagarahalli@arm.com>",
        "Subject": "[dpdk-dev] [PATCH v4 5/6] service: optimize with c11 atomics",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "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-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "From: Phil Yang <phil.yang@arm.com>\n\nThe num_mapped_cores is used as a statistics. Use c11 atomics with\nRELAXED ordering for num_mapped_cores instead of rte_atomic ops which\nenforce unnessary barriers on aarch64.\n\nReplace execute_lock operations to spinlock_try_lock to avoid duplicate\ncode.\n\nSigned-off-by: Phil Yang <phil.yang@arm.com>\nReviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>\nAcked-by: Harry van Haaren <harry.van.haaren@intel.com>\n---\n lib/librte_eal/common/rte_service.c | 32 ++++++++++++++++-------------\n lib/librte_eal/meson.build          |  4 ++++\n 2 files changed, 22 insertions(+), 14 deletions(-)",
    "diff": "diff --git a/lib/librte_eal/common/rte_service.c b/lib/librte_eal/common/rte_service.c\nindex 37c16c4bc..5d35f8a8d 100644\n--- a/lib/librte_eal/common/rte_service.c\n+++ b/lib/librte_eal/common/rte_service.c\n@@ -20,6 +20,7 @@\n #include <rte_atomic.h>\n #include <rte_memory.h>\n #include <rte_malloc.h>\n+#include <rte_spinlock.h>\n \n #include \"eal_private.h\"\n \n@@ -38,11 +39,11 @@ struct rte_service_spec_impl {\n \t/* public part of the struct */\n \tstruct rte_service_spec spec;\n \n-\t/* atomic lock that when set indicates a service core is currently\n+\t/* spin lock that when set indicates a service core is currently\n \t * running this service callback. When not set, a core may take the\n \t * lock and then run the service callback.\n \t */\n-\trte_atomic32_t execute_lock;\n+\trte_spinlock_t execute_lock;\n \n \t/* API set/get-able variables */\n \tint8_t app_runstate;\n@@ -54,7 +55,7 @@ struct rte_service_spec_impl {\n \t * It does not indicate the number of cores the service is running\n \t * on currently.\n \t */\n-\trte_atomic32_t num_mapped_cores;\n+\tuint32_t num_mapped_cores;\n \tuint64_t calls;\n \tuint64_t cycles_spent;\n } __rte_cache_aligned;\n@@ -332,7 +333,8 @@ rte_service_runstate_get(uint32_t id)\n \trte_smp_rmb();\n \n \tint check_disabled = !(s->internal_flags & SERVICE_F_START_CHECK);\n-\tint lcore_mapped = (rte_atomic32_read(&s->num_mapped_cores) > 0);\n+\tint lcore_mapped = (__atomic_load_n(&s->num_mapped_cores,\n+\t\t\t\t\t    __ATOMIC_RELAXED) > 0);\n \n \treturn (s->app_runstate == RUNSTATE_RUNNING) &&\n \t\t(s->comp_runstate == RUNSTATE_RUNNING) &&\n@@ -375,11 +377,11 @@ service_run(uint32_t i, struct core_state *cs, uint64_t service_mask,\n \tcs->service_active_on_lcore[i] = 1;\n \n \tif ((service_mt_safe(s) == 0) && (serialize_mt_unsafe == 1)) {\n-\t\tif (!rte_atomic32_cmpset((uint32_t *)&s->execute_lock, 0, 1))\n+\t\tif (!rte_spinlock_trylock(&s->execute_lock))\n \t\t\treturn -EBUSY;\n \n \t\tservice_runner_do_callback(s, cs, i);\n-\t\trte_atomic32_clear(&s->execute_lock);\n+\t\trte_spinlock_unlock(&s->execute_lock);\n \t} else\n \t\tservice_runner_do_callback(s, cs, i);\n \n@@ -415,11 +417,11 @@ rte_service_run_iter_on_app_lcore(uint32_t id, uint32_t serialize_mt_unsafe)\n \t/* Increment num_mapped_cores to reflect that this core is\n \t * now mapped capable of running the service.\n \t */\n-\trte_atomic32_inc(&s->num_mapped_cores);\n+\t__atomic_add_fetch(&s->num_mapped_cores, 1, __ATOMIC_RELAXED);\n \n \tint ret = service_run(id, cs, UINT64_MAX, s, serialize_mt_unsafe);\n \n-\trte_atomic32_dec(&s->num_mapped_cores);\n+\t__atomic_sub_fetch(&s->num_mapped_cores, 1, __ATOMIC_RELAXED);\n \n \treturn ret;\n }\n@@ -556,19 +558,19 @@ service_update(uint32_t sid, uint32_t lcore,\n \n \t\tif (*set && !lcore_mapped) {\n \t\t\tlcore_states[lcore].service_mask |= sid_mask;\n-\t\t\trte_atomic32_inc(&rte_services[sid].num_mapped_cores);\n+\t\t\t__atomic_add_fetch(&rte_services[sid].num_mapped_cores,\n+\t\t\t\t\t    1, __ATOMIC_RELAXED);\n \t\t}\n \t\tif (!*set && lcore_mapped) {\n \t\t\tlcore_states[lcore].service_mask &= ~(sid_mask);\n-\t\t\trte_atomic32_dec(&rte_services[sid].num_mapped_cores);\n+\t\t\t__atomic_sub_fetch(&rte_services[sid].num_mapped_cores,\n+\t\t\t\t\t    1, __ATOMIC_RELAXED);\n \t\t}\n \t}\n \n \tif (enabled)\n \t\t*enabled = !!(lcore_states[lcore].service_mask & (sid_mask));\n \n-\trte_smp_wmb();\n-\n \treturn 0;\n }\n \n@@ -616,7 +618,8 @@ rte_service_lcore_reset_all(void)\n \t\t}\n \t}\n \tfor (i = 0; i < RTE_SERVICE_NUM_MAX; i++)\n-\t\trte_atomic32_set(&rte_services[i].num_mapped_cores, 0);\n+\t\t__atomic_store_n(&rte_services[i].num_mapped_cores, 0,\n+\t\t\t\t    __ATOMIC_RELAXED);\n \n \trte_smp_wmb();\n \n@@ -699,7 +702,8 @@ rte_service_lcore_stop(uint32_t lcore)\n \t\tint32_t enabled = service_mask & (UINT64_C(1) << i);\n \t\tint32_t service_running = rte_service_runstate_get(i);\n \t\tint32_t only_core = (1 ==\n-\t\t\trte_atomic32_read(&rte_services[i].num_mapped_cores));\n+\t\t\t__atomic_load_n(&rte_services[i].num_mapped_cores,\n+\t\t\t\t\t__ATOMIC_RELAXED));\n \n \t\t/* if the core is mapped, and the service is running, and this\n \t\t * is the only core that is mapped, the service would cease to\ndiff --git a/lib/librte_eal/meson.build b/lib/librte_eal/meson.build\nindex 0267c3b9d..c2d7a6954 100644\n--- a/lib/librte_eal/meson.build\n+++ b/lib/librte_eal/meson.build\n@@ -21,3 +21,7 @@ endif\n if cc.has_header('getopt.h')\n \tcflags += ['-DHAVE_GETOPT_H', '-DHAVE_GETOPT', '-DHAVE_GETOPT_LONG']\n endif\n+# for clang 32-bit compiles we need libatomic for 64-bit atomic ops\n+if cc.get_id() == 'clang' and dpdk_conf.get('RTE_ARCH_64') == false\n+    ext_deps += cc.find_library('atomic')\n+endif\n",
    "prefixes": [
        "v4",
        "5/6"
    ]
}