get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 41141,
    "url": "https://patches.dpdk.org/api/patches/41141/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20180614135130.30849-2-gage.eads@intel.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": "<20180614135130.30849-2-gage.eads@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20180614135130.30849-2-gage.eads@intel.com",
    "date": "2018-06-14T13:51:29",
    "name": "[v2,1/2] service: add mechanism for quiescing a service",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "a95a73837d9ad422d3e787f59d6e3cde24dd339d",
    "submitter": {
        "id": 586,
        "url": "https://patches.dpdk.org/api/people/586/?format=api",
        "name": "Eads, Gage",
        "email": "gage.eads@intel.com"
    },
    "delegate": {
        "id": 310,
        "url": "https://patches.dpdk.org/api/users/310/?format=api",
        "username": "jerin",
        "first_name": "Jerin",
        "last_name": "Jacob",
        "email": "jerinj@marvell.com"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20180614135130.30849-2-gage.eads@intel.com/mbox/",
    "series": [
        {
            "id": 129,
            "url": "https://patches.dpdk.org/api/series/129/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=129",
            "date": "2018-06-14T13:51:28",
            "name": "Improve service stop support",
            "version": 2,
            "mbox": "https://patches.dpdk.org/series/129/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/41141/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/41141/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 [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 509F61DFFF;\n\tThu, 14 Jun 2018 15:51:56 +0200 (CEST)",
            "from mga04.intel.com (mga04.intel.com [192.55.52.120])\n\tby dpdk.org (Postfix) with ESMTP id D79BE1DFF7\n\tfor <dev@dpdk.org>; Thu, 14 Jun 2018 15:51:53 +0200 (CEST)",
            "from orsmga005.jf.intel.com ([10.7.209.41])\n\tby fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t14 Jun 2018 06:51:53 -0700",
            "from txasoft-yocto.an.intel.com ([10.123.72.192])\n\tby orsmga005.jf.intel.com with ESMTP; 14 Jun 2018 06:51:52 -0700"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.51,222,1526367600\"; d=\"scan'208\";a=\"232574702\"",
        "From": "Gage Eads <gage.eads@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "jerin.jacob@caviumnetworks.com, harry.van.haaren@intel.com,\n\tbruce.richardson@intel.com, nikhil.rao@intel.com,\n\terik.g.carrillo@intel.com, abhinandan.gujjar@intel.com",
        "Date": "Thu, 14 Jun 2018 08:51:29 -0500",
        "Message-Id": "<20180614135130.30849-2-gage.eads@intel.com>",
        "X-Mailer": "git-send-email 2.13.6",
        "In-Reply-To": "<20180614135130.30849-1-gage.eads@intel.com>",
        "References": "<20180531135557.7544-1-gage.eads@intel.com>\n\t<20180614135130.30849-1-gage.eads@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v2 1/2] service: add mechanism for quiescing a\n\tservice",
        "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://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": "<https://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": "Existing service functions allow us to stop a service, but doing so doesn't\nguarantee that the service has finished running on a service core. This\ncommit introduces rte_service_may_be_active(), which returns whether the\nservice may be executing on one or more lcores currently, or definitely is\nnot.\n\nThe service core layer supports this function by setting a flag when\na service core is going to execute a service, and unsetting the flag when\nthe core is no longer able to run the service (its runstate becomes stopped\nor the lcore is no longer mapped).\n\nWith this new function, applications can set a service's runstate to\nstopped, then poll rte_service_may_be_active() until it returns false. At\nthat point, the service is quiesced.\n\nSigned-off-by: Gage Eads <gage.eads@intel.com>\nAcked-by: Harry van Haaren <harry.van.haaren@intel.com>\n---\n lib/librte_eal/common/include/rte_service.h | 16 +++++++++++\n lib/librte_eal/common/rte_service.c         | 31 ++++++++++++++++++---\n lib/librte_eal/rte_eal_version.map          |  7 +++++\n test/test/test_service_cores.c              | 43 +++++++++++++++++++++++++++++\n 4 files changed, 93 insertions(+), 4 deletions(-)",
    "diff": "diff --git a/lib/librte_eal/common/include/rte_service.h b/lib/librte_eal/common/include/rte_service.h\nindex aea4d91b9..27b2dab7c 100644\n--- a/lib/librte_eal/common/include/rte_service.h\n+++ b/lib/librte_eal/common/include/rte_service.h\n@@ -162,6 +162,22 @@ int32_t rte_service_runstate_set(uint32_t id, uint32_t runstate);\n int32_t rte_service_runstate_get(uint32_t id);\n \n /**\n+ * This function returns whether the service may be currently executing on\n+ * at least one lcore, or definitely is not. This function can be used to\n+ * determine if, after setting the service runstate to stopped, the service\n+ * is still executing an a service lcore.\n+ *\n+ * Care must be taken if calling this function when the service runstate is\n+ * running, since the result of this function may be incorrect by the time the\n+ * function returns due to service cores running in parallel.\n+ *\n+ * @retval 1 Service may be running on one or more lcores\n+ * @retval 0 Service is not running on any lcore\n+ * @retval -EINVAL Invalid service id\n+ */\n+int32_t rte_service_may_be_active(uint32_t id);\n+\n+/**\n  * Enable or disable the check for a service-core being mapped to the service.\n  * An application can disable the check when takes the responsibility to run a\n  * service itself using *rte_service_run_iter_on_app_lcore*.\ndiff --git a/lib/librte_eal/common/rte_service.c b/lib/librte_eal/common/rte_service.c\nindex 73507aacb..d6c4c6039 100644\n--- a/lib/librte_eal/common/rte_service.c\n+++ b/lib/librte_eal/common/rte_service.c\n@@ -52,6 +52,7 @@ struct rte_service_spec_impl {\n \trte_atomic32_t num_mapped_cores;\n \tuint64_t calls;\n \tuint64_t cycles_spent;\n+\tuint8_t active_on_lcore[RTE_MAX_LCORE];\n } __rte_cache_aligned;\n \n /* the internal values of a service core */\n@@ -347,15 +348,19 @@ rte_service_runner_do_callback(struct rte_service_spec_impl *s,\n \n \n static inline int32_t\n-service_run(uint32_t i, struct core_state *cs, uint64_t service_mask)\n+service_run(uint32_t i, int lcore, struct core_state *cs, uint64_t service_mask)\n {\n \tif (!service_valid(i))\n \t\treturn -EINVAL;\n \tstruct rte_service_spec_impl *s = &rte_services[i];\n \tif (s->comp_runstate != RUNSTATE_RUNNING ||\n \t\t\ts->app_runstate != RUNSTATE_RUNNING ||\n-\t\t\t!(service_mask & (UINT64_C(1) << i)))\n+\t\t\t!(service_mask & (UINT64_C(1) << i))) {\n+\t\ts->active_on_lcore[lcore] = 0;\n \t\treturn -ENOEXEC;\n+\t}\n+\n+\ts->active_on_lcore[lcore] = 1;\n \n \t/* check do we need cmpset, if MT safe or <= 1 core\n \t * mapped, atomic ops are not required.\n@@ -374,6 +379,24 @@ service_run(uint32_t i, struct core_state *cs, uint64_t service_mask)\n \treturn 0;\n }\n \n+int32_t rte_service_may_be_active(uint32_t id)\n+{\n+\tuint32_t ids[RTE_MAX_LCORE] = {0};\n+\tstruct rte_service_spec_impl *s = &rte_services[id];\n+\tint32_t lcore_count = rte_service_lcore_list(ids, RTE_MAX_LCORE);\n+\tint i;\n+\n+\tif (!service_valid(id))\n+\t\treturn -EINVAL;\n+\n+\tfor (i = 0; i < lcore_count; i++) {\n+\t\tif (s->active_on_lcore[ids[i]])\n+\t\t\treturn 1;\n+\t}\n+\n+\treturn 0;\n+}\n+\n int32_t rte_service_run_iter_on_app_lcore(uint32_t id,\n \t\tuint32_t serialize_mt_unsafe)\n {\n@@ -398,7 +421,7 @@ int32_t rte_service_run_iter_on_app_lcore(uint32_t id,\n \t\treturn -EBUSY;\n \t}\n \n-\tint ret = service_run(id, cs, UINT64_MAX);\n+\tint ret = service_run(id, rte_lcore_id(), cs, UINT64_MAX);\n \n \tif (serialize_mt_unsafe)\n \t\trte_atomic32_dec(&s->num_mapped_cores);\n@@ -419,7 +442,7 @@ rte_service_runner_func(void *arg)\n \n \t\tfor (i = 0; i < RTE_SERVICE_NUM_MAX; i++) {\n \t\t\t/* return value ignored as no change to code flow */\n-\t\t\tservice_run(i, cs, service_mask);\n+\t\t\tservice_run(i, lcore, cs, service_mask);\n \t\t}\n \n \t\trte_smp_rmb();\ndiff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map\nindex f7dd0e7bc..fb113b446 100644\n--- a/lib/librte_eal/rte_eal_version.map\n+++ b/lib/librte_eal/rte_eal_version.map\n@@ -241,6 +241,13 @@ DPDK_18.05 {\n \n } DPDK_18.02;\n \n+DPDK_18.08 {\n+\tglobal:\n+\n+\trte_service_may_be_active;\n+\n+} DPDK_18.05;\n+\n EXPERIMENTAL {\n \tglobal:\n \ndiff --git a/test/test/test_service_cores.c b/test/test/test_service_cores.c\nindex 86b4073d2..e6973d642 100644\n--- a/test/test/test_service_cores.c\n+++ b/test/test/test_service_cores.c\n@@ -771,6 +771,48 @@ service_lcore_start_stop(void)\n \treturn unregister_all();\n }\n \n+/* stop a service and wait for it to become inactive */\n+static int\n+service_may_be_active(void)\n+{\n+\tconst uint32_t sid = 0;\n+\tint i;\n+\n+\t/* expected failure cases */\n+\tTEST_ASSERT_EQUAL(-EINVAL, rte_service_may_be_active(10000),\n+\t\t\t\"Invalid service may be active check did not fail\");\n+\n+\t/* start the service */\n+\tTEST_ASSERT_EQUAL(0, rte_service_runstate_set(sid, 1),\n+\t\t\t\"Starting valid service failed\");\n+\tTEST_ASSERT_EQUAL(0, rte_service_lcore_add(slcore_id),\n+\t\t\t\"Add service core failed when not in use before\");\n+\tTEST_ASSERT_EQUAL(0, rte_service_map_lcore_set(sid, slcore_id, 1),\n+\t\t\t\"Enabling valid service on valid core failed\");\n+\tTEST_ASSERT_EQUAL(0, rte_service_lcore_start(slcore_id),\n+\t\t\t\"Service core start after add failed\");\n+\n+\t/* ensures core really is running the service function */\n+\tTEST_ASSERT_EQUAL(1, service_lcore_running_check(),\n+\t\t\t\"Service core expected to poll service but it didn't\");\n+\n+\t/* stop the service */\n+\tTEST_ASSERT_EQUAL(0, rte_service_runstate_set(sid, 0),\n+\t\t\t\"Error: Service stop returned non-zero\");\n+\n+\t/* give the service 100ms to stop running */\n+\tfor (i = 0; i < 100; i++) {\n+\t\tif (!rte_service_may_be_active(sid))\n+\t\t\tbreak;\n+\t\trte_delay_ms(SERVICE_DELAY);\n+\t}\n+\n+\tTEST_ASSERT_EQUAL(0, rte_service_may_be_active(sid),\n+\t\t\t  \"Error: Service not stopped after 100ms\");\n+\n+\treturn unregister_all();\n+}\n+\n static struct unit_test_suite service_tests  = {\n \t.suite_name = \"service core test suite\",\n \t.setup = testsuite_setup,\n@@ -790,6 +832,7 @@ static struct unit_test_suite service_tests  = {\n \t\tTEST_CASE_ST(dummy_register, NULL, service_mt_safe_poll),\n \t\tTEST_CASE_ST(dummy_register, NULL, service_app_lcore_mt_safe),\n \t\tTEST_CASE_ST(dummy_register, NULL, service_app_lcore_mt_unsafe),\n+\t\tTEST_CASE_ST(dummy_register, NULL, service_may_be_active),\n \t\tTEST_CASES_END() /**< NULL terminate unit test array */\n \t}\n };\n",
    "prefixes": [
        "v2",
        "1/2"
    ]
}