get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 40924,
    "url": "https://patches.dpdk.org/api/patches/40924/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1528455078-328182-4-git-send-email-yipeng1.wang@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": "<1528455078-328182-4-git-send-email-yipeng1.wang@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1528455078-328182-4-git-send-email-yipeng1.wang@intel.com",
    "date": "2018-06-08T10:51:18",
    "name": "[dpdk-dev,v1,3/3] hash: add new API function to query the key count",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "a7b9bd86d114f82679f091a5883251d6555b206c",
    "submitter": {
        "id": 754,
        "url": "https://patches.dpdk.org/api/people/754/?format=api",
        "name": "Wang, Yipeng1",
        "email": "yipeng1.wang@intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1528455078-328182-4-git-send-email-yipeng1.wang@intel.com/mbox/",
    "series": [
        {
            "id": 62,
            "url": "https://patches.dpdk.org/api/series/62/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=62",
            "date": "2018-06-08T10:51:15",
            "name": "Add read-write concurrency to rte_hash library",
            "version": 1,
            "mbox": "https://patches.dpdk.org/series/62/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/40924/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/40924/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 ECAE01CDEB;\n\tFri,  8 Jun 2018 19:56:46 +0200 (CEST)",
            "from mga03.intel.com (mga03.intel.com [134.134.136.65])\n\tby dpdk.org (Postfix) with ESMTP id 33B5D1BB4F\n\tfor <dev@dpdk.org>; Fri,  8 Jun 2018 19:56:42 +0200 (CEST)",
            "from fmsmga002.fm.intel.com ([10.253.24.26])\n\tby orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t08 Jun 2018 10:56:37 -0700",
            "from skx-yipeng.jf.intel.com ([10.54.81.175])\n\tby fmsmga002.fm.intel.com with ESMTP; 08 Jun 2018 10:56:37 -0700"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.49,490,1520924400\"; d=\"scan'208\";a=\"55270349\"",
        "From": "Yipeng Wang <yipeng1.wang@intel.com>",
        "To": "pablo.de.lara.guarch@intel.com",
        "Cc": "dev@dpdk.org, yipeng1.wang@intel.com, john.mcnamara@intel.com,\n\tbruce.richardson@intel.com, honnappa.nagarahalli@arm.com,\n\tvguvva@caviumnetworks.com, brijesh.s.singh@gmail.com",
        "Date": "Fri,  8 Jun 2018 03:51:18 -0700",
        "Message-Id": "<1528455078-328182-4-git-send-email-yipeng1.wang@intel.com>",
        "X-Mailer": "git-send-email 2.7.4",
        "In-Reply-To": "<1528455078-328182-1-git-send-email-yipeng1.wang@intel.com>",
        "References": "<1528455078-328182-1-git-send-email-yipeng1.wang@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v1 3/3] hash: add new API function to query the\n\tkey count",
        "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": "Add a new function, rte_hash_count, to return the number of keys that\nare currently stored in the hash table. Corresponding test functions are\nadded into hash_test and hash_multiwriter test.\n\nSigned-off-by: Yipeng Wang <yipeng1.wang@intel.com>\n---\n lib/librte_hash/rte_cuckoo_hash.c    | 39 +++++++++++++++++++++++++++++++-----\n lib/librte_hash/rte_hash.h           | 11 ++++++++++\n lib/librte_hash/rte_hash_version.map |  8 ++++++++\n test/test/test_hash.c                | 12 +++++++++++\n test/test/test_hash_multiwriter.c    |  9 +++++++++\n 5 files changed, 74 insertions(+), 5 deletions(-)",
    "diff": "diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c\nindex a5bb4d4..3dff871 100644\n--- a/lib/librte_hash/rte_cuckoo_hash.c\n+++ b/lib/librte_hash/rte_cuckoo_hash.c\n@@ -133,13 +133,13 @@ rte_hash_create(const struct rte_hash_parameters *params)\n \t\t * except for the first cache\n \t\t */\n \t\tnum_key_slots = params->entries + (RTE_MAX_LCORE - 1) *\n-\t\t\t\t\tLCORE_CACHE_SIZE + 1;\n+\t\t\t\t\t(LCORE_CACHE_SIZE - 1) + 1;\n \telse\n \t\tnum_key_slots = params->entries + 1;\n \n \tsnprintf(ring_name, sizeof(ring_name), \"HT_%s\", params->name);\n \t/* Create ring (Dummy slot index is not enqueued) */\n-\tr = rte_ring_create(ring_name, rte_align32pow2(num_key_slots - 1),\n+\tr = rte_ring_create(ring_name, rte_align32pow2(num_key_slots),\n \t\t\tparams->socket_id, 0);\n \tif (r == NULL) {\n \t\tRTE_LOG(ERR, HASH, \"memory allocation failed\\n\");\n@@ -290,7 +290,7 @@ rte_hash_create(const struct rte_hash_parameters *params)\n \t}\n \n \t/* Populate free slots ring. Entry zero is reserved for key misses. */\n-\tfor (i = 1; i < params->entries + 1; i++)\n+\tfor (i = 1; i < num_key_slots; i++)\n \t\trte_ring_sp_enqueue(r, (void *)((uintptr_t) i));\n \n \tte->data = (void *) h;\n@@ -371,7 +371,7 @@ void\n rte_hash_reset(struct rte_hash *h)\n {\n \tvoid *ptr;\n-\tunsigned i;\n+\tuint32_t tot_ring_cnt, i;\n \n \tif (h == NULL)\n \t\treturn;\n@@ -384,7 +384,13 @@ rte_hash_reset(struct rte_hash *h)\n \t\trte_pause();\n \n \t/* Repopulate the free slots ring. Entry zero is reserved for key misses */\n-\tfor (i = 1; i < h->entries + 1; i++)\n+\tif (h->multi_writer_support)\n+\t\ttot_ring_cnt = h->entries + (RTE_MAX_LCORE - 1) *\n+\t\t\t\t\t(LCORE_CACHE_SIZE - 1);\n+\telse\n+\t\ttot_ring_cnt = h->entries;\n+\n+\tfor (i = 1; i < tot_ring_cnt + 1; i++)\n \t\trte_ring_sp_enqueue(h->free_slots, (void *)((uintptr_t) i));\n \n \tif (h->multi_writer_support) {\n@@ -394,6 +400,29 @@ rte_hash_reset(struct rte_hash *h)\n \t}\n }\n \n+int32_t\n+rte_hash_count(struct rte_hash *h)\n+{\n+\tuint32_t tot_ring_cnt, cached_cnt = 0;\n+\tuint32_t i, ret;\n+\n+\tif (h == NULL || h->free_slots == NULL)\n+\t\treturn -EINVAL;\n+\n+\tif (h->multi_writer_support) {\n+\t\ttot_ring_cnt = h->entries + (RTE_MAX_LCORE - 1) *\n+\t\t\t\t\t(LCORE_CACHE_SIZE - 1);\n+\t\tfor (i = 0; i < RTE_MAX_LCORE; i++)\n+\t\t\tcached_cnt += h->local_free_slots[i].len;\n+\n+\t\tret = tot_ring_cnt - rte_ring_count(h->free_slots) -\n+\t\t\t\t\t\t\t\tcached_cnt;\n+\t} else {\n+\t\ttot_ring_cnt = h->entries;\n+\t\tret = tot_ring_cnt - rte_ring_count(h->free_slots);\n+\t}\n+\treturn ret;\n+}\n \n static inline void\n __hash_rw_writer_lock(const struct rte_hash *h)\ndiff --git a/lib/librte_hash/rte_hash.h b/lib/librte_hash/rte_hash.h\nindex ecb49e4..b8f1f31 100644\n--- a/lib/librte_hash/rte_hash.h\n+++ b/lib/librte_hash/rte_hash.h\n@@ -127,6 +127,17 @@ void\n rte_hash_reset(struct rte_hash *h);\n \n /**\n+ * Return the number of keys in the hash table\n+ * @param h\n+ *  Hash table to query from\n+ * @return\n+ *   - -EINVAL if parameters are invalid\n+ *   - A value indicating how many keys inserted in the table.\n+ */\n+int32_t\n+rte_hash_count(struct rte_hash *h);\n+\n+/**\n  * Add a key-value pair to an existing hash table.\n  * This operation is not multi-thread safe\n  * and should only be called from one thread.\ndiff --git a/lib/librte_hash/rte_hash_version.map b/lib/librte_hash/rte_hash_version.map\nindex 52a2576..e216ac8 100644\n--- a/lib/librte_hash/rte_hash_version.map\n+++ b/lib/librte_hash/rte_hash_version.map\n@@ -45,3 +45,11 @@ DPDK_16.07 {\n \trte_hash_get_key_with_position;\n \n } DPDK_2.2;\n+\n+\n+DPDK_18.08 {\n+\tglobal:\n+\n+\trte_hash_count;\n+\n+} DPDK_16.07;\ndiff --git a/test/test/test_hash.c b/test/test/test_hash.c\nindex edf41f5..b3db9fd 100644\n--- a/test/test/test_hash.c\n+++ b/test/test/test_hash.c\n@@ -1103,6 +1103,7 @@ static int test_average_table_utilization(void)\n \tunsigned i, j;\n \tunsigned added_keys, average_keys_added = 0;\n \tint ret;\n+\tunsigned int cnt;\n \n \tprintf(\"\\n# Running test to determine average utilization\"\n \t       \"\\n  before adding elements begins to fail\\n\");\n@@ -1121,13 +1122,24 @@ static int test_average_table_utilization(void)\n \t\t\tfor (i = 0; i < ut_params.key_len; i++)\n \t\t\t\tsimple_key[i] = rte_rand() % 255;\n \t\t\tret = rte_hash_add_key(handle, simple_key);\n+\t\t\tif (ret < 0)\n+\t\t\t\tbreak;\n \t\t}\n+\n \t\tif (ret != -ENOSPC) {\n \t\t\tprintf(\"Unexpected error when adding keys\\n\");\n \t\t\trte_hash_free(handle);\n \t\t\treturn -1;\n \t\t}\n \n+\t\tcnt = rte_hash_count(handle);\n+\t\tif (cnt != added_keys) {\n+\t\t\tprintf(\"rte_hash_count returned wrong value %u, %u,\"\n+\t\t\t\t\t\"%u\\n\", j, added_keys, cnt);\n+\t\t\trte_hash_free(handle);\n+\t\t\treturn -1;\n+\t\t}\n+\n \t\taverage_keys_added += added_keys;\n \n \t\t/* Reset the table */\ndiff --git a/test/test/test_hash_multiwriter.c b/test/test/test_hash_multiwriter.c\nindex ef5fce3..ae3ce3b 100644\n--- a/test/test/test_hash_multiwriter.c\n+++ b/test/test/test_hash_multiwriter.c\n@@ -116,6 +116,7 @@ test_hash_multiwriter(void)\n \n \tuint32_t duplicated_keys = 0;\n \tuint32_t lost_keys = 0;\n+\tuint32_t count;\n \n \tsnprintf(name, 32, \"test%u\", calledCount++);\n \thash_params.name = name;\n@@ -163,6 +164,14 @@ test_hash_multiwriter(void)\n \t\t\t\t NULL, CALL_MASTER);\n \trte_eal_mp_wait_lcore();\n \n+\n+\tcount = rte_hash_count(handle);\n+\tif (count != rounded_nb_total_tsx_insertion) {\n+\t\tprintf(\"rte_hash_count returned wrong value %u, %d\\n\",\n+\t\t\t\trounded_nb_total_tsx_insertion, count);\n+\t\tgoto err3;\n+\t}\n+\n \twhile (rte_hash_iterate(handle, &next_key, &next_data, &iter) >= 0) {\n \t\t/* Search for the key in the list of keys added .*/\n \t\ti = *(const uint32_t *)next_key;\n",
    "prefixes": [
        "dpdk-dev",
        "v1",
        "3/3"
    ]
}