Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/96079/?format=api
https://patches.dpdk.org/api/patches/96079/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/20210720035125.14214-8-joyce.kong@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": "<20210720035125.14214-8-joyce.kong@arm.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20210720035125.14214-8-joyce.kong@arm.com", "date": "2021-07-20T03:51:24", "name": "[v3,7/8] test/service_cores: use compiler atomics for lock sync", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "1f8b6df633cb1cbbe50e3a025117dffe4b37e13a", "submitter": { "id": 970, "url": "https://patches.dpdk.org/api/people/970/?format=api", "name": "Joyce Kong", "email": "joyce.kong@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/20210720035125.14214-8-joyce.kong@arm.com/mbox/", "series": [ { "id": 17901, "url": "https://patches.dpdk.org/api/series/17901/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=17901", "date": "2021-07-20T03:51:17", "name": "use compiler atomic builtins for test", "version": 3, "mbox": "https://patches.dpdk.org/series/17901/mbox/" } ], "comments": "https://patches.dpdk.org/api/patches/96079/comments/", "check": "warning", "checks": "https://patches.dpdk.org/api/patches/96079/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 mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 6037BA0C43;\n\tTue, 20 Jul 2021 05:52:39 +0200 (CEST)", "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 56DB341153;\n\tTue, 20 Jul 2021 05:52:28 +0200 (CEST)", "from foss.arm.com (foss.arm.com [217.140.110.172])\n by mails.dpdk.org (Postfix) with ESMTP id 11E7B41190\n for <dev@dpdk.org>; Tue, 20 Jul 2021 05:52:26 +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 8AB3E1FB;\n Mon, 19 Jul 2021 20:52:25 -0700 (PDT)", "from net-arm-n1sdp.shanghai.arm.com (net-arm-n1sdp.shanghai.arm.com\n [10.169.208.222])\n by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 334FF3F694;\n Mon, 19 Jul 2021 20:52:21 -0700 (PDT)" ], "From": "Joyce Kong <joyce.kong@arm.com>", "To": "thomas@monjalon.net, david.marchand@redhat.com,\n roretzla@linux.microsoft.com, stephen@networkplumber.org,\n olivier.matz@6wind.com, andrew.rybchenko@oktetlabs.ru,\n harry.van.haaren@intel.com, honnappa.nagarahalli@arm.com,\n ruifeng.wang@arm.com", "Cc": "dev@dpdk.org,\n\tnd@arm.com", "Date": "Mon, 19 Jul 2021 22:51:24 -0500", "Message-Id": "<20210720035125.14214-8-joyce.kong@arm.com>", "X-Mailer": "git-send-email 2.17.1", "In-Reply-To": "<20210720035125.14214-1-joyce.kong@arm.com>", "References": "<20210616025459.22717-1-joyce.kong@arm.com>\n <20210720035125.14214-1-joyce.kong@arm.com>", "Subject": "[dpdk-dev] [PATCH v3 7/8] test/service_cores: use compiler atomics\n for lock sync", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.29", "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": "Convert rte_atomic usages to compiler atomic built-ins for lock\nsync in service_cores testcases.\n\nSigned-off-by: Joyce Kong <joyce.kong@arm.com>\nReviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>\nAcked-by: Stephen Hemminger <stephen@networkplumber.org>\n---\n app/test/test_service_cores.c | 36 +++++++++++++++++++----------------\n 1 file changed, 20 insertions(+), 16 deletions(-)", "diff": "diff --git a/app/test/test_service_cores.c b/app/test/test_service_cores.c\nindex 37d7172d53..ece104054e 100644\n--- a/app/test/test_service_cores.c\n+++ b/app/test/test_service_cores.c\n@@ -53,18 +53,20 @@ static int32_t dummy_cb(void *args)\n static int32_t dummy_mt_unsafe_cb(void *args)\n {\n \t/* before running test, the initialization has set pass_test to 1.\n-\t * If the cmpset in service-cores is working correctly, the code here\n+\t * If the CAS in service-cores is working correctly, the code here\n \t * should never fail to take the lock. If the lock *is* taken, fail the\n \t * test, because two threads are concurrently in a non-MT safe callback.\n \t */\n \tuint32_t *test_params = args;\n-\tuint32_t *atomic_lock = &test_params[0];\n+\tuint32_t *lock = &test_params[0];\n \tuint32_t *pass_test = &test_params[1];\n-\tint lock_taken = rte_atomic32_cmpset(atomic_lock, 0, 1);\n+\tuint32_t exp = 0;\n+\tint lock_taken = __atomic_compare_exchange_n(lock, &exp, 1, 0,\n+\t\t\t\t\t__ATOMIC_RELAXED, __ATOMIC_RELAXED);\n \tif (lock_taken) {\n \t\t/* delay with the lock held */\n \t\trte_delay_ms(250);\n-\t\trte_atomic32_clear((rte_atomic32_t *)atomic_lock);\n+\t\t__atomic_store_n(lock, 0, __ATOMIC_RELAXED);\n \t} else {\n \t\t/* 2nd thread will fail to take lock, so set pass flag */\n \t\t*pass_test = 0;\n@@ -83,13 +85,15 @@ static int32_t dummy_mt_safe_cb(void *args)\n \t * that 2 threads are running the callback at the same time: MT safe\n \t */\n \tuint32_t *test_params = args;\n-\tuint32_t *atomic_lock = &test_params[0];\n+\tuint32_t *lock = &test_params[0];\n \tuint32_t *pass_test = &test_params[1];\n-\tint lock_taken = rte_atomic32_cmpset(atomic_lock, 0, 1);\n+\tuint32_t exp = 0;\n+\tint lock_taken = __atomic_compare_exchange_n(lock, &exp, 1, 0,\n+\t\t\t\t\t__ATOMIC_RELAXED, __ATOMIC_RELAXED);\n \tif (lock_taken) {\n \t\t/* delay with the lock held */\n \t\trte_delay_ms(250);\n-\t\trte_atomic32_clear((rte_atomic32_t *)atomic_lock);\n+\t\t__atomic_store_n(lock, 0, __ATOMIC_RELAXED);\n \t} else {\n \t\t/* 2nd thread will fail to take lock, so set pass flag */\n \t\t*pass_test = 1;\n@@ -622,9 +626,9 @@ service_threaded_test(int mt_safe)\n \tTEST_ASSERT_EQUAL(0, rte_service_lcore_add(slcore_2),\n \t\t\t\"mt safe lcore add fail\");\n \n-\t/* Use atomic locks to verify that two threads are in the same function\n-\t * at the same time. These are passed to the unit tests through the\n-\t * callback userdata parameter\n+\t/* Use locks to verify that two threads are in the same function\n+\t * at the same time. These are passed to the unit tests through\n+\t * the callback userdata parameter.\n \t */\n \tuint32_t test_params[2];\n \tmemset(test_params, 0, sizeof(uint32_t) * 2);\n@@ -713,7 +717,7 @@ service_mt_safe_poll(void)\n }\n \n /* tests a NON mt safe service with two cores, the callback is serialized\n- * using the atomic cmpset.\n+ * using the CAS.\n */\n static int\n service_mt_unsafe_poll(void)\n@@ -735,17 +739,17 @@ delay_as_a_mt_safe_service(void *args)\n \tRTE_SET_USED(args);\n \tuint32_t *params = args;\n \n-\t/* retrieve done flag and atomic lock to inc/dec */\n+\t/* retrieve done flag and lock to add/sub */\n \tuint32_t *done = ¶ms[0];\n-\trte_atomic32_t *lock = (rte_atomic32_t *)¶ms[1];\n+\tuint32_t *lock = ¶ms[1];\n \n \twhile (!*done) {\n-\t\trte_atomic32_inc(lock);\n+\t\t__atomic_add_fetch(lock, 1, __ATOMIC_RELAXED);\n \t\trte_delay_us(500);\n-\t\tif (rte_atomic32_read(lock) > 1)\n+\t\tif (__atomic_load_n(lock, __ATOMIC_RELAXED) > 1)\n \t\t\t/* pass: second core has simultaneously incremented */\n \t\t\t*done = 1;\n-\t\trte_atomic32_dec(lock);\n+\t\t__atomic_sub_fetch(lock, 1, __ATOMIC_RELAXED);\n \t}\n \n \treturn 0;\n", "prefixes": [ "v3", "7/8" ] }{ "id": 96079, "url": "