* [PATCH] mtd: tests: Use boottime
@ 2015-08-11 16:16 Abhilash Jindal
2015-11-10 23:05 ` Brian Norris
0 siblings, 1 reply; 2+ messages in thread
From: Abhilash Jindal @ 2015-08-11 16:16 UTC (permalink / raw)
To: linux-mtd; +Cc: dwmw2, computersforpeace, Abhilash Jindal
Wall time obtained from do_gettimeofday is susceptible to sudden jumps due to
user setting the time or due to NTP. Boot time is constantly increasing time
better suited for comparing two timestamps.
Signed-off-by: Abhilash Jindal <klock.android@gmail.com>
---
drivers/mtd/tests/speedtest.c | 9 ++++-----
drivers/mtd/tests/torturetest.c | 9 ++++-----
2 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/drivers/mtd/tests/speedtest.c b/drivers/mtd/tests/speedtest.c
index 5a6f31a..854b707 100644
--- a/drivers/mtd/tests/speedtest.c
+++ b/drivers/mtd/tests/speedtest.c
@@ -49,7 +49,7 @@ static int pgsize;
static int ebcnt;
static int pgcnt;
static int goodebcnt;
-static struct timeval start, finish;
+static ktime_t start, finish;
static int multiblock_erase(int ebnum, int blocks)
{
@@ -168,12 +168,12 @@ static int read_eraseblock_by_2pages(int ebnum)
static inline void start_timing(void)
{
- do_gettimeofday(&start);
+ start = ktime_get_boottime();
}
static inline void stop_timing(void)
{
- do_gettimeofday(&finish);
+ finish = ktime_get_boottime();
}
static long calc_speed(void)
@@ -181,8 +181,7 @@ static long calc_speed(void)
uint64_t k;
long ms;
- ms = (finish.tv_sec - start.tv_sec) * 1000 +
- (finish.tv_usec - start.tv_usec) / 1000;
+ ms = ktime_to_ms(ktime_sub(finish, start));
if (ms == 0)
return 0;
k = (uint64_t)goodebcnt * (mtd->erasesize / 1024) * 1000;
diff --git a/drivers/mtd/tests/torturetest.c b/drivers/mtd/tests/torturetest.c
index e5d6e6d..228023a 100644
--- a/drivers/mtd/tests/torturetest.c
+++ b/drivers/mtd/tests/torturetest.c
@@ -79,18 +79,18 @@ static unsigned char *check_buf;
static unsigned int erase_cycles;
static int pgsize;
-static struct timeval start, finish;
+static ktime_t start, finish;
static void report_corrupt(unsigned char *read, unsigned char *written);
static inline void start_timing(void)
{
- do_gettimeofday(&start);
+ start = ktime_get_boottime();
}
static inline void stop_timing(void)
{
- do_gettimeofday(&finish);
+ finish = ktime_get_boottime();
}
/*
@@ -333,8 +333,7 @@ static int __init tort_init(void)
long ms;
stop_timing();
- ms = (finish.tv_sec - start.tv_sec) * 1000 +
- (finish.tv_usec - start.tv_usec) / 1000;
+ ms = ktime_to_ms(ktime_sub(finish, start));
pr_info("%08u erase cycles done, took %lu "
"milliseconds (%lu seconds)\n",
erase_cycles, ms, ms / 1000);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mtd: tests: Use boottime
2015-08-11 16:16 [PATCH] mtd: tests: Use boottime Abhilash Jindal
@ 2015-11-10 23:05 ` Brian Norris
0 siblings, 0 replies; 2+ messages in thread
From: Brian Norris @ 2015-11-10 23:05 UTC (permalink / raw)
To: Abhilash Jindal
Cc: linux-mtd, dwmw2, Arnd Bergmann, Shraddha Barke, linux-kernel
+ others
On Tue, Aug 11, 2015 at 12:16:14PM -0400, Abhilash Jindal wrote:
> Wall time obtained from do_gettimeofday is susceptible to sudden jumps due to
> user setting the time or due to NTP. Boot time is constantly increasing time
> better suited for comparing two timestamps.
>
> Signed-off-by: Abhilash Jindal <klock.android@gmail.com>
Sorry, didn't notice this one earlier. We've merged an alternative patch
that uses ktime_get():
commit af30c0a00aa0d086a820c2ec75544c07611834d7
Author: Shraddha Barke <shraddha.6596@gmail.com>
Date: Thu Oct 22 20:29:54 2015 +0530
mtd: tests: Replace timeval with ktime_t
>From reading the API description, it's not really clear to me if
ktime_get() includes NTP jumps or not.
In any case, if you still need this patch, please rebase on the latest
-next.
Regards,
Brian
> ---
> drivers/mtd/tests/speedtest.c | 9 ++++-----
> drivers/mtd/tests/torturetest.c | 9 ++++-----
> 2 files changed, 8 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/mtd/tests/speedtest.c b/drivers/mtd/tests/speedtest.c
> index 5a6f31a..854b707 100644
> --- a/drivers/mtd/tests/speedtest.c
> +++ b/drivers/mtd/tests/speedtest.c
> @@ -49,7 +49,7 @@ static int pgsize;
> static int ebcnt;
> static int pgcnt;
> static int goodebcnt;
> -static struct timeval start, finish;
> +static ktime_t start, finish;
>
> static int multiblock_erase(int ebnum, int blocks)
> {
> @@ -168,12 +168,12 @@ static int read_eraseblock_by_2pages(int ebnum)
>
> static inline void start_timing(void)
> {
> - do_gettimeofday(&start);
> + start = ktime_get_boottime();
> }
>
> static inline void stop_timing(void)
> {
> - do_gettimeofday(&finish);
> + finish = ktime_get_boottime();
> }
>
> static long calc_speed(void)
> @@ -181,8 +181,7 @@ static long calc_speed(void)
> uint64_t k;
> long ms;
>
> - ms = (finish.tv_sec - start.tv_sec) * 1000 +
> - (finish.tv_usec - start.tv_usec) / 1000;
> + ms = ktime_to_ms(ktime_sub(finish, start));
> if (ms == 0)
> return 0;
> k = (uint64_t)goodebcnt * (mtd->erasesize / 1024) * 1000;
> diff --git a/drivers/mtd/tests/torturetest.c b/drivers/mtd/tests/torturetest.c
> index e5d6e6d..228023a 100644
> --- a/drivers/mtd/tests/torturetest.c
> +++ b/drivers/mtd/tests/torturetest.c
> @@ -79,18 +79,18 @@ static unsigned char *check_buf;
> static unsigned int erase_cycles;
>
> static int pgsize;
> -static struct timeval start, finish;
> +static ktime_t start, finish;
>
> static void report_corrupt(unsigned char *read, unsigned char *written);
>
> static inline void start_timing(void)
> {
> - do_gettimeofday(&start);
> + start = ktime_get_boottime();
> }
>
> static inline void stop_timing(void)
> {
> - do_gettimeofday(&finish);
> + finish = ktime_get_boottime();
> }
>
> /*
> @@ -333,8 +333,7 @@ static int __init tort_init(void)
> long ms;
>
> stop_timing();
> - ms = (finish.tv_sec - start.tv_sec) * 1000 +
> - (finish.tv_usec - start.tv_usec) / 1000;
> + ms = ktime_to_ms(ktime_sub(finish, start));
> pr_info("%08u erase cycles done, took %lu "
> "milliseconds (%lu seconds)\n",
> erase_cycles, ms, ms / 1000);
> --
> 1.7.9.5
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-11-10 23:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-11 16:16 [PATCH] mtd: tests: Use boottime Abhilash Jindal
2015-11-10 23:05 ` Brian Norris
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).