get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 61475,
    "url": "https://patches.dpdk.org/api/patches/61475/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20191018183120.116065-1-drc@linux.vnet.ibm.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": "<20191018183120.116065-1-drc@linux.vnet.ibm.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20191018183120.116065-1-drc@linux.vnet.ibm.com",
    "date": "2019-10-18T18:31:20",
    "name": "[v3] app/test: add tests for atomic exchanges",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "6ce057661a403d05796172c238ff0d504cba400e",
    "submitter": {
        "id": 1256,
        "url": "https://patches.dpdk.org/api/people/1256/?format=api",
        "name": "David Christensen",
        "email": "drc@linux.vnet.ibm.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/20191018183120.116065-1-drc@linux.vnet.ibm.com/mbox/",
    "series": [
        {
            "id": 6942,
            "url": "https://patches.dpdk.org/api/series/6942/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=6942",
            "date": "2019-10-18T18:31:20",
            "name": "[v3] app/test: add tests for atomic exchanges",
            "version": 3,
            "mbox": "https://patches.dpdk.org/series/6942/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/61475/comments/",
    "check": "fail",
    "checks": "https://patches.dpdk.org/api/patches/61475/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 0BA9C1BE81;\n\tFri, 18 Oct 2019 20:31:29 +0200 (CEST)",
            "from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com\n\t[148.163.158.5]) by dpdk.org (Postfix) with ESMTP id 8B5152BAE\n\tfor <dev@dpdk.org>; Fri, 18 Oct 2019 20:31:27 +0200 (CEST)",
            "from pps.filterd (m0098414.ppops.net [127.0.0.1])\n\tby mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id\n\tx9IIRMcf124899 for <dev@dpdk.org>; Fri, 18 Oct 2019 14:31:26 -0400",
            "from ppma01dal.us.ibm.com (83.d6.3fa9.ip4.static.sl-reverse.com\n\t[169.63.214.131])\n\tby mx0b-001b2d01.pphosted.com with ESMTP id 2vqj4ys8ts-1\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256\n\tverify=NOT) for <dev@dpdk.org>; Fri, 18 Oct 2019 14:31:26 -0400",
            "from pps.filterd (ppma01dal.us.ibm.com [127.0.0.1])\n\tby ppma01dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id\n\tx9IIM4in012220 for <dev@dpdk.org>; Fri, 18 Oct 2019 18:31:25 GMT",
            "from b01cxnp22036.gho.pok.ibm.com (b01cxnp22036.gho.pok.ibm.com\n\t[9.57.198.26]) by ppma01dal.us.ibm.com with ESMTP id 2vq0brt23h-1\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256\n\tverify=NOT) for <dev@dpdk.org>; Fri, 18 Oct 2019 18:31:25 +0000",
            "from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com\n\t[9.57.199.107])\n\tby b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP\n\tid x9IIVPdU13697950\n\t(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256\n\tverify=OK); Fri, 18 Oct 2019 18:31:25 GMT",
            "from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1])\n\tby IMSVA (Postfix) with ESMTP id 0CB95124055;\n\tFri, 18 Oct 2019 18:31:25 +0000 (GMT)",
            "from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1])\n\tby IMSVA (Postfix) with ESMTP id E9703124052;\n\tFri, 18 Oct 2019 18:31:24 +0000 (GMT)",
            "from localhost.localdomain (unknown [9.114.224.51])\n\tby b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP;\n\tFri, 18 Oct 2019 18:31:24 +0000 (GMT)"
        ],
        "From": "David Christensen <drc@linux.vnet.ibm.com>",
        "To": "dev@dpdk.org",
        "Cc": "David Christensen <drc@linux.vnet.ibm.com>",
        "Date": "Fri, 18 Oct 2019 11:31:20 -0700",
        "Message-Id": "<20191018183120.116065-1-drc@linux.vnet.ibm.com>",
        "X-Mailer": "git-send-email 2.18.1",
        "In-Reply-To": "<20191017223903.70437-1-drc@linux.vnet.ibm.com>",
        "References": "<20191017223903.70437-1-drc@linux.vnet.ibm.com>",
        "X-TM-AS-GCONF": "00",
        "X-Proofpoint-Virus-Version": "vendor=fsecure engine=2.50.10434:, ,\n\tdefinitions=2019-10-18_04:, , signatures=0",
        "X-Proofpoint-Spam-Details": "rule=outbound_notspam policy=outbound score=0\n\tpriorityscore=1501\n\tmalwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0\n\tclxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0\n\tmlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx\n\tscancount=1 engine=8.0.1-1908290000 definitions=main-1910180165",
        "Subject": "[dpdk-dev] [PATCH v3] app/test: add tests for atomic exchanges",
        "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": "The test works by creating a token comprised of random data\nand a CRC8 value, using the rte_atomicXX_exchange to exchange\nthe new token for a previously generated token, and then\nverifying that the exchanged data is intact (i.e. the CRC8\nis still correct for the data).\n\nSigned-off-by: David Christensen <drc@linux.vnet.ibm.com>\n---\nv3:\n* Actually fixed build issue on all platforms caused by\n  misspelling of rte_atomic64_inc\n\nv2:\n* Fixed build issue on all platforms caused by misspelling\n  of rte_atomic64_inc\n\n app/test/test_atomic.c | 173 ++++++++++++++++++++++++++++++++++++++++-\n 1 file changed, 171 insertions(+), 2 deletions(-)",
    "diff": "diff --git a/app/test/test_atomic.c b/app/test/test_atomic.c\nindex 43be30ec0..725e7a5df 100644\n--- a/app/test/test_atomic.c\n+++ b/app/test/test_atomic.c\n@@ -1,10 +1,12 @@\n /* SPDX-License-Identifier: BSD-3-Clause\n  * Copyright(c) 2010-2014 Intel Corporation\n+ * Copyright(c) 2019 Arm Limited\n  */\n \n #include <stdio.h>\n #include <stdint.h>\n #include <unistd.h>\n+#include <inttypes.h>\n #include <sys/queue.h>\n \n #include <rte_memory.h>\n@@ -13,6 +15,8 @@\n #include <rte_atomic.h>\n #include <rte_eal.h>\n #include <rte_lcore.h>\n+#include <rte_random.h>\n+#include <rte_hash_crc.h>\n \n #include \"test.h\"\n \n@@ -20,7 +24,7 @@\n  * Atomic Variables\n  * ================\n  *\n- * - The main test function performs three subtests. The first test\n+ * - The main test function performs four subtests. The first test\n  *   checks that the usual inc/dec/add/sub functions are working\n  *   correctly:\n  *\n@@ -61,11 +65,26 @@\n  *       atomic_sub(&count, tmp+1);\n  *\n  *   - At the end of the test, the *count* value must be 0.\n+ *\n+ * - Test \"atomic exchange\"\n+ *\n+ *   - Create a 64 bit token that can be tested for data integrity\n+ *\n+ *   - Invoke ``test_atomic_exchange`` on each lcore.  Before doing\n+ *     anything else, the cores wait for a synchronization event.\n+ *     Each core then does the follwoing for N iterations:\n+ *\n+ *       Generate a new token with a data integrity check\n+ *       Exchange the new token for previously generated token\n+ *       Increment a counter if a corrupt token was received\n+ *\n+ *   - At the end of the test, the number of corrupted tokens must be 0.\n+ *\n  */\n \n #define NUM_ATOMIC_TYPES 3\n \n-#define N 10000\n+#define N 1000000\n \n static rte_atomic16_t a16;\n static rte_atomic32_t a32;\n@@ -216,6 +235,124 @@ test_atomic_dec_and_test(__attribute__((unused)) void *arg)\n \treturn 0;\n }\n \n+/*\n+ * Helper definitions/variables/functions for\n+ * atomic exchange tests\n+ */\n+typedef union {\n+\tuint16_t u16;\n+\tuint8_t  u8[2];\n+} rte_u16_t;\n+\n+typedef union {\n+\tuint32_t u32;\n+\tuint16_t u16[2];\n+\tuint8_t  u8[4];\n+} rte_u32_t;\n+\n+typedef union {\n+\tuint64_t u64;\n+\tuint32_t u32[2];\n+\tuint16_t u16[4];\n+\tuint8_t  u8[8];\n+} rte_u64_t;\n+\n+const uint8_t CRC8_POLY = 0x91;\n+uint8_t crc8_table[256];\n+\n+volatile uint16_t token16;\n+volatile uint32_t token32;\n+volatile uint64_t token64;\n+\n+static void\n+build_crc8_table(void)\n+{\n+\tuint8_t val;\n+\n+\tfor (int i = 0; i < 256; i++) {\n+\t\tval = i;\n+\t\tfor (int j = 0; j < 8; j++) {\n+\t\t\tif (val & 1)\n+\t\t\t\tval ^= CRC8_POLY;\n+\t\t\tval >>= 1;\n+\t\t}\n+\t\tcrc8_table[i] = val;\n+\t}\n+}\n+\n+static uint8_t\n+get_crc8(uint8_t *message, int length)\n+{\n+\tuint8_t crc = 0;\n+\n+\tfor (int i = 0; i < length; i++)\n+\t\tcrc = crc8_table[crc ^ message[i]];\n+\treturn crc;\n+}\n+\n+/*\n+ * The atomic exchange test sets up a token in memory and\n+ * then spins up multiple lcores whose job is to generate\n+ * new tokens, exchange that new token for the old one held\n+ * in memory, and then verify that the old token is still\n+ * valid (i.e. the exchange did not corrupt the token).\n+ *\n+ * A token is made up of random data and 8 bits of crc\n+ * covering that random data.  The following is an example\n+ * of a 64bit token.\n+ *\n+ * +------------+------------+\n+ * | 63      56 | 55       0 |\n+ * +------------+------------+\n+ * |    CRC8    |    Data    |\n+ * +------------+------------+\n+ */\n+static int\n+test_atomic_exchange(__attribute__((unused)) void *arg)\n+{\n+\trte_u16_t nt16, ot16; /* new token, old token */\n+\trte_u32_t nt32, ot32;\n+\trte_u64_t nt64, ot64;\n+\n+\t/* Wait until all of the other threads have been dispatched */\n+\twhile (rte_atomic32_read(&synchro) == 0)\n+\t\t;\n+\n+\t/*\n+\t * Let the battle begin! Every thread attempts to steal the current\n+\t * token with an atomic exchange operation and install its own newly\n+\t * generated token. If the old token is valid (i.e. it has the\n+\t * appropriate crc32 hash for the data) then the test iteration has\n+\t * passed.  If the token is invalid, increment the counter.\n+\t */\n+\tfor (int i = 0; i < N; i++) {\n+\n+\t\t/* Test 64bit Atomic Exchange */\n+\t\tnt64.u64 = rte_rand();\n+\t\tnt64.u8[7] = get_crc8(&nt64.u8[0], sizeof(nt64) - 1);\n+\t\tot64.u64 = rte_atomic64_exchange(&token64, nt64.u64);\n+\t\tif (ot64.u8[7] != get_crc8(&ot64.u8[0], sizeof(ot64) - 1))\n+\t\t\trte_atomic64_inc(&count);\n+\n+\t\t/* Test 32bit Atomic Exchange */\n+\t\tnt32.u32 = (uint32_t)rte_rand();\n+\t\tnt32.u8[3] = get_crc8(&nt32.u8[0], sizeof(nt32) - 1);\n+\t\tot32.u32 = rte_atomic32_exchange(&token32, nt32.u32);\n+\t\tif (ot32.u8[3] != get_crc8(&ot32.u8[0], sizeof(ot32) - 1))\n+\t\t\trte_atomic64_inc(&count);\n+\n+\t\t/* Test 16bit Atomic Exchange */\n+\t\tnt16.u16 = (uint16_t)rte_rand();\n+\t\tnt16.u8[1] = get_crc8(&nt16.u8[0], sizeof(nt16) - 1);\n+\t\tot16.u16 = rte_atomic16_exchange(&token16, nt16.u16);\n+\t\tif (ot16.u8[1] != get_crc8(&ot16.u8[0], sizeof(ot16) - 1))\n+\t\t\trte_atomic64_inc(&count);\n+\t}\n+\n+\treturn 0;\n+}\n+\n+\n static int\n test_atomic(void)\n {\n@@ -340,6 +477,38 @@ test_atomic(void)\n \t\treturn -1;\n \t}\n \n+\t/*\n+\t * Test 16/32/64bit atomic exchange.\n+\t */\n+\trte_u64_t t;\n+\n+\tprintf(\"exchange test\\n\");\n+\n+\trte_atomic32_clear(&synchro);\n+\trte_atomic64_clear(&count);\n+\n+\t/* Generate the CRC8 lookup table */\n+\tbuild_crc8_table();\n+\n+\t/* Create the initial tokens used by the test */\n+\tt.u64 = rte_rand();\n+\ttoken16 = (get_crc8(&t.u8[0], sizeof(token16) - 1) << 8)\n+\t\t| (t.u16[0] & 0x00ff);\n+\ttoken32 = ((uint32_t)get_crc8(&t.u8[0], sizeof(token32) - 1) << 24)\n+\t\t| (t.u32[0] & 0x00ffffff);\n+\ttoken64 = ((uint64_t)get_crc8(&t.u8[0], sizeof(token64) - 1) << 56)\n+\t\t| (t.u64 & 0x00ffffffffffffff);\n+\n+\trte_eal_mp_remote_launch(test_atomic_exchange, NULL, SKIP_MASTER);\n+\trte_atomic32_set(&synchro, 1);\n+\trte_eal_mp_wait_lcore();\n+\trte_atomic32_clear(&synchro);\n+\n+\tif (rte_atomic64_read(&count) > 0) {\n+\t\tprintf(\"Atomic exchange test failed\\n\");\n+\t\treturn -1;\n+\t}\n+\n \treturn 0;\n }\n \n",
    "prefixes": [
        "v3"
    ]
}