From patchwork Wed Oct 10 21:48:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Yipeng1" X-Patchwork-Id: 46531 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 49A4F1B187; Thu, 11 Oct 2018 06:52:58 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 896031B183 for ; Thu, 11 Oct 2018 06:52:56 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Oct 2018 21:52:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,367,1534834800"; d="scan'208";a="77895190" Received: from skx-yipeng.jf.intel.com ([10.54.81.175]) by fmsmga008.fm.intel.com with ESMTP; 10 Oct 2018 21:52:54 -0700 From: Yipeng Wang To: bruce.richardson@intel.com Cc: stephen@networkplumber.org, dev@dpdk.org, yipeng1.wang@intel.com, honnappa.nagarahalli@arm.com, sameh.gobriel@intel.com Date: Wed, 10 Oct 2018 14:48:03 -0700 Message-Id: <1539208085-30756-2-git-send-email-yipeng1.wang@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1539208085-30756-1-git-send-email-yipeng1.wang@intel.com> References: <1539208085-30756-1-git-send-email-yipeng1.wang@intel.com> Subject: [dpdk-dev] [PATCH v1 1/3] hash: fix unnecessary pause X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" There is a rte_pause in hash table reset function. Since the loop is not a polling loop on shared data structure, the rte_pause is not needed. Fixes: b26473ff8f4a ("hash: add reset function") Cc: stable@dpdk.org Signed-off-by: Yipeng Wang --- lib/librte_hash/rte_cuckoo_hash.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c index 750caf8..ea8107e 100644 --- a/lib/librte_hash/rte_cuckoo_hash.c +++ b/lib/librte_hash/rte_cuckoo_hash.c @@ -521,14 +521,14 @@ rte_hash_reset(struct rte_hash *h) /* clear the free ring */ while (rte_ring_dequeue(h->free_slots, &ptr) == 0) - rte_pause(); + continue; /* clear free extendable bucket ring and memory */ if (h->ext_table_support) { memset(h->buckets_ext, 0, h->num_buckets * sizeof(struct rte_hash_bucket)); while (rte_ring_dequeue(h->free_ext_bkts, &ptr) == 0) - rte_pause(); + continue; } /* Repopulate the free slots ring. Entry zero is reserved for key misses */ From patchwork Wed Oct 10 21:48:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Yipeng1" X-Patchwork-Id: 46532 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 330551B195; Thu, 11 Oct 2018 06:53:00 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 2C1B41B183 for ; Thu, 11 Oct 2018 06:52:57 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Oct 2018 21:52:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,367,1534834800"; d="scan'208";a="77895193" Received: from skx-yipeng.jf.intel.com ([10.54.81.175]) by fmsmga008.fm.intel.com with ESMTP; 10 Oct 2018 21:52:54 -0700 From: Yipeng Wang To: bruce.richardson@intel.com Cc: stephen@networkplumber.org, dev@dpdk.org, yipeng1.wang@intel.com, honnappa.nagarahalli@arm.com, sameh.gobriel@intel.com Date: Wed, 10 Oct 2018 14:48:04 -0700 Message-Id: <1539208085-30756-3-git-send-email-yipeng1.wang@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1539208085-30756-1-git-send-email-yipeng1.wang@intel.com> References: <1539208085-30756-1-git-send-email-yipeng1.wang@intel.com> Subject: [dpdk-dev] [PATCH v1 2/3] test/hash: change multiwriter test to use jhash X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" With sequential key, the test will cover more corner cases with jhash instead of crc hash, since jhash generates more random hash pattern on sequential key. It is useful for functional verification. Signed-off-by: Yipeng Wang --- test/test/test_hash_multiwriter.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/test/test/test_hash_multiwriter.c b/test/test/test_hash_multiwriter.c index 6a3eb10..7f2deae 100644 --- a/test/test/test_hash_multiwriter.c +++ b/test/test/test_hash_multiwriter.c @@ -12,6 +12,7 @@ #include #include #include +#include #include "test.h" @@ -95,7 +96,7 @@ test_hash_multiwriter_worker(void *arg) static int -test_hash_multiwriter(void) +test_hash_multiwriter(int use_jhash) { unsigned int i, rounded_nb_total_tsx_insertion; static unsigned calledCount = 1; @@ -108,10 +109,14 @@ test_hash_multiwriter(void) struct rte_hash_parameters hash_params = { .entries = nb_entries, .key_len = sizeof(uint32_t), - .hash_func = rte_hash_crc, .hash_func_init_val = 0, .socket_id = rte_socket_id(), }; + if (use_jhash) + hash_params.hash_func = rte_jhash; + else + hash_params.hash_func = rte_hash_crc; + if (use_htm) hash_params.extra_flag = RTE_HASH_EXTRA_FLAGS_TRANS_MEM_SUPPORT @@ -259,6 +264,8 @@ test_hash_multiwriter(void) static int test_hash_multiwriter_main(void) { + int use_jhash = 1; + if (rte_lcore_count() == 1) { printf("More than one lcore is required to do multiwriter test\n"); return 0; @@ -278,13 +285,13 @@ test_hash_multiwriter_main(void) printf("Test multi-writer with Hardware transactional memory\n"); use_htm = 1; - if (test_hash_multiwriter() < 0) + if (test_hash_multiwriter(use_jhash) < 0) return -1; } printf("Test multi-writer without Hardware transactional memory\n"); use_htm = 0; - if (test_hash_multiwriter() < 0) + if (test_hash_multiwriter(use_jhash) < 0) return -1; return 0; From patchwork Wed Oct 10 21:48:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Yipeng1" X-Patchwork-Id: 46533 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7F5021B2AB; Thu, 11 Oct 2018 06:53:02 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id C70B01B185 for ; Thu, 11 Oct 2018 06:52:57 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Oct 2018 21:52:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,367,1534834800"; d="scan'208";a="77895196" Received: from skx-yipeng.jf.intel.com ([10.54.81.175]) by fmsmga008.fm.intel.com with ESMTP; 10 Oct 2018 21:52:54 -0700 From: Yipeng Wang To: bruce.richardson@intel.com Cc: stephen@networkplumber.org, dev@dpdk.org, yipeng1.wang@intel.com, honnappa.nagarahalli@arm.com, sameh.gobriel@intel.com Date: Wed, 10 Oct 2018 14:48:05 -0700 Message-Id: <1539208085-30756-4-git-send-email-yipeng1.wang@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1539208085-30756-1-git-send-email-yipeng1.wang@intel.com> References: <1539208085-30756-1-git-send-email-yipeng1.wang@intel.com> Subject: [dpdk-dev] [PATCH v1 3/3] test/hash: add readwrite test for ext table X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This commit improves the readwrite test to consider extendable table feature and add more functional tests to cover more corner cases. Signed-off-by: Yipeng Wang --- test/test/test_hash_readwrite.c | 70 ++++++++++++++++++++++++++++++++++------- 1 file changed, 58 insertions(+), 12 deletions(-) diff --git a/test/test/test_hash_readwrite.c b/test/test/test_hash_readwrite.c index 2a4f7b9..1cb00ad 100644 --- a/test/test/test_hash_readwrite.c +++ b/test/test/test_hash_readwrite.c @@ -21,6 +21,8 @@ #define TOTAL_ENTRY (16*1024*1024) #define TOTAL_INSERT (15*1024*1024) +#define TOTAL_INSERT_EXT (16*1024*1024) + #define NUM_TEST 3 unsigned int core_cnt[NUM_TEST] = {2, 4, 8}; @@ -59,8 +61,10 @@ test_hash_readwrite_worker(__attribute__((unused)) void *arg) uint64_t i, offset; uint32_t lcore_id = rte_lcore_id(); uint64_t begin, cycles; - int ret; + int *ret; + ret = rte_malloc(NULL, sizeof(int) * + tbl_rw_test_param.num_insert, 0); for (i = 0; i < rte_lcore_count(); i++) { if (slave_core_ids[i] == lcore_id) break; @@ -79,13 +83,30 @@ test_hash_readwrite_worker(__attribute__((unused)) void *arg) tbl_rw_test_param.keys + i) > 0) break; - ret = rte_hash_add_key(tbl_rw_test_param.h, + ret[i - offset] = rte_hash_add_key(tbl_rw_test_param.h, tbl_rw_test_param.keys + i); - if (ret < 0) + if (ret[i - offset] < 0) + break; + + /* lookup a random key */ + uint32_t rand = rte_rand() % (i + 1 - offset); + + if (rte_hash_lookup(tbl_rw_test_param.h, + tbl_rw_test_param.keys + rand) != ret[rand]) + break; + + + if (rte_hash_del_key(tbl_rw_test_param.h, + tbl_rw_test_param.keys + rand) != ret[rand]) + break; + + ret[rand] = rte_hash_add_key(tbl_rw_test_param.h, + tbl_rw_test_param.keys + rand); + if (ret[rand] < 0) break; if (rte_hash_lookup(tbl_rw_test_param.h, - tbl_rw_test_param.keys + i) != ret) + tbl_rw_test_param.keys + rand) != ret[rand]) break; } @@ -100,7 +121,7 @@ test_hash_readwrite_worker(__attribute__((unused)) void *arg) } static int -init_params(int use_htm, int use_jhash) +init_params(int use_ext, int use_htm, int use_jhash) { unsigned int i; @@ -127,6 +148,13 @@ init_params(int use_htm, int use_jhash) hash_params.extra_flag = RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY; + if (use_ext) + hash_params.extra_flag |= + RTE_HASH_EXTRA_FLAGS_EXT_TABLE; + else + hash_params.extra_flag &= + ~RTE_HASH_EXTRA_FLAGS_EXT_TABLE; + hash_params.name = "tests"; handle = rte_hash_create(&hash_params); @@ -165,7 +193,7 @@ init_params(int use_htm, int use_jhash) } static int -test_hash_readwrite_functional(int use_htm) +test_hash_readwrite_functional(int use_ext, int use_htm) { unsigned int i; const void *next_key; @@ -176,6 +204,7 @@ test_hash_readwrite_functional(int use_htm) uint32_t lost_keys = 0; int use_jhash = 1; int slave_cnt = rte_lcore_count() - 1; + uint32_t tot_insert = 0; rte_atomic64_init(&gcycles); rte_atomic64_clear(&gcycles); @@ -183,11 +212,16 @@ test_hash_readwrite_functional(int use_htm) rte_atomic64_init(&ginsertions); rte_atomic64_clear(&ginsertions); - if (init_params(use_htm, use_jhash) != 0) + if (init_params(use_ext, use_htm, use_jhash) != 0) goto err; + if (use_ext) + tot_insert = TOTAL_INSERT_EXT; + else + tot_insert = TOTAL_INSERT; + tbl_rw_test_param.num_insert = - TOTAL_INSERT / slave_cnt; + tot_insert / slave_cnt; tbl_rw_test_param.rounded_tot_insert = tbl_rw_test_param.num_insert @@ -343,7 +377,7 @@ test_hash_readwrite_perf(struct perf *perf_results, int use_htm, rte_atomic64_init(&gwrite_cycles); rte_atomic64_clear(&gwrite_cycles); - if (init_params(use_htm, use_jhash) != 0) + if (init_params(0, use_htm, use_jhash) != 0) goto err; /* @@ -577,7 +611,7 @@ test_hash_readwrite_main(void) * than writer threads. This is to timing either reader threads or * writer threads for performance numbers. */ - int use_htm, reader_faster; + int use_htm, use_ext, reader_faster; unsigned int i = 0, core_id = 0; if (rte_lcore_count() <= 2) { @@ -600,7 +634,13 @@ test_hash_readwrite_main(void) printf("Test read-write with Hardware transactional memory\n"); use_htm = 1; - if (test_hash_readwrite_functional(use_htm) < 0) + use_ext = 0; + + if (test_hash_readwrite_functional(use_ext, use_htm) < 0) + return -1; + + use_ext = 1; + if (test_hash_readwrite_functional(use_ext, use_htm) < 0) return -1; reader_faster = 1; @@ -619,8 +659,14 @@ test_hash_readwrite_main(void) printf("Test read-write without Hardware transactional memory\n"); use_htm = 0; - if (test_hash_readwrite_functional(use_htm) < 0) + use_ext = 0; + if (test_hash_readwrite_functional(use_ext, use_htm) < 0) return -1; + + use_ext = 1; + if (test_hash_readwrite_functional(use_ext, use_htm) < 0) + return -1; + reader_faster = 1; if (test_hash_readwrite_perf(&non_htm_results, use_htm, reader_faster) < 0)