From: Gavin Hu <gavin.hu@arm.com>
To: dev@dpdk.org
Cc: nd@arm.com, thomas@monjalon.net, jerinj@marvell.com,
hemant.agrawal@nxp.com, nipun.gupta@nxp.com,
Honnappa.Nagarahalli@arm.com, gavin.hu@arm.com,
i.maximets@samsung.com, chaozhu@linux.vnet.ibm.com,
stable@dpdk.org
Subject: [dpdk-dev] [PATCH v6 2/3] test/spinlock: amortize the cost of getting time
Date: Fri, 8 Mar 2019 15:16:40 +0800 [thread overview]
Message-ID: <1552029401-90697-3-git-send-email-gavin.hu@arm.com> (raw)
In-Reply-To: <1552029401-90697-1-git-send-email-gavin.hu@arm.com>
In-Reply-To: <20181220104246.5590-1-gavin.hu@arm.com>
Instead of getting timestamps per iteration, amortize its overhead
can help getting more precise benchmarking results.
Fixes: af75078fece3 ("first public release")
Cc: stable@dpdk.org
Signed-off-by: Gavin Hu <gavin.hu@arm.com>
Reviewed-by: Joyce Kong <Joyce.Kong@arm.com>
Reviewed-by: ruifeng wang <ruifeng.wang@arm.com>
Reviewed-by: honnappa nagarahalli <honnappa.nagarahalli@arm.com>
---
app/test/test_spinlock.c | 29 ++++++++++++++++-------------
1 file changed, 16 insertions(+), 13 deletions(-)
diff --git a/app/test/test_spinlock.c b/app/test/test_spinlock.c
index 6795195..6ac7495 100644
--- a/app/test/test_spinlock.c
+++ b/app/test/test_spinlock.c
@@ -96,16 +96,16 @@ test_spinlock_recursive_per_core(__attribute__((unused)) void *arg)
}
static rte_spinlock_t lk = RTE_SPINLOCK_INITIALIZER;
-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
static int
load_loop_fn(void *func_param)
{
uint64_t time_diff = 0, begin;
uint64_t hz = rte_get_timer_hz();
- uint64_t lcount = 0;
+ volatile uint64_t lcount = 0;
const int use_lock = *(int*)func_param;
const unsigned lcore = rte_lcore_id();
@@ -114,15 +114,15 @@ load_loop_fn(void *func_param)
while (rte_atomic32_read(&synchro) == 0);
begin = rte_get_timer_cycles();
- while (time_diff < hz * TIME_MS / 1000) {
+ while (lcount < MAX_LOOP) {
if (use_lock)
rte_spinlock_lock(&lk);
lcount++;
if (use_lock)
rte_spinlock_unlock(&lk);
- time_diff = rte_get_timer_cycles() - begin;
}
- lock_count[lcore] = lcount;
+ time_diff = rte_get_timer_cycles() - begin;
+ time_count[lcore] = time_diff * 1000000 / hz;
return 0;
}
@@ -136,14 +136,16 @@ test_spinlock_perf(void)
printf("\nTest with no lock on single core...\n");
load_loop_fn(&lock);
- printf("Core [%u] count = %"PRIu64"\n", lcore, lock_count[lcore]);
- memset(lock_count, 0, sizeof(lock_count));
+ printf("Core [%u] Cost Time = %"PRIu64" us\n", lcore,
+ time_count[lcore]);
+ memset(time_count, 0, sizeof(time_count));
printf("\nTest with lock on single core...\n");
lock = 1;
load_loop_fn(&lock);
- printf("Core [%u] count = %"PRIu64"\n", lcore, lock_count[lcore]);
- memset(lock_count, 0, sizeof(lock_count));
+ printf("Core [%u] Cost Time = %"PRIu64" us\n", lcore,
+ time_count[lcore]);
+ memset(time_count, 0, sizeof(time_count));
printf("\nTest with lock on %u cores...\n", rte_lcore_count());
@@ -158,11 +160,12 @@ test_spinlock_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);
return 0;
}
--
2.7.4
next prev parent reply other threads:[~2019-03-08 7:17 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-20 10:42 [dpdk-dev] [PATCH v1 0/5] spinlock optimization and test case enhancements Gavin Hu
2018-12-20 10:42 ` [dpdk-dev] [PATCH v1 1/5] test/spinlock: remove 1us delay for correct spinlock benchmarking Gavin Hu
2018-12-20 10:42 ` [dpdk-dev] [PATCH v1 2/5] test/spinlock: get timestamp more precisely Gavin Hu
2018-12-20 10:42 ` [dpdk-dev] [PATCH v1 3/5] test/spinlock: amortize the cost of getting time Gavin Hu
2018-12-20 10:42 ` [dpdk-dev] [PATCH v1 4/5] spinlock: move the implementation to arm specific file Gavin Hu
2018-12-20 12:47 ` David Marchand
2018-12-20 12:55 ` David Marchand
2018-12-20 14:40 ` Gavin Hu (Arm Technology China)
2018-12-20 14:36 ` Gavin Hu (Arm Technology China)
2018-12-20 15:09 ` David Marchand
2018-12-20 15:58 ` Gavin Hu (Arm Technology China)
2018-12-20 15:59 ` David Marchand
2018-12-20 10:42 ` [dpdk-dev] [PATCH v1 5/5] spinlock: reimplement with atomic one-way barrier builtins Gavin Hu
2018-12-20 17:42 ` [dpdk-dev] [PATCH v2 0/5] spinlock optimization and test case enhancements Gavin Hu
2018-12-20 17:42 ` [dpdk-dev] [PATCH v2 1/5] test/spinlock: remove 1us delay for correct benchmarking Gavin Hu
2018-12-20 17:42 ` [dpdk-dev] [PATCH v2 2/5] test/spinlock: get timestamp more precisely Gavin Hu
2018-12-20 17:42 ` [dpdk-dev] [PATCH v2 3/5] test/spinlock: amortize the cost of getting time Gavin Hu
2018-12-20 17:42 ` [dpdk-dev] [PATCH v2 4/5] spinlock: reimplement with atomic one-way barrier builtins Gavin Hu
2018-12-20 17:42 ` [dpdk-dev] [PATCH v2 5/5] eal: fix clang compilation error on x86 Gavin Hu
2019-01-15 7:54 ` [dpdk-dev] [PATCH v4 0/4] spinlock optimization and test case enhancements gavin hu
2019-01-15 7:54 ` [dpdk-dev] [PATCH v4 1/4] eal: fix clang compilation error on x86 gavin hu
2019-01-15 7:54 ` [dpdk-dev] [PATCH v4 2/4] test/spinlock: remove 1us delay for correct benchmarking gavin hu
2019-01-15 7:54 ` [dpdk-dev] [PATCH v4 3/4] test/spinlock: amortize the cost of getting time gavin hu
2019-01-15 7:54 ` [dpdk-dev] [PATCH v4 4/4] spinlock: reimplement with atomic one-way barrier builtins gavin hu
2019-01-15 10:32 ` [dpdk-dev] [PATCH v5 0/4] spinlock optimization and test case enhancements gavin hu
2019-01-15 10:32 ` [dpdk-dev] [PATCH v5 1/4] eal: fix clang compilation error on x86 gavin hu
2019-01-15 17:42 ` Honnappa Nagarahalli
2019-01-15 10:32 ` [dpdk-dev] [PATCH v5 2/4] test/spinlock: remove 1us delay for correct benchmarking gavin hu
2019-01-15 10:32 ` [dpdk-dev] [PATCH v5 3/4] test/spinlock: amortize the cost of getting time gavin hu
2019-01-15 10:32 ` [dpdk-dev] [PATCH v5 4/4] spinlock: reimplement with atomic one-way barrier builtins gavin hu
2019-03-08 7:16 ` [dpdk-dev] [PATCH v6 0/3] generic spinlock optimization and test case enhancements Gavin Hu
2019-03-08 7:16 ` [dpdk-dev] [PATCH v6 1/3] test/spinlock: dealy 1 us to create contention Gavin Hu
2019-03-08 7:16 ` Gavin Hu [this message]
2019-03-08 7:16 ` [dpdk-dev] [PATCH v6 3/3] spinlock: reimplement with atomic one-way barrier builtins Gavin Hu
2019-03-08 7:37 ` [dpdk-dev] [PATCH v7 0/3] generic spinlock optimization and test case enhancements Gavin Hu
2019-03-08 7:37 ` [dpdk-dev] [PATCH v7 1/3] test/spinlock: remove 1us delay for correct benchmarking Gavin Hu
2019-03-08 7:37 ` [dpdk-dev] [PATCH v7 2/3] test/spinlock: amortize the cost of getting time Gavin Hu
2019-03-08 7:37 ` [dpdk-dev] [PATCH v7 3/3] spinlock: reimplement with atomic one-way barrier builtins Gavin Hu
2019-03-08 7:56 ` [dpdk-dev] [PATCH v8 0/3] generic spinlock optimization and test case enhancements Gavin Hu
2019-03-11 12:21 ` Nipun Gupta
2019-03-15 12:21 ` Ananyev, Konstantin
2019-03-15 12:21 ` Ananyev, Konstantin
2019-03-28 7:47 ` Thomas Monjalon
2019-03-28 7:47 ` Thomas Monjalon
2019-03-08 7:56 ` [dpdk-dev] [PATCH v8 1/3] test/spinlock: remove 1us delay for correct benchmarking Gavin Hu
2019-03-08 7:56 ` [dpdk-dev] [PATCH v8 2/3] test/spinlock: amortize the cost of getting time Gavin Hu
2019-03-08 7:56 ` [dpdk-dev] [PATCH v8 3/3] spinlock: reimplement with atomic one-way barrier builtins Gavin Hu
2019-03-12 14:53 ` [dpdk-dev] [EXT] " Jerin Jacob Kollanukkaran
2019-03-14 0:31 ` Honnappa Nagarahalli
2019-03-14 0:31 ` Honnappa Nagarahalli
2019-03-14 2:36 ` Gavin Hu (Arm Technology China)
2019-03-14 2:36 ` Gavin Hu (Arm Technology China)
2019-03-14 14:22 ` Jerin Jacob Kollanukkaran
2019-03-14 14:22 ` Jerin Jacob Kollanukkaran
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1552029401-90697-3-git-send-email-gavin.hu@arm.com \
--to=gavin.hu@arm.com \
--cc=Honnappa.Nagarahalli@arm.com \
--cc=chaozhu@linux.vnet.ibm.com \
--cc=dev@dpdk.org \
--cc=hemant.agrawal@nxp.com \
--cc=i.maximets@samsung.com \
--cc=jerinj@marvell.com \
--cc=nd@arm.com \
--cc=nipun.gupta@nxp.com \
--cc=stable@dpdk.org \
--cc=thomas@monjalon.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).