get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 33754,
    "url": "http://patches.dpdk.org/api/patches/33754/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1516028680-2342-2-git-send-email-konstantin.ananyev@intel.com/",
    "project": {
        "id": 1,
        "url": "http://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": "<1516028680-2342-2-git-send-email-konstantin.ananyev@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1516028680-2342-2-git-send-email-konstantin.ananyev@intel.com",
    "date": "2018-01-15T15:04:39",
    "name": "[dpdk-dev,v3,1/2] test/test: introduce new test-case for rte_smp_mb()",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "a5a6b406ee97e12df3d43c9293bade6fd48e1fd3",
    "submitter": {
        "id": 33,
        "url": "http://patches.dpdk.org/api/people/33/?format=api",
        "name": "Ananyev, Konstantin",
        "email": "konstantin.ananyev@intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/1516028680-2342-2-git-send-email-konstantin.ananyev@intel.com/mbox/",
    "series": [],
    "comments": "http://patches.dpdk.org/api/patches/33754/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/33754/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 2AAE7A823;\n\tMon, 15 Jan 2018 16:05:09 +0100 (CET)",
            "from mga04.intel.com (mga04.intel.com [192.55.52.120])\n\tby dpdk.org (Postfix) with ESMTP id 1DB5A397D\n\tfor <dev@dpdk.org>; Mon, 15 Jan 2018 16:05:04 +0100 (CET)",
            "from fmsmga001.fm.intel.com ([10.253.24.23])\n\tby fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t15 Jan 2018 07:05:04 -0800",
            "from sivswdev02.ir.intel.com (HELO localhost.localdomain)\n\t([10.237.217.46])\n\tby fmsmga001.fm.intel.com with ESMTP; 15 Jan 2018 07:05:03 -0800"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.46,364,1511856000\"; d=\"scan'208\";a=\"22343727\"",
        "From": "Konstantin Ananyev <konstantin.ananyev@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "Konstantin Ananyev <konstantin.ananyev@intel.com>",
        "Date": "Mon, 15 Jan 2018 15:04:39 +0000",
        "Message-Id": "<1516028680-2342-2-git-send-email-konstantin.ananyev@intel.com>",
        "X-Mailer": "git-send-email 1.7.0.7",
        "In-Reply-To": "<1513611253-8785-2-git-send-email-konstantin.ananyev@intel.com>",
        "References": "<1513611253-8785-2-git-send-email-konstantin.ananyev@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v3 1/2] test/test: introduce new test-case for\n\trte_smp_mb()",
        "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": "Simple functional test for rte_smp_mb() implementations.\nAlso when executed on a single lcore could be used as rough\nestimation how many cycles particular implementation of rte_smp_mb()\nmight take.\n\nSigned-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>\n---\n test/test/Makefile       |   1 +\n test/test/test_barrier.c | 286 +++++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 287 insertions(+)\n create mode 100644 test/test/test_barrier.c",
    "diff": "diff --git a/test/test/Makefile b/test/test/Makefile\nindex e7818dc6e..80fb09e2e 100644\n--- a/test/test/Makefile\n+++ b/test/test/Makefile\n@@ -67,6 +67,7 @@ SRCS-y += test_spinlock.c\n SRCS-y += test_memory.c\n SRCS-y += test_memzone.c\n SRCS-y += test_bitmap.c\n+SRCS-y += test_barrier.c\n \n SRCS-y += test_ring.c\n SRCS-y += test_ring_perf.c\ndiff --git a/test/test/test_barrier.c b/test/test/test_barrier.c\nnew file mode 100644\nindex 000000000..82b572c3e\n--- /dev/null\n+++ b/test/test/test_barrier.c\n@@ -0,0 +1,286 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2010-2018 Intel Corporation\n+ */\n+\n+ /*\n+  * This is a simple functional test for rte_smp_mb() implementation.\n+  * I.E. make sure that LOAD and STORE operations that precede the\n+  * rte_smp_mb() call are globally visible across the lcores\n+  * before the the LOAD and STORE operations that follows it.\n+  * The test uses simple implementation of Peterson's lock algorithm\n+  * (https://en.wikipedia.org/wiki/Peterson%27s_algorithm)\n+  * for two execution units to make sure that rte_smp_mb() prevents\n+  * store-load reordering to happen.\n+  * Also when executed on a single lcore could be used as a approxiamate\n+  * estimation of number of cycles particular implementation of rte_smp_mb()\n+  * will take.\n+  */\n+\n+#include <stdio.h>\n+#include <string.h>\n+#include <stdint.h>\n+#include <inttypes.h>\n+\n+#include <rte_memory.h>\n+#include <rte_per_lcore.h>\n+#include <rte_launch.h>\n+#include <rte_atomic.h>\n+#include <rte_eal.h>\n+#include <rte_lcore.h>\n+#include <rte_pause.h>\n+#include <rte_random.h>\n+#include <rte_cycles.h>\n+#include <rte_vect.h>\n+#include <rte_debug.h>\n+\n+#include \"test.h\"\n+\n+#define ADD_MAX\t\t8\n+#define ITER_MAX\t0x1000000\n+\n+enum plock_use_type {\n+\tUSE_MB,\n+\tUSE_SMP_MB,\n+\tUSE_NUM\n+};\n+\n+struct plock {\n+\tvolatile uint32_t flag[2];\n+\tvolatile uint32_t victim;\n+\tenum plock_use_type utype;\n+};\n+\n+/*\n+ * Lock plus protected by it two counters.\n+ */\n+struct plock_test {\n+\tstruct plock lock;\n+\tuint32_t val;\n+\tuint32_t iter;\n+};\n+\n+/*\n+ * Each active lcore shares plock_test struct with it's left and right\n+ * neighbours.\n+ */\n+struct lcore_plock_test {\n+\tstruct plock_test *pt[2]; /* shared, lock-protected data */\n+\tuint32_t sum[2];          /* local copy of the shared data */\n+\tuint32_t iter;            /* number of iterations to perfom */\n+\tuint32_t lc;              /* given lcore id */\n+};\n+\n+static inline void\n+store_load_barrier(uint32_t utype)\n+{\n+\tif (utype == USE_MB)\n+\t\trte_mb();\n+\telse if (utype == USE_SMP_MB)\n+\t\trte_smp_mb();\n+\telse\n+\t\tRTE_VERIFY(0);\n+}\n+\n+/*\n+ * Peterson lock implementation.\n+ */\n+static void\n+plock_lock(struct plock *l, uint32_t self)\n+{\n+\tuint32_t other;\n+\n+\tother = self ^ 1;\n+\n+\tl->flag[self] = 1;\n+\tl->victim = self;\n+\n+\tstore_load_barrier(l->utype);\n+\n+\twhile (l->flag[other] == 1 && l->victim == self)\n+\t\trte_pause();\n+}\n+\n+static void\n+plock_unlock(struct plock *l, uint32_t self)\n+{\n+\trte_smp_wmb();\n+\tl->flag[self] = 0;\n+}\n+\n+static void\n+plock_reset(struct plock *l, enum plock_use_type utype)\n+{\n+\tmemset(l, 0, sizeof(*l));\n+\tl->utype = utype;\n+}\n+\n+/*\n+ * grab the lock, update both counters, release the lock.\n+ */\n+static void\n+plock_add(struct plock_test *pt, uint32_t self, uint32_t n)\n+{\n+\tplock_lock(&pt->lock, self);\n+\tpt->iter++;\n+\tpt->val += n;\n+\tplock_unlock(&pt->lock, self);\n+}\n+\n+static int\n+plock_test1_lcore(void *data)\n+{\n+\tuint64_t tm;\n+\tuint32_t i, lc, ln, n;\n+\tstruct lcore_plock_test *lpt;\n+\n+\tlpt = data;\n+\tlc = rte_lcore_id();\n+\n+\t/* find lcore_plock_test struct for given lcore */\n+\tfor (ln = rte_lcore_count(); ln != 0 && lpt->lc != lc; lpt++, ln--)\n+\t\t;\n+\n+\tif (ln == 0) {\n+\t\tprintf(\"%s(%u) error at init\\n\", __func__, lc);\n+\t\treturn -1;\n+\t}\n+\n+\tn = rte_rand() % ADD_MAX;\n+\ttm = rte_get_timer_cycles();\n+\n+\t/*\n+\t * for each iteration:\n+\t * - update shared, locked protected data in a safe manner\n+\t * - update local copy of the shared data\n+\t */\n+\tfor (i = 0; i != lpt->iter; i++) {\n+\n+\t\tplock_add(lpt->pt[0], 0, n);\n+\t\tplock_add(lpt->pt[1], 1, n);\n+\n+\t\tlpt->sum[0] += n;\n+\t\tlpt->sum[1] += n;\n+\n+\t\tn = (n + 1) % ADD_MAX;\n+\t}\n+\n+\ttm = rte_get_timer_cycles() - tm;\n+\n+\tprintf(\"%s(%u): %u iterations finished, in %\" PRIu64\n+\t\t\" cycles, %#Lf cycles/iteration, \"\n+\t\t\"local sum={%u, %u}\\n\",\n+\t\t__func__, lc, i, tm, (long double)tm / i,\n+\t\tlpt->sum[0], lpt->sum[1]);\n+\treturn 0;\n+}\n+\n+/*\n+ * For N active lcores we allocate N+1 lcore_plock_test structures.\n+ * Each active lcore shares one lcore_plock_test structure with its\n+ * left lcore neighbor and one lcore_plock_test structure with its\n+ * right lcore neighbor.\n+ * During the test each lcore updates data in both shared structures and\n+ * its local copies. Then at validation phase we check that our shared\n+ * and local data are the same.\n+ */\n+static int\n+plock_test(uint32_t iter, enum plock_use_type utype)\n+{\n+\tint32_t rc;\n+\tuint32_t i, lc, n;\n+\tuint32_t *sum;\n+\tstruct plock_test *pt;\n+\tstruct lcore_plock_test *lpt;\n+\n+\t/* init phase, allocate and initialize shared data */\n+\n+\tn = rte_lcore_count();\n+\tpt = calloc(n + 1, sizeof(*pt));\n+\tlpt = calloc(n, sizeof(*lpt));\n+\tsum = calloc(n + 1, sizeof(*sum));\n+\n+\tprintf(\"%s(iter=%u, utype=%u) started on %u lcores\\n\",\n+\t\t__func__, iter, utype, n);\n+\n+\tif (pt == NULL || lpt == NULL) {\n+\t\tprintf(\"%s: failed to allocate memory for %u lcores\\n\",\n+\t\t\t__func__, n);\n+\t\tfree(pt);\n+\t\tfree(lpt);\n+\t\tfree(sum);\n+\t\treturn -ENOMEM;\n+\t}\n+\n+\tfor (i = 0; i != n + 1; i++)\n+\t\tplock_reset(&pt[i].lock, utype);\n+\n+\ti = 0;\n+\tRTE_LCORE_FOREACH(lc) {\n+\n+\t\tlpt[i].lc = lc;\n+\t\tlpt[i].iter = iter;\n+\t\tlpt[i].pt[0] = pt + i;\n+\t\tlpt[i].pt[1] = pt + i + 1;\n+\t\ti++;\n+\t}\n+\n+\tlpt[i - 1].pt[1] = pt;\n+\n+\tfor (i = 0; i != n; i++)\n+\t\tprintf(\"lpt[%u]={lc=%u, pt={%p, %p},};\\n\",\n+\t\t\ti, lpt[i].lc, lpt[i].pt[0], lpt[i].pt[1]);\n+\n+\n+\t/* test phase - start and wait for completion on each active lcore */\n+\n+\trte_eal_mp_remote_launch(plock_test1_lcore, lpt, CALL_MASTER);\n+\trte_eal_mp_wait_lcore();\n+\n+\t/* validation phase - make sure that shared and local data match */\n+\n+\tfor (i = 0; i != n; i++) {\n+\t\tsum[i] += lpt[i].sum[0];\n+\t\tsum[i + 1] += lpt[i].sum[1];\n+\t}\n+\n+\tsum[0] += sum[i];\n+\n+\trc = 0;\n+\tfor (i = 0; i != n; i++) {\n+\t\tprintf(\"%s: sum[%u]=%u, pt[%u].val=%u, pt[%u].iter=%u;\\n\",\n+\t\t\t__func__, i, sum[i], i, pt[i].val, i, pt[i].iter);\n+\n+\t\t/* race condition occurred, lock doesn't work properly */\n+\t\tif (sum[i] != pt[i].val || 2 * iter != pt[i].iter) {\n+\t\t\tprintf(\"error: local and shared sums don't much\\n\");\n+\t\t\trc = -1;\n+\t\t}\n+\t}\n+\n+\tfree(pt);\n+\tfree(lpt);\n+\tfree(sum);\n+\n+\tprintf(\"%s(utype=%u) returns %d\\n\", __func__, utype, rc);\n+\treturn rc;\n+}\n+\n+static int\n+test_barrier(void)\n+{\n+\tint32_t i, ret, rc[USE_NUM];\n+\n+\tfor (i = 0; i != RTE_DIM(rc); i++)\n+\t\trc[i] = plock_test(ITER_MAX, i);\n+\n+\tret = 0;\n+\tfor (i = 0; i != RTE_DIM(rc); i++) {\n+\t\tprintf(\"%s for utype=%d %s\\n\",\n+\t\t\t__func__, i, rc[i] == 0 ? \"passed\" : \"failed\");\n+\t\tret |= rc[i];\n+\t}\n+\n+\treturn ret;\n+}\n+\n+REGISTER_TEST_COMMAND(barrier_autotest, test_barrier);\n",
    "prefixes": [
        "dpdk-dev",
        "v3",
        "1/2"
    ]
}