From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4BB14A2EEB for ; Tue, 10 Sep 2019 05:37:14 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3169A1EB02; Tue, 10 Sep 2019 05:37:14 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by dpdk.org (Postfix) with ESMTP id 48DBE1EB02 for ; Tue, 10 Sep 2019 05:37:13 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AA2C71570; Mon, 9 Sep 2019 20:37:12 -0700 (PDT) Received: from net-arm-thunderx2-01.test.ast.arm.com (net-arm-thunderx2-01.shanghai.arm.com [10.169.40.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id A8A3A3F67D; Mon, 9 Sep 2019 20:37:11 -0700 (PDT) From: Joyce Kong To: stable@dpdk.org, ktraynor@redhat.com Cc: joyce@arm.com Date: Tue, 10 Sep 2019 11:36:59 +0800 Message-Id: <1568086619-5029-2-git-send-email-joyce.kong@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1568086619-5029-1-git-send-email-joyce.kong@arm.com> References: <1568086619-5029-1-git-send-email-joyce.kong@arm.com> Subject: [dpdk-stable] [PATCH 18.11 2/2] test/rwlock: amortize the cost of getting time X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" [ upstream commit 6fef1ae4fc109807d13de4235281960b3b1dfd51 ] Instead of getting timestamp per iteration, amortize its overhead can help to get more precise benchmarking results. Fixes: af75078fece3 ("first public release") Signed-off-by: Joyce Kong Acked-by: Konstantin Ananyev --- test/test/test_rwlock.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/test/test/test_rwlock.c b/test/test/test_rwlock.c index d654d48..7c9b919 100644 --- a/test/test/test_rwlock.c +++ b/test/test/test_rwlock.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -69,9 +70,9 @@ test_rwlock_per_core(__attribute__((unused)) void *arg) static rte_rwlock_t lk = RTE_RWLOCK_INITIALIZER; static volatile uint64_t rwlock_data; -static uint64_t lock_count[RTE_MAX_LCORE] = {0}; +static uint64_t time_count[RTE_MAX_LCORE] = {0}; -#define TIME_MS 100 +#define MAX_LOOP 10000 #define TEST_RWLOCK_DEBUG 0 static int @@ -88,7 +89,7 @@ load_loop_fn(__attribute__((unused)) void *arg) ; begin = rte_rdtsc_precise(); - while (time_diff < hz * TIME_MS / 1000) { + while (lcount < MAX_LOOP) { rte_rwlock_write_lock(&lk); ++rwlock_data; rte_rwlock_write_unlock(&lk); @@ -102,10 +103,10 @@ load_loop_fn(__attribute__((unused)) void *arg) lcount++; /* delay to make lock duty cycle slightly realistic */ rte_pause(); - time_diff = rte_rdtsc_precise() - begin; } - lock_count[lcore] = lcount; + time_diff = rte_rdtsc_precise() - begin; + time_count[lcore] = time_diff * 1000000 / hz; return 0; } @@ -129,11 +130,13 @@ test_rwlock_perf(void) rte_eal_mp_wait_lcore(); RTE_LCORE_FOREACH(i) { - printf("Core [%u] count = %"PRIu64"\n", i, lock_count[i]); - total += lock_count[i]; + printf("Core [%u] cost time = %"PRIu64" us\n", + i, time_count[i]); + total += time_count[i]; } - printf("Total count = %"PRIu64"\n", total); + printf("Total cost time = %"PRIu64" us\n", total); + memset(time_count, 0, sizeof(time_count)); return 0; } -- 2.7.4