From patchwork Fri Oct 26 09:53:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Yipeng1" X-Patchwork-Id: 47481 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 E14A75323; Fri, 26 Oct 2018 18:59:15 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 3660C2E81 for ; Fri, 26 Oct 2018 18:59:10 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Oct 2018 09:59:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,428,1534834800"; d="scan'208";a="85849485" Received: from skx-yipeng.jf.intel.com ([10.54.81.175]) by orsmga006.jf.intel.com with ESMTP; 26 Oct 2018 09:59:08 -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: Fri, 26 Oct 2018 02:53:41 -0700 Message-Id: <1540547626-197189-2-git-send-email-yipeng1.wang@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1540547626-197189-1-git-send-email-yipeng1.wang@intel.com> References: <1540494678-64299-1-git-send-email-yipeng1.wang@intel.com> <1540547626-197189-1-git-send-email-yipeng1.wang@intel.com> Subject: [dpdk-dev] [PATCH v4 1/6] 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 Acked-by: Bruce Richardson --- lib/librte_hash/rte_cuckoo_hash.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c index 0648a22..5ddcccd 100644 --- a/lib/librte_hash/rte_cuckoo_hash.c +++ b/lib/librte_hash/rte_cuckoo_hash.c @@ -27,7 +27,6 @@ #include #include #include -#include #include "rte_hash.h" #include "rte_cuckoo_hash.h" @@ -574,14 +573,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 Fri Oct 26 09:53:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Yipeng1" X-Patchwork-Id: 47482 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 23268559A; Fri, 26 Oct 2018 18:59:18 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id A37772C52 for ; Fri, 26 Oct 2018 18:59:10 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Oct 2018 09:59:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,428,1534834800"; d="scan'208";a="85849488" Received: from skx-yipeng.jf.intel.com ([10.54.81.175]) by orsmga006.jf.intel.com with ESMTP; 26 Oct 2018 09:59:08 -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: Fri, 26 Oct 2018 02:53:42 -0700 Message-Id: <1540547626-197189-3-git-send-email-yipeng1.wang@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1540547626-197189-1-git-send-email-yipeng1.wang@intel.com> References: <1540494678-64299-1-git-send-email-yipeng1.wang@intel.com> <1540547626-197189-1-git-send-email-yipeng1.wang@intel.com> Subject: [dpdk-dev] [PATCH v4 2/6] 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 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test/test_hash_multiwriter.c b/test/test/test_hash_multiwriter.c index 6a3eb10..d447f6d 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" @@ -108,7 +109,7 @@ 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 = rte_jhash, .hash_func_init_val = 0, .socket_id = rte_socket_id(), }; From patchwork Fri Oct 26 09:53:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Yipeng1" X-Patchwork-Id: 47483 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 65B545689; Fri, 26 Oct 2018 18:59:20 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id CD3892E81 for ; Fri, 26 Oct 2018 18:59:10 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Oct 2018 09:59:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,428,1534834800"; d="scan'208";a="85849491" Received: from skx-yipeng.jf.intel.com ([10.54.81.175]) by orsmga006.jf.intel.com with ESMTP; 26 Oct 2018 09:59:08 -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: Fri, 26 Oct 2018 02:53:43 -0700 Message-Id: <1540547626-197189-4-git-send-email-yipeng1.wang@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1540547626-197189-1-git-send-email-yipeng1.wang@intel.com> References: <1540494678-64299-1-git-send-email-yipeng1.wang@intel.com> <1540547626-197189-1-git-send-email-yipeng1.wang@intel.com> Subject: [dpdk-dev] [PATCH v4 3/6] test/hash: test more corner cases in unit test 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 unit test to cover more corner cases and reduces the testing time by reducing the total key count. Signed-off-by: Yipeng Wang Acked-by: Bruce Richardson --- test/test/test_hash_readwrite.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/test/test/test_hash_readwrite.c b/test/test/test_hash_readwrite.c index a8fadd0..26e802c 100644 --- a/test/test/test_hash_readwrite.c +++ b/test/test/test_hash_readwrite.c @@ -18,8 +18,8 @@ #define RTE_RWTEST_FAIL 0 -#define TOTAL_ENTRY (16*1024*1024) -#define TOTAL_INSERT (15*1024*1024) +#define TOTAL_ENTRY (5*1024*1024) +#define TOTAL_INSERT (4.5*1024*1024) #define NUM_TEST 3 unsigned int core_cnt[NUM_TEST] = {2, 4, 8}; @@ -59,8 +59,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 +81,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; } @@ -96,6 +115,7 @@ test_hash_readwrite_worker(__attribute__((unused)) void *arg) for (; i < offset + tbl_rw_test_param.num_insert; i++) tbl_rw_test_param.keys[i] = RTE_RWTEST_FAIL; + rte_free(ret); return 0; } From patchwork Fri Oct 26 09:53:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Yipeng1" X-Patchwork-Id: 47484 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 3B98E58F6; Fri, 26 Oct 2018 18:59:22 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 45F972C52 for ; Fri, 26 Oct 2018 18:59:11 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Oct 2018 09:59:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,428,1534834800"; d="scan'208";a="85849493" Received: from skx-yipeng.jf.intel.com ([10.54.81.175]) by orsmga006.jf.intel.com with ESMTP; 26 Oct 2018 09:59:08 -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: Fri, 26 Oct 2018 02:53:44 -0700 Message-Id: <1540547626-197189-5-git-send-email-yipeng1.wang@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1540547626-197189-1-git-send-email-yipeng1.wang@intel.com> References: <1540494678-64299-1-git-send-email-yipeng1.wang@intel.com> <1540547626-197189-1-git-send-email-yipeng1.wang@intel.com> Subject: [dpdk-dev] [PATCH v4 4/6] 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. Signed-off-by: Yipeng Wang Acked-by: Bruce Richardson --- test/test/test_hash_readwrite.c | 42 +++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/test/test/test_hash_readwrite.c b/test/test/test_hash_readwrite.c index 26e802c..01f986c 100644 --- a/test/test/test_hash_readwrite.c +++ b/test/test/test_hash_readwrite.c @@ -20,6 +20,7 @@ #define TOTAL_ENTRY (5*1024*1024) #define TOTAL_INSERT (4.5*1024*1024) +#define TOTAL_INSERT_EXT (5*1024*1024) #define NUM_TEST 3 unsigned int core_cnt[NUM_TEST] = {2, 4, 8}; @@ -120,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; @@ -149,6 +150,13 @@ init_params(int use_htm, int use_jhash) RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY | RTE_HASH_EXTRA_FLAGS_MULTI_WRITER_ADD; + 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); @@ -187,7 +195,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; @@ -198,6 +206,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); @@ -205,11 +214,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 @@ -365,7 +379,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; /* @@ -599,7 +613,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) { @@ -622,7 +636,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; @@ -641,8 +661,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) From patchwork Fri Oct 26 09:53:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Yipeng1" X-Patchwork-Id: 47485 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 797425A6A; Fri, 26 Oct 2018 18:59:24 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 6F7432E81 for ; Fri, 26 Oct 2018 18:59:11 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Oct 2018 09:59:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,428,1534834800"; d="scan'208";a="85849498" Received: from skx-yipeng.jf.intel.com ([10.54.81.175]) by orsmga006.jf.intel.com with ESMTP; 26 Oct 2018 09:59:08 -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: Fri, 26 Oct 2018 02:53:45 -0700 Message-Id: <1540547626-197189-6-git-send-email-yipeng1.wang@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1540547626-197189-1-git-send-email-yipeng1.wang@intel.com> References: <1540494678-64299-1-git-send-email-yipeng1.wang@intel.com> <1540547626-197189-1-git-send-email-yipeng1.wang@intel.com> Subject: [dpdk-dev] [PATCH v4 5/6] test/hash: remove hash scaling unit test 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" The hash scaling unit test is not really needed any more since the multi-writer is supported now inside the library and it is tested by multi-writer unit test. Signed-off-by: Yipeng Wang Acked-by: Bruce Richardson --- test/test/Makefile | 1 - test/test/autotest_data.py | 6 -- test/test/meson.build | 2 - test/test/test_hash_scaling.c | 191 ------------------------------------------ 4 files changed, 200 deletions(-) delete mode 100644 test/test/test_hash_scaling.c diff --git a/test/test/Makefile b/test/test/Makefile index 1b5c070..6b77e15 100644 --- a/test/test/Makefile +++ b/test/test/Makefile @@ -113,7 +113,6 @@ SRCS-$(CONFIG_RTE_LIBRTE_HASH) += test_hash.c SRCS-$(CONFIG_RTE_LIBRTE_HASH) += test_thash.c SRCS-$(CONFIG_RTE_LIBRTE_HASH) += test_hash_perf.c SRCS-$(CONFIG_RTE_LIBRTE_HASH) += test_hash_functions.c -SRCS-$(CONFIG_RTE_LIBRTE_HASH) += test_hash_scaling.c SRCS-$(CONFIG_RTE_LIBRTE_HASH) += test_hash_multiwriter.c SRCS-$(CONFIG_RTE_LIBRTE_HASH) += test_hash_readwrite.c SRCS-$(CONFIG_RTE_LIBRTE_HASH) += test_hash_readwrite_lf.c diff --git a/test/test/autotest_data.py b/test/test/autotest_data.py index 4eae588..9265617 100644 --- a/test/test/autotest_data.py +++ b/test/test/autotest_data.py @@ -345,12 +345,6 @@ "Report": None, }, { - "Name": "Hash scaling autotest", - "Command": "hash_scaling_autotest", - "Func": default_autotest, - "Report": None, - }, - { "Name": "Hash multiwriter autotest", "Command": "hash_multiwriter_autotest", "Func": default_autotest, diff --git a/test/test/meson.build b/test/test/meson.build index faef5a4..7ebe9ab 100644 --- a/test/test/meson.build +++ b/test/test/meson.build @@ -47,7 +47,6 @@ test_sources = files('commands.c', 'test_hash_readwrite.c', 'test_hash_perf.c', 'test_hash_readwrite_lf.c', - 'test_hash_scaling.c', 'test_interrupts.c', 'test_kni.c', 'test_kvargs.c', @@ -170,7 +169,6 @@ test_names = [ 'external_mem_autotest', 'func_reentrancy_autotest', 'flow_classify_autotest', - 'hash_scaling_autotest', 'hash_autotest', 'hash_functions_autotest', 'hash_multiwriter_autotest', diff --git a/test/test/test_hash_scaling.c b/test/test/test_hash_scaling.c deleted file mode 100644 index 07765a7..0000000 --- a/test/test/test_hash_scaling.c +++ /dev/null @@ -1,191 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2015 Intel Corporation - */ - -#include - -#include -#include -#include -#include -#include - -#include "test.h" - -/* - * Check condition and return an error if true. Assumes that "handle" is the - * name of the hash structure pointer to be freed. - */ -#define RETURN_IF_ERROR(cond, str, ...) do { \ - if (cond) { \ - printf("ERROR line %d: " str "\n", __LINE__, \ - ##__VA_ARGS__); \ - if (handle) \ - rte_hash_free(handle); \ - return -1; \ - } \ -} while (0) - -enum locking_mode_t { - NORMAL_LOCK, - LOCK_ELISION, - NULL_LOCK -}; - -struct { - uint32_t num_iterations; - struct rte_hash *h; - rte_spinlock_t *lock; - int locking_mode; -} tbl_scaling_test_params; - -static rte_atomic64_t gcycles; - -static int test_hash_scaling_worker(__attribute__((unused)) void *arg) -{ - uint64_t i, key; - uint32_t thr_id = rte_sys_gettid(); - uint64_t begin, cycles = 0; - - switch (tbl_scaling_test_params.locking_mode) { - - case NORMAL_LOCK: - - for (i = 0; i < tbl_scaling_test_params.num_iterations; i++) { - /* different threads get different keys because - we use the thread-id in the key computation - */ - key = rte_hash_crc(&i, sizeof(i), thr_id); - begin = rte_rdtsc_precise(); - rte_spinlock_lock(tbl_scaling_test_params.lock); - rte_hash_add_key(tbl_scaling_test_params.h, &key); - rte_spinlock_unlock(tbl_scaling_test_params.lock); - cycles += rte_rdtsc_precise() - begin; - } - break; - - case LOCK_ELISION: - - for (i = 0; i < tbl_scaling_test_params.num_iterations; i++) { - key = rte_hash_crc(&i, sizeof(i), thr_id); - begin = rte_rdtsc_precise(); - rte_spinlock_lock_tm(tbl_scaling_test_params.lock); - rte_hash_add_key(tbl_scaling_test_params.h, &key); - rte_spinlock_unlock_tm(tbl_scaling_test_params.lock); - cycles += rte_rdtsc_precise() - begin; - } - break; - - default: - - for (i = 0; i < tbl_scaling_test_params.num_iterations; i++) { - key = rte_hash_crc(&i, sizeof(i), thr_id); - begin = rte_rdtsc_precise(); - rte_hash_add_key(tbl_scaling_test_params.h, &key); - cycles += rte_rdtsc_precise() - begin; - } - } - - rte_atomic64_add(&gcycles, cycles); - - return 0; -} - -/* - * Do scalability perf tests. - */ -static int -test_hash_scaling(int locking_mode) -{ - static unsigned calledCount = 1; - uint32_t num_iterations = 1024*1024; - uint64_t i, key; - struct rte_hash_parameters hash_params = { - .entries = num_iterations*2, - .key_len = sizeof(key), - .hash_func = rte_hash_crc, - .hash_func_init_val = 0, - .socket_id = rte_socket_id(), - .extra_flag = RTE_HASH_EXTRA_FLAGS_TRANS_MEM_SUPPORT - }; - struct rte_hash *handle; - char name[RTE_HASH_NAMESIZE]; - rte_spinlock_t lock; - - rte_spinlock_init(&lock); - - snprintf(name, 32, "test%u", calledCount++); - hash_params.name = name; - - handle = rte_hash_create(&hash_params); - RETURN_IF_ERROR(handle == NULL, "hash creation failed"); - - tbl_scaling_test_params.num_iterations = - num_iterations/rte_lcore_count(); - tbl_scaling_test_params.h = handle; - tbl_scaling_test_params.lock = &lock; - tbl_scaling_test_params.locking_mode = locking_mode; - - rte_atomic64_init(&gcycles); - rte_atomic64_clear(&gcycles); - - /* fill up to initial size */ - for (i = 0; i < num_iterations; i++) { - key = rte_hash_crc(&i, sizeof(i), 0xabcdabcd); - rte_hash_add_key(tbl_scaling_test_params.h, &key); - } - - rte_eal_mp_remote_launch(test_hash_scaling_worker, NULL, CALL_MASTER); - rte_eal_mp_wait_lcore(); - - unsigned long long int cycles_per_operation = - rte_atomic64_read(&gcycles)/ - (tbl_scaling_test_params.num_iterations*rte_lcore_count()); - const char *lock_name; - - switch (locking_mode) { - case NORMAL_LOCK: - lock_name = "normal spinlock"; - break; - case LOCK_ELISION: - lock_name = "lock elision"; - break; - default: - lock_name = "null lock"; - } - printf("--------------------------------------------------------\n"); - printf("Cores: %d; %s mode -> cycles per operation: %llu\n", - rte_lcore_count(), lock_name, cycles_per_operation); - printf("--------------------------------------------------------\n"); - /* CSV output */ - printf(">>>%d,%s,%llu\n", rte_lcore_count(), lock_name, - cycles_per_operation); - - rte_hash_free(handle); - return 0; -} - -static int -test_hash_scaling_main(void) -{ - int r = 0; - - if (rte_lcore_count() == 1) - r = test_hash_scaling(NULL_LOCK); - - if (r == 0) - r = test_hash_scaling(NORMAL_LOCK); - - if (!rte_tm_supported()) { - printf("Hardware transactional memory (lock elision) is NOT supported\n"); - return r; - } - printf("Hardware transactional memory (lock elision) is supported\n"); - - if (r == 0) - r = test_hash_scaling(LOCK_ELISION); - - return r; -} - -REGISTER_TEST_COMMAND(hash_scaling_autotest, test_hash_scaling_main); From patchwork Fri Oct 26 09:53:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Yipeng1" X-Patchwork-Id: 47480 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 48EE94CE4; Fri, 26 Oct 2018 18:59:13 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 139542C52 for ; Fri, 26 Oct 2018 18:59:09 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Oct 2018 09:59:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,428,1534834800"; d="scan'208";a="85849500" Received: from skx-yipeng.jf.intel.com ([10.54.81.175]) by orsmga006.jf.intel.com with ESMTP; 26 Oct 2018 09:59:08 -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: Fri, 26 Oct 2018 02:53:46 -0700 Message-Id: <1540547626-197189-7-git-send-email-yipeng1.wang@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1540547626-197189-1-git-send-email-yipeng1.wang@intel.com> References: <1540494678-64299-1-git-send-email-yipeng1.wang@intel.com> <1540547626-197189-1-git-send-email-yipeng1.wang@intel.com> Subject: [dpdk-dev] [PATCH v4 6/6] test/hash: fix to add read-write test to autotest 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" Add read-write concurrency test to meson and autotest file. Fixes: 0eb3726ebcf1 ("test/hash: add test for read/write concurrency") Cc: stable@dpdk.org Signed-off-by: Yipeng Wang --- test/test/autotest_data.py | 6 ++++++ test/test/meson.build | 1 + 2 files changed, 7 insertions(+) diff --git a/test/test/autotest_data.py b/test/test/autotest_data.py index 9265617..0df686a 100644 --- a/test/test/autotest_data.py +++ b/test/test/autotest_data.py @@ -574,6 +574,12 @@ "Report": None, }, { + "Name": "Hash read-write concurrency autotest", + "Command": "hash_readwrite_autotest", + "Func": default_autotest, + "Report": None, + }, + { "Name": "Hash read-write lock-free concurrency autotest", "Command": "hash_readwrite_lf_autotest", "Func": default_autotest, diff --git a/test/test/meson.build b/test/test/meson.build index 7ebe9ab..1c1fcd7 100644 --- a/test/test/meson.build +++ b/test/test/meson.build @@ -173,6 +173,7 @@ test_names = [ 'hash_functions_autotest', 'hash_multiwriter_autotest', 'hash_perf_autotest', + 'hash_readwrite_autotest', 'hash_readwrite_lf_autotest', 'interrupt_autotest', 'kni_autotest',