get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 52247,
    "url": "http://patches.dpdk.org/api/patches/52247/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20190403232020.12784-4-gage.eads@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": "<20190403232020.12784-4-gage.eads@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20190403232020.12784-4-gage.eads@intel.com",
    "date": "2019-04-03T23:20:15",
    "name": "[v9,3/8] test/stack: add stack test",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "6c92656a420c67b089520e8c83d546af46bdfa9d",
    "submitter": {
        "id": 586,
        "url": "http://patches.dpdk.org/api/people/586/?format=api",
        "name": "Eads, Gage",
        "email": "gage.eads@intel.com"
    },
    "delegate": null,
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20190403232020.12784-4-gage.eads@intel.com/mbox/",
    "series": [
        {
            "id": 4103,
            "url": "http://patches.dpdk.org/api/series/4103/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=4103",
            "date": "2019-04-03T23:20:12",
            "name": "Add stack library and new mempool handler",
            "version": 9,
            "mbox": "http://patches.dpdk.org/series/4103/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/52247/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/52247/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 9806B1B0FC;\n\tThu,  4 Apr 2019 01:21:20 +0200 (CEST)",
            "from mga12.intel.com (mga12.intel.com [192.55.52.136])\n\tby dpdk.org (Postfix) with ESMTP id 9659B5F1C\n\tfor <dev@dpdk.org>; Thu,  4 Apr 2019 01:21:07 +0200 (CEST)",
            "from orsmga003.jf.intel.com ([10.7.209.27])\n\tby fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t03 Apr 2019 16:21:07 -0700",
            "from txasoft-yocto.an.intel.com ([10.123.72.192])\n\tby orsmga003.jf.intel.com with ESMTP; 03 Apr 2019 16:21:06 -0700"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.60,306,1549958400\"; d=\"scan'208\";a=\"139791666\"",
        "From": "Gage Eads <gage.eads@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "olivier.matz@6wind.com, arybchenko@solarflare.com,\n\tbruce.richardson@intel.com, konstantin.ananyev@intel.com,\n\tgavin.hu@arm.com, \n\tHonnappa.Nagarahalli@arm.com, nd@arm.com, thomas@monjalon.net",
        "Date": "Wed,  3 Apr 2019 18:20:15 -0500",
        "Message-Id": "<20190403232020.12784-4-gage.eads@intel.com>",
        "X-Mailer": "git-send-email 2.13.6",
        "In-Reply-To": "<20190403232020.12784-1-gage.eads@intel.com>",
        "References": "<20190403205041.4651-1-gage.eads@intel.com>\n\t<20190403232020.12784-1-gage.eads@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v9 3/8] test/stack: add stack test",
        "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\t<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\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "stack_autotest performs positive and negative testing of the stack API, and\nexercises the push and pop datapath functions with all available lcores.\n\nSigned-off-by: Gage Eads <gage.eads@intel.com>\nReviewed-by: Olivier Matz <olivier.matz@6wind.com>\n---\n MAINTAINERS           |   1 +\n app/test/Makefile     |   2 +\n app/test/meson.build  |   3 +\n app/test/test_stack.c | 411 ++++++++++++++++++++++++++++++++++++++++++++++++++\n 4 files changed, 417 insertions(+)\n create mode 100644 app/test/test_stack.c",
    "diff": "diff --git a/MAINTAINERS b/MAINTAINERS\nindex e09e7d93f..e4e6d1b15 100644\n--- a/MAINTAINERS\n+++ b/MAINTAINERS\n@@ -431,6 +431,7 @@ M: Olivier Matz <olivier.matz@6wind.com>\n F: lib/librte_stack/\n F: doc/guides/prog_guide/stack_lib.rst\n F: drivers/mempool/stack/\n+F: test/test/*stack*\n \n \n Memory Pool Drivers\ndiff --git a/app/test/Makefile b/app/test/Makefile\nindex d6aa28bad..e5bde81af 100644\n--- a/app/test/Makefile\n+++ b/app/test/Makefile\n@@ -90,6 +90,8 @@ endif\n \n SRCS-y += test_rwlock.c\n \n+SRCS-$(CONFIG_RTE_LIBRTE_STACK) += test_stack.c\n+\n SRCS-$(CONFIG_RTE_LIBRTE_TIMER) += test_timer.c\n SRCS-$(CONFIG_RTE_LIBRTE_TIMER) += test_timer_perf.c\n SRCS-$(CONFIG_RTE_LIBRTE_TIMER) += test_timer_racecond.c\ndiff --git a/app/test/meson.build b/app/test/meson.build\nindex c5e65fe66..56ea13f53 100644\n--- a/app/test/meson.build\n+++ b/app/test/meson.build\n@@ -95,6 +95,7 @@ test_sources = files('commands.c',\n \t'test_sched.c',\n \t'test_service_cores.c',\n \t'test_spinlock.c',\n+\t'test_stack.c',\n \t'test_string_fns.c',\n \t'test_table.c',\n \t'test_table_acl.c',\n@@ -133,6 +134,7 @@ test_deps = ['acl',\n \t'port',\n \t'reorder',\n \t'ring',\n+\t'stack',\n \t'timer'\n ]\n \n@@ -174,6 +176,7 @@ fast_parallel_test_names = [\n         'rwlock_autotest',\n         'sched_autotest',\n         'spinlock_autotest',\n+        'stack_autotest',\n         'string_autotest',\n         'table_autotest',\n         'tailq_autotest',\ndiff --git a/app/test/test_stack.c b/app/test/test_stack.c\nnew file mode 100644\nindex 000000000..6be2f876b\n--- /dev/null\n+++ b/app/test/test_stack.c\n@@ -0,0 +1,411 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2019 Intel Corporation\n+ */\n+\n+#include <string.h>\n+\n+#include <rte_atomic.h>\n+#include <rte_lcore.h>\n+#include <rte_malloc.h>\n+#include <rte_random.h>\n+#include <rte_stack.h>\n+\n+#include \"test.h\"\n+\n+#define STACK_SIZE 4096\n+#define MAX_BULK 32\n+\n+static int\n+test_stack_push_pop(struct rte_stack *s, void **obj_table, unsigned int bulk_sz)\n+{\n+\tunsigned int i, ret;\n+\tvoid **popped_objs;\n+\n+\tpopped_objs = rte_calloc(NULL, STACK_SIZE, sizeof(void *), 0);\n+\tif (popped_objs == NULL) {\n+\t\tprintf(\"[%s():%u] failed to calloc %zu bytes\\n\",\n+\t\t       __func__, __LINE__, STACK_SIZE * sizeof(void *));\n+\t\treturn -1;\n+\t}\n+\n+\tfor (i = 0; i < STACK_SIZE; i += bulk_sz) {\n+\t\tret = rte_stack_push(s, &obj_table[i], bulk_sz);\n+\n+\t\tif (ret != bulk_sz) {\n+\t\t\tprintf(\"[%s():%u] push returned: %d (expected %u)\\n\",\n+\t\t\t       __func__, __LINE__, ret, bulk_sz);\n+\t\t\trte_free(popped_objs);\n+\t\t\treturn -1;\n+\t\t}\n+\n+\t\tif (rte_stack_count(s) != i + bulk_sz) {\n+\t\t\tprintf(\"[%s():%u] stack count: %u (expected %u)\\n\",\n+\t\t\t       __func__, __LINE__, rte_stack_count(s),\n+\t\t\t       i + bulk_sz);\n+\t\t\trte_free(popped_objs);\n+\t\t\treturn -1;\n+\t\t}\n+\n+\t\tif (rte_stack_free_count(s) != STACK_SIZE - i - bulk_sz) {\n+\t\t\tprintf(\"[%s():%u] stack free count: %u (expected %u)\\n\",\n+\t\t\t       __func__, __LINE__, rte_stack_count(s),\n+\t\t\t       STACK_SIZE - i - bulk_sz);\n+\t\t\trte_free(popped_objs);\n+\t\t\treturn -1;\n+\t\t}\n+\t}\n+\n+\tfor (i = 0; i < STACK_SIZE; i += bulk_sz) {\n+\t\tret = rte_stack_pop(s, &popped_objs[i], bulk_sz);\n+\n+\t\tif (ret != bulk_sz) {\n+\t\t\tprintf(\"[%s():%u] pop returned: %d (expected %u)\\n\",\n+\t\t\t       __func__, __LINE__, ret, bulk_sz);\n+\t\t\trte_free(popped_objs);\n+\t\t\treturn -1;\n+\t\t}\n+\n+\t\tif (rte_stack_count(s) != STACK_SIZE - i - bulk_sz) {\n+\t\t\tprintf(\"[%s():%u] stack count: %u (expected %u)\\n\",\n+\t\t\t       __func__, __LINE__, rte_stack_count(s),\n+\t\t\t       STACK_SIZE - i - bulk_sz);\n+\t\t\trte_free(popped_objs);\n+\t\t\treturn -1;\n+\t\t}\n+\n+\t\tif (rte_stack_free_count(s) != i + bulk_sz) {\n+\t\t\tprintf(\"[%s():%u] stack free count: %u (expected %u)\\n\",\n+\t\t\t       __func__, __LINE__, rte_stack_count(s),\n+\t\t\t       i + bulk_sz);\n+\t\t\trte_free(popped_objs);\n+\t\t\treturn -1;\n+\t\t}\n+\t}\n+\n+\tfor (i = 0; i < STACK_SIZE; i++) {\n+\t\tif (obj_table[i] != popped_objs[STACK_SIZE - i - 1]) {\n+\t\t\tprintf(\"[%s():%u] Incorrect value %p at index 0x%x\\n\",\n+\t\t\t       __func__, __LINE__,\n+\t\t\t       popped_objs[STACK_SIZE - i - 1], i);\n+\t\t\trte_free(popped_objs);\n+\t\t\treturn -1;\n+\t\t}\n+\t}\n+\n+\trte_free(popped_objs);\n+\n+\treturn 0;\n+}\n+\n+static int\n+test_stack_basic(void)\n+{\n+\tstruct rte_stack *s = NULL;\n+\tvoid **obj_table = NULL;\n+\tint i, ret = -1;\n+\n+\tobj_table = rte_calloc(NULL, STACK_SIZE, sizeof(void *), 0);\n+\tif (obj_table == NULL) {\n+\t\tprintf(\"[%s():%u] failed to calloc %zu bytes\\n\",\n+\t\t       __func__, __LINE__, STACK_SIZE * sizeof(void *));\n+\t\tgoto fail_test;\n+\t}\n+\n+\tfor (i = 0; i < STACK_SIZE; i++)\n+\t\tobj_table[i] = (void *)(uintptr_t)i;\n+\n+\ts = rte_stack_create(__func__, STACK_SIZE, rte_socket_id(), 0);\n+\tif (s == NULL) {\n+\t\tprintf(\"[%s():%u] failed to create a stack\\n\",\n+\t\t       __func__, __LINE__);\n+\t\tgoto fail_test;\n+\t}\n+\n+\tif (rte_stack_lookup(__func__) != s) {\n+\t\tprintf(\"[%s():%u] failed to lookup a stack\\n\",\n+\t\t       __func__, __LINE__);\n+\t\tgoto fail_test;\n+\t}\n+\n+\tif (rte_stack_count(s) != 0) {\n+\t\tprintf(\"[%s():%u] stack count: %u (expected 0)\\n\",\n+\t\t       __func__, __LINE__, rte_stack_count(s));\n+\t\tgoto fail_test;\n+\t}\n+\n+\tif (rte_stack_free_count(s) != STACK_SIZE) {\n+\t\tprintf(\"[%s():%u] stack free count: %u (expected %u)\\n\",\n+\t\t       __func__, __LINE__, rte_stack_count(s), STACK_SIZE);\n+\t\tgoto fail_test;\n+\t}\n+\n+\tret = test_stack_push_pop(s, obj_table, 1);\n+\tif (ret) {\n+\t\tprintf(\"[%s():%u] Single object push/pop failed\\n\",\n+\t\t       __func__, __LINE__);\n+\t\tgoto fail_test;\n+\t}\n+\n+\tret = test_stack_push_pop(s, obj_table, MAX_BULK);\n+\tif (ret) {\n+\t\tprintf(\"[%s():%u] Bulk object push/pop failed\\n\",\n+\t\t       __func__, __LINE__);\n+\t\tgoto fail_test;\n+\t}\n+\n+\tret = rte_stack_push(s, obj_table, 2 * STACK_SIZE);\n+\tif (ret != 0) {\n+\t\tprintf(\"[%s():%u] Excess objects push succeeded\\n\",\n+\t\t       __func__, __LINE__);\n+\t\tgoto fail_test;\n+\t}\n+\n+\tret = rte_stack_pop(s, obj_table, 1);\n+\tif (ret != 0) {\n+\t\tprintf(\"[%s():%u] Empty stack pop succeeded\\n\",\n+\t\t       __func__, __LINE__);\n+\t\tgoto fail_test;\n+\t}\n+\n+\tret = 0;\n+\n+fail_test:\n+\trte_stack_free(s);\n+\n+\trte_free(obj_table);\n+\n+\treturn ret;\n+}\n+\n+static int\n+test_stack_name_reuse(void)\n+{\n+\tstruct rte_stack *s[2];\n+\n+\ts[0] = rte_stack_create(\"test\", STACK_SIZE, rte_socket_id(), 0);\n+\tif (s[0] == NULL) {\n+\t\tprintf(\"[%s():%u] Failed to create a stack\\n\",\n+\t\t       __func__, __LINE__);\n+\t\treturn -1;\n+\t}\n+\n+\ts[1] = rte_stack_create(\"test\", STACK_SIZE, rte_socket_id(), 0);\n+\tif (s[1] != NULL) {\n+\t\tprintf(\"[%s():%u] Failed to detect re-used name\\n\",\n+\t\t       __func__, __LINE__);\n+\t\treturn -1;\n+\t}\n+\n+\trte_stack_free(s[0]);\n+\n+\treturn 0;\n+}\n+\n+static int\n+test_stack_name_length(void)\n+{\n+\tchar name[RTE_STACK_NAMESIZE + 1];\n+\tstruct rte_stack *s;\n+\n+\tmemset(name, 's', sizeof(name));\n+\tname[RTE_STACK_NAMESIZE] = '\\0';\n+\n+\ts = rte_stack_create(name, STACK_SIZE, rte_socket_id(), 0);\n+\tif (s != NULL) {\n+\t\tprintf(\"[%s():%u] Failed to prevent long name\\n\",\n+\t\t       __func__, __LINE__);\n+\t\treturn -1;\n+\t}\n+\n+\tif (rte_errno != ENAMETOOLONG) {\n+\t\tprintf(\"[%s():%u] rte_stack failed to set correct errno on failed lookup\\n\",\n+\t\t       __func__, __LINE__);\n+\t\treturn -1;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static int\n+test_lookup_null(void)\n+{\n+\tstruct rte_stack *s = rte_stack_lookup(\"stack_not_found\");\n+\n+\tif (s != NULL) {\n+\t\tprintf(\"[%s():%u] rte_stack found a non-existent stack\\n\",\n+\t\t       __func__, __LINE__);\n+\t\treturn -1;\n+\t}\n+\n+\tif (rte_errno != ENOENT) {\n+\t\tprintf(\"[%s():%u] rte_stack failed to set correct errno on failed lookup\\n\",\n+\t\t       __func__, __LINE__);\n+\t\treturn -1;\n+\t}\n+\n+\ts = rte_stack_lookup(NULL);\n+\n+\tif (s != NULL) {\n+\t\tprintf(\"[%s():%u] rte_stack found a non-existent stack\\n\",\n+\t\t       __func__, __LINE__);\n+\t\treturn -1;\n+\t}\n+\n+\tif (rte_errno != EINVAL) {\n+\t\tprintf(\"[%s():%u] rte_stack failed to set correct errno on failed lookup\\n\",\n+\t\t       __func__, __LINE__);\n+\t\treturn -1;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static int\n+test_free_null(void)\n+{\n+\t/* Check whether the library proper handles a NULL pointer */\n+\trte_stack_free(NULL);\n+\n+\treturn 0;\n+}\n+\n+#define NUM_ITERS_PER_THREAD 100000\n+\n+struct test_args {\n+\tstruct rte_stack *s;\n+\trte_atomic64_t *sz;\n+};\n+\n+static int\n+stack_thread_push_pop(void *args)\n+{\n+\tstruct test_args *t = args;\n+\tvoid **obj_table;\n+\tint i;\n+\n+\tobj_table = rte_calloc(NULL, STACK_SIZE, sizeof(void *), 0);\n+\tif (obj_table == NULL) {\n+\t\tprintf(\"[%s():%u] failed to calloc %zu bytes\\n\",\n+\t\t       __func__, __LINE__, STACK_SIZE * sizeof(void *));\n+\t\treturn -1;\n+\t}\n+\n+\tfor (i = 0; i < NUM_ITERS_PER_THREAD; i++) {\n+\t\tunsigned int success, num;\n+\n+\t\t/* Reserve up to min(MAX_BULK, available slots) stack entries,\n+\t\t * then push and pop those stack entries.\n+\t\t */\n+\t\tdo {\n+\t\t\tuint64_t sz = rte_atomic64_read(t->sz);\n+\t\t\tvolatile uint64_t *sz_addr;\n+\n+\t\t\tsz_addr = (volatile uint64_t *)t->sz;\n+\n+\t\t\tnum = RTE_MIN(rte_rand() % MAX_BULK, STACK_SIZE - sz);\n+\n+\t\t\tsuccess = rte_atomic64_cmpset(sz_addr, sz, sz + num);\n+\t\t} while (success == 0);\n+\n+\t\tif (rte_stack_push(t->s, obj_table, num) != num) {\n+\t\t\tprintf(\"[%s():%u] Failed to push %u pointers\\n\",\n+\t\t\t       __func__, __LINE__, num);\n+\t\t\trte_free(obj_table);\n+\t\t\treturn -1;\n+\t\t}\n+\n+\t\tif (rte_stack_pop(t->s, obj_table, num) != num) {\n+\t\t\tprintf(\"[%s():%u] Failed to pop %u pointers\\n\",\n+\t\t\t       __func__, __LINE__, num);\n+\t\t\trte_free(obj_table);\n+\t\t\treturn -1;\n+\t\t}\n+\n+\t\trte_atomic64_sub(t->sz, num);\n+\t}\n+\n+\trte_free(obj_table);\n+\treturn 0;\n+}\n+\n+static int\n+test_stack_multithreaded(void)\n+{\n+\tstruct test_args *args;\n+\tunsigned int lcore_id;\n+\tstruct rte_stack *s;\n+\trte_atomic64_t size;\n+\n+\tprintf(\"[%s():%u] Running with %u lcores\\n\",\n+\t       __func__, __LINE__, rte_lcore_count());\n+\n+\tif (rte_lcore_count() < 2)\n+\t\treturn 0;\n+\n+\targs = rte_malloc(NULL, sizeof(struct test_args) * RTE_MAX_LCORE, 0);\n+\tif (args == NULL) {\n+\t\tprintf(\"[%s():%u] failed to malloc %zu bytes\\n\",\n+\t\t       __func__, __LINE__,\n+\t\t       sizeof(struct test_args) * RTE_MAX_LCORE);\n+\t\treturn -1;\n+\t}\n+\n+\ts = rte_stack_create(\"test\", STACK_SIZE, rte_socket_id(), 0);\n+\tif (s == NULL) {\n+\t\tprintf(\"[%s():%u] Failed to create a stack\\n\",\n+\t\t       __func__, __LINE__);\n+\t\trte_free(args);\n+\t\treturn -1;\n+\t}\n+\n+\trte_atomic64_init(&size);\n+\n+\tRTE_LCORE_FOREACH_SLAVE(lcore_id) {\n+\t\targs[lcore_id].s = s;\n+\t\targs[lcore_id].sz = &size;\n+\n+\t\tif (rte_eal_remote_launch(stack_thread_push_pop,\n+\t\t\t\t\t  &args[lcore_id], lcore_id))\n+\t\t\trte_panic(\"Failed to launch lcore %d\\n\", lcore_id);\n+\t}\n+\n+\tlcore_id = rte_lcore_id();\n+\n+\targs[lcore_id].s = s;\n+\targs[lcore_id].sz = &size;\n+\n+\tstack_thread_push_pop(&args[lcore_id]);\n+\n+\trte_eal_mp_wait_lcore();\n+\n+\trte_stack_free(s);\n+\trte_free(args);\n+\n+\treturn 0;\n+}\n+\n+static int\n+test_stack(void)\n+{\n+\tif (test_stack_basic() < 0)\n+\t\treturn -1;\n+\n+\tif (test_lookup_null() < 0)\n+\t\treturn -1;\n+\n+\tif (test_free_null() < 0)\n+\t\treturn -1;\n+\n+\tif (test_stack_name_reuse() < 0)\n+\t\treturn -1;\n+\n+\tif (test_stack_name_length() < 0)\n+\t\treturn -1;\n+\n+\tif (test_stack_multithreaded() < 0)\n+\t\treturn -1;\n+\n+\treturn 0;\n+}\n+\n+REGISTER_TEST_COMMAND(stack_autotest, test_stack);\n",
    "prefixes": [
        "v9",
        "3/8"
    ]
}