get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 5457,
    "url": "https://patches.dpdk.org/api/patches/5457/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1434475006-13732-4-git-send-email-roman.dementiev@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": "<1434475006-13732-4-git-send-email-roman.dementiev@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1434475006-13732-4-git-send-email-roman.dementiev@intel.com",
    "date": "2015-06-16T17:16:46",
    "name": "[dpdk-dev,v2,3/3] test scaling of HTM lock elision protecting rte_hash",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "5a9bf0c8a3607443806cba27c5d88b9b5f5aad19",
    "submitter": {
        "id": 255,
        "url": "https://patches.dpdk.org/api/people/255/?format=api",
        "name": "Roman Dementiev",
        "email": "roman.dementiev@intel.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1434475006-13732-4-git-send-email-roman.dementiev@intel.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/5457/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/5457/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 [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id 89FE4C336;\n\tTue, 16 Jun 2015 19:18:04 +0200 (CEST)",
            "from mga11.intel.com (mga11.intel.com [192.55.52.93])\n\tby dpdk.org (Postfix) with ESMTP id 1A26FC32A\n\tfor <dev@dpdk.org>; Tue, 16 Jun 2015 19:18:01 +0200 (CEST)",
            "from fmsmga002.fm.intel.com ([10.253.24.26])\n\tby fmsmga102.fm.intel.com with ESMTP; 16 Jun 2015 10:17:50 -0700",
            "from unknown (HELO localhost) ([10.254.234.33])\n\tby fmsmga002.fm.intel.com with ESMTP; 16 Jun 2015 10:17:47 -0700"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.13,627,1427785200\"; d=\"scan'208\";a=\"744568041\"",
        "From": "Roman Dementiev <roman.dementiev@intel.com>",
        "To": "dev@dpdk.org",
        "Date": "Tue, 16 Jun 2015 10:16:46 -0700",
        "Message-Id": "<1434475006-13732-4-git-send-email-roman.dementiev@intel.com>",
        "X-Mailer": "git-send-email 1.9.5.msysgit.0",
        "In-Reply-To": "<1434475006-13732-1-git-send-email-roman.dementiev@intel.com>",
        "References": "<1433250693-23644-1-git-send-email-roman.dementiev@intel.com>\n\t<1434475006-13732-1-git-send-email-roman.dementiev@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v2 3/3] test scaling of HTM lock elision\n\tprotecting rte_hash",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "patches and discussions about DPDK <dev.dpdk.org>",
        "List-Unsubscribe": "<http://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": "<http://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": "This patch adds a new auto-test for testing the scaling\nof concurrent inserts into rte_hash when protected by\nthe normal spinlock vs. the spinlock with HTM lock\nelision. The test also benchmarks single-threaded\naccess without any locks.\n\nSigned-off-by: Roman Dementiev <roman.dementiev@intel.com>\n---\n app/test/Makefile            |   1 +\n app/test/test_hash_scaling.c | 223 +++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 224 insertions(+)\n create mode 100644 app/test/test_hash_scaling.c",
    "diff": "diff --git a/app/test/Makefile b/app/test/Makefile\nindex 3c777bf..6ffe539 100644\n--- a/app/test/Makefile\n+++ b/app/test/Makefile\n@@ -83,6 +83,7 @@ SRCS-y += test_memcpy_perf.c\n \n SRCS-$(CONFIG_RTE_LIBRTE_HASH) += test_hash.c\n SRCS-$(CONFIG_RTE_LIBRTE_HASH) += test_hash_perf.c\n+SRCS-$(CONFIG_RTE_LIBRTE_HASH) += test_hash_scaling.c\n \n SRCS-$(CONFIG_RTE_LIBRTE_LPM) += test_lpm.c\n SRCS-$(CONFIG_RTE_LIBRTE_LPM) += test_lpm6.c\ndiff --git a/app/test/test_hash_scaling.c b/app/test/test_hash_scaling.c\nnew file mode 100644\nindex 0000000..682ae94\n--- /dev/null\n+++ b/app/test/test_hash_scaling.c\n@@ -0,0 +1,223 @@\n+/*-\n+ *   BSD LICENSE\n+ *\n+ *   Copyright(c) 2015 Intel Corporation. All rights reserved.\n+ *   All rights reserved.\n+ *\n+ *   Redistribution and use in source and binary forms, with or without\n+ *   modification, are permitted provided that the following conditions\n+ *   are met:\n+ *\n+ *     * Redistributions of source code must retain the above copyright\n+ *       notice, this list of conditions and the following disclaimer.\n+ *     * Redistributions in binary form must reproduce the above copyright\n+ *       notice, this list of conditions and the following disclaimer in\n+ *       the documentation and/or other materials provided with the\n+ *       distribution.\n+ *     * Neither the name of Intel Corporation nor the names of its\n+ *       contributors may be used to endorse or promote products derived\n+ *       from this software without specific prior written permission.\n+ *\n+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+ *   \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+\n+#include <rte_cycles.h>\n+#include <rte_hash.h>\n+#include <rte_hash_crc.h>\n+#include <rte_spinlock.h>\n+#include <rte_launch.h>\n+\n+#include \"test.h\"\n+\n+/*\n+ * Check condition and return an error if true. Assumes that \"handle\" is the\n+ * name of the hash structure pointer to be freed.\n+ */\n+#define RETURN_IF_ERROR(cond, str, ...) do {\t\t\t\t\\\n+\tif (cond) {\t\t\t\t\t\t\t\\\n+\t\tprintf(\"ERROR line %d: \" str \"\\n\", __LINE__,\t\t\\\n+\t\t\t\t\t\t\t##__VA_ARGS__);\t\\\n+\t\tif (handle)\t\t\t\t\t\t\\\n+\t\t\trte_hash_free(handle);\t\t\t\t\\\n+\t\treturn -1;\t\t\t\t\t\t\\\n+\t}\t\t\t\t\t\t\t\t\\\n+} while (0)\n+\n+enum locking_mode_t {\n+\tNORMAL_LOCK,\n+\tLOCK_ELISION,\n+\tNULL_LOCK\n+};\n+\n+struct {\n+\tuint32_t num_iterations;\n+\tstruct rte_hash *h;\n+\trte_spinlock_t *lock;\n+\tint locking_mode;\n+} tbl_scaling_test_params;\n+\n+static rte_atomic64_t gcycles;\n+\n+static int test_hash_scaling_worker(__attribute__((unused)) void *arg)\n+{\n+\tuint64_t i, key;\n+\tuint32_t thr_id = rte_sys_gettid();\n+\tuint64_t begin, cycles = 0;\n+\n+\tswitch (tbl_scaling_test_params.locking_mode) {\n+\n+\tcase NORMAL_LOCK:\n+\n+\t\tfor (i = 0; i < tbl_scaling_test_params.num_iterations; i++) {\n+\t\t\t/*\tdifferent threads get different keys because\n+\t\t\t\twe use the thread-id in the key computation\n+\t\t\t */\n+\t\t\tkey = rte_hash_crc(&i, sizeof(i), thr_id);\n+\t\t\tbegin = rte_rdtsc_precise();\n+\t\t\trte_spinlock_lock(tbl_scaling_test_params.lock);\n+\t\t\trte_hash_add_key(tbl_scaling_test_params.h, &key);\n+\t\t\trte_spinlock_unlock(tbl_scaling_test_params.lock);\n+\t\t\tcycles += rte_rdtsc_precise() - begin;\n+\t\t}\n+\t\tbreak;\n+\n+\tcase LOCK_ELISION:\n+\n+\t\tfor (i = 0; i < tbl_scaling_test_params.num_iterations; i++) {\n+\t\t\tkey = rte_hash_crc(&i, sizeof(i), thr_id);\n+\t\t\tbegin = rte_rdtsc_precise();\n+\t\t\trte_spinlock_lock_tm(tbl_scaling_test_params.lock);\n+\t\t\trte_hash_add_key(tbl_scaling_test_params.h, &key);\n+\t\t\trte_spinlock_unlock_tm(tbl_scaling_test_params.lock);\n+\t\t\tcycles += rte_rdtsc_precise() - begin;\n+\t\t}\n+\t\tbreak;\n+\n+\tdefault:\n+\n+\t\tfor (i = 0; i < tbl_scaling_test_params.num_iterations; i++) {\n+\t\t\tkey = rte_hash_crc(&i, sizeof(i), thr_id);\n+\t\t\tbegin = rte_rdtsc_precise();\n+\t\t\trte_hash_add_key(tbl_scaling_test_params.h, &key);\n+\t\t\tcycles += rte_rdtsc_precise() - begin;\n+\t\t}\n+\t}\n+\n+\trte_atomic64_add(&gcycles, cycles);\n+\n+\treturn 0;\n+}\n+\n+/*\n+ * Do scalability perf tests.\n+ */\n+static int\n+test_hash_scaling(int locking_mode)\n+{\n+\tstatic unsigned calledCount =    1;\n+\tuint32_t num_iterations = 1024*1024;\n+\tuint64_t i, key;\n+\tstruct rte_hash_parameters hash_params = {\n+\t\t.entries = num_iterations*2,\n+\t\t.bucket_entries = 16,\n+\t\t.key_len = sizeof(key),\n+\t\t.hash_func = rte_hash_crc,\n+\t\t.hash_func_init_val = 0,\n+\t\t.socket_id = rte_socket_id(),\n+\t};\n+\tstruct rte_hash *handle;\n+\tchar name[RTE_HASH_NAMESIZE];\n+\trte_spinlock_t lock;\n+\n+\trte_spinlock_init(&lock);\n+\n+\tsnprintf(name, 32, \"test%u\", calledCount++);\n+\thash_params.name = name;\n+\n+\thandle = rte_hash_create(&hash_params);\n+\tRETURN_IF_ERROR(handle == NULL, \"hash creation failed\");\n+\n+\ttbl_scaling_test_params.num_iterations =\n+\t\tnum_iterations/rte_lcore_count();\n+\ttbl_scaling_test_params.h = handle;\n+\ttbl_scaling_test_params.lock = &lock;\n+\ttbl_scaling_test_params.locking_mode = locking_mode;\n+\n+\trte_atomic64_init(&gcycles);\n+\trte_atomic64_clear(&gcycles);\n+\n+\t/* fill up to initial size */\n+\tfor (i = 0; i < num_iterations; i++) {\n+\t\tkey = rte_hash_crc(&i, sizeof(i), 0xabcdabcd);\n+\t\trte_hash_add_key(tbl_scaling_test_params.h, &key);\n+\t}\n+\n+\trte_eal_mp_remote_launch(test_hash_scaling_worker, NULL, CALL_MASTER);\n+\trte_eal_mp_wait_lcore();\n+\n+\tunsigned long long int cycles_per_operation =\n+\t\trte_atomic64_read(&gcycles)/\n+\t\t(tbl_scaling_test_params.num_iterations*rte_lcore_count());\n+\tconst char *lock_name;\n+\n+\tswitch (locking_mode) {\n+\tcase NORMAL_LOCK:\n+\t\tlock_name = \"normal spinlock\";\n+\t\tbreak;\n+\tcase LOCK_ELISION:\n+\t\tlock_name = \"lock elision\";\n+\t\tbreak;\n+\tdefault:\n+\t\tlock_name = \"null lock\";\n+\t}\n+\tprintf(\"--------------------------------------------------------\\n\");\n+\tprintf(\"Cores: %d; %s mode ->  cycles per operation: %llu\\n\",\n+\t\trte_lcore_count(), lock_name, cycles_per_operation);\n+\tprintf(\"--------------------------------------------------------\\n\");\n+\t/* CSV output */\n+\tprintf(\">>>%d,%s,%llu\\n\", rte_lcore_count(), lock_name,\n+\t\tcycles_per_operation);\n+\n+\trte_hash_free(handle);\n+\treturn 0;\n+}\n+\n+static int\n+test_hash_scaling_main(void)\n+{\n+\tint r = 0;\n+\n+\tif (rte_lcore_count() == 1)\n+\t\tr = test_hash_scaling(NULL_LOCK);\n+\n+\tif (r == 0)\n+\t\tr = test_hash_scaling(NORMAL_LOCK);\n+\n+\tif (!rte_tm_supported()) {\n+\t\tprintf(\"Hardware transactional memory (lock elision) is NOT supported\\n\");\n+\t\treturn r;\n+\t}\n+\tprintf(\"Hardware transactional memory (lock elision) is supported\\n\");\n+\n+\tif (r == 0)\n+\t\tr = test_hash_scaling(LOCK_ELISION);\n+\n+\treturn r;\n+}\n+\n+\n+static struct test_command hash_scaling_cmd = {\n+\t.command = \"hash_scaling_autotest\",\n+\t.callback = test_hash_scaling_main,\n+};\n+REGISTER_TEST_COMMAND(hash_scaling_cmd);\n",
    "prefixes": [
        "dpdk-dev",
        "v2",
        "3/3"
    ]
}