* [PATCH v3] mtd: test: Replace timeval with ktime_t in speedtest.c and torturetest.c [not found] <mtdtestv3> @ 2014-12-18 3:23 ` Chunyan Zhang 2014-12-18 7:53 ` Arnd Bergmann 0 siblings, 1 reply; 4+ messages in thread From: Chunyan Zhang @ 2014-12-18 3:23 UTC (permalink / raw) To: dwmw2, computersforpeace Cc: arnd, john.stultz, linux-mtd, linux-kernel, zhang.lyra This patch changes the 32-bit time type (timeval) to the 64-bit one (ktime_t), since 32-bit time types will break in the year 2038. I use ktime_t instead of timeval to define 'start' and 'finish' which are used to get the time for tow points. This patch also changes do_gettimeofday() to ktime_get() accordingly, since ktime_get returns a ktime_t, but do_gettimeofday returns a struct timeval, and the other reason is that ktime_get() uses the monotonic clock. This patch is based on another patch which privides a millisecond time difference function 'ktime_ms_delta' in ktime.h http://lkml.iu.edu//hypermail/linux/kernel/1412.2/00625.html Signed-off-by: Chunyan Zhang <zhang.chunyan@linaro.org> Reviewed-by: Arnd Bergmann <arnd@arndb.de> --- Changes since v2: - Use the new function ktime_ms_delta which is added in another patch listed up. Changes since v1: - Add including <linux/ktime.h> in torturetest.c --- drivers/mtd/tests/speedtest.c | 10 +++++----- drivers/mtd/tests/torturetest.c | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/mtd/tests/speedtest.c b/drivers/mtd/tests/speedtest.c index 5ee9f70..87a6e25 100644 --- a/drivers/mtd/tests/speedtest.c +++ b/drivers/mtd/tests/speedtest.c @@ -22,6 +22,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include <linux/init.h> +#include <linux/ktime.h> #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/err.h> @@ -49,7 +50,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 +169,12 @@ static int read_eraseblock_by_2pages(int ebnum) static inline void start_timing(void) { - do_gettimeofday(&start); + start = ktime_get(); } static inline void stop_timing(void) { - do_gettimeofday(&finish); + finish = ktime_get(); } static long calc_speed(void) @@ -181,8 +182,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_ms_delta(finish, start); if (ms == 0) return 0; k = goodebcnt * (mtd->erasesize / 1024) * 1000; diff --git a/drivers/mtd/tests/torturetest.c b/drivers/mtd/tests/torturetest.c index eeab969..7e77ed4 100644 --- a/drivers/mtd/tests/torturetest.c +++ b/drivers/mtd/tests/torturetest.c @@ -26,6 +26,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include <linux/init.h> +#include <linux/ktime.h> #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/err.h> @@ -79,18 +80,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(); } static inline void stop_timing(void) { - do_gettimeofday(&finish); + finish = ktime_get(); } /* @@ -322,8 +323,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_ms_delta(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] 4+ messages in thread
* Re: [PATCH v3] mtd: test: Replace timeval with ktime_t in speedtest.c and torturetest.c 2014-12-18 3:23 ` [PATCH v3] mtd: test: Replace timeval with ktime_t in speedtest.c and torturetest.c Chunyan Zhang @ 2014-12-18 7:53 ` Arnd Bergmann 2015-01-08 1:26 ` Brian Norris 0 siblings, 1 reply; 4+ messages in thread From: Arnd Bergmann @ 2014-12-18 7:53 UTC (permalink / raw) To: Chunyan Zhang Cc: dwmw2, computersforpeace, john.stultz, linux-mtd, linux-kernel, zhang.lyra On Thursday 18 December 2014 11:23:31 Chunyan Zhang wrote: > This patch changes the 32-bit time type (timeval) to the 64-bit one > (ktime_t), since 32-bit time types will break in the year 2038. > > I use ktime_t instead of timeval to define 'start' and 'finish' > which are used to get the time for tow points. > > This patch also changes do_gettimeofday() to ktime_get() accordingly, > since ktime_get returns a ktime_t, but do_gettimeofday returns a > struct timeval, and the other reason is that ktime_get() uses > the monotonic clock. > > This patch is based on another patch which privides a millisecond > time difference function 'ktime_ms_delta' in ktime.h > > http://lkml.iu.edu//hypermail/linux/kernel/1412.2/00625.html > > Signed-off-by: Chunyan Zhang <zhang.chunyan@linaro.org> > Reviewed-by: Arnd Bergmann <arnd@arndb.de> > The new version still looks good to me, but as there is now a dependency on another patch, I'd suggest we queue this up in the y2038 branch together with the patch that introduces ktime_ms_delta. David or Brian, can you provide an Ack for this, or do you have any objections? Arnd ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] mtd: test: Replace timeval with ktime_t in speedtest.c and torturetest.c 2014-12-18 7:53 ` Arnd Bergmann @ 2015-01-08 1:26 ` Brian Norris 2015-01-14 8:20 ` Chunyan Zhang 0 siblings, 1 reply; 4+ messages in thread From: Brian Norris @ 2015-01-08 1:26 UTC (permalink / raw) To: Arnd Bergmann Cc: Chunyan Zhang, dwmw2, john.stultz, linux-mtd, linux-kernel, zhang.lyra On Thu, Dec 18, 2014 at 08:53:10AM +0100, Arnd Bergmann wrote: > On Thursday 18 December 2014 11:23:31 Chunyan Zhang wrote: > > This patch changes the 32-bit time type (timeval) to the 64-bit one > > (ktime_t), since 32-bit time types will break in the year 2038. > > > > I use ktime_t instead of timeval to define 'start' and 'finish' > > which are used to get the time for tow points. > > > > This patch also changes do_gettimeofday() to ktime_get() accordingly, > > since ktime_get returns a ktime_t, but do_gettimeofday returns a > > struct timeval, and the other reason is that ktime_get() uses > > the monotonic clock. > > > > This patch is based on another patch which privides a millisecond > > time difference function 'ktime_ms_delta' in ktime.h > > > > http://lkml.iu.edu//hypermail/linux/kernel/1412.2/00625.html > > > > Signed-off-by: Chunyan Zhang <zhang.chunyan@linaro.org> > > Reviewed-by: Arnd Bergmann <arnd@arndb.de> > > > > The new version still looks good to me, but as there is now a > dependency on another patch, I'd suggest we queue this up in the > y2038 branch together with the patch that introduces ktime_ms_delta. > > David or Brian, can you provide an Ack for this, or do you have > any objections? I just tested v2, which doesn't have this dependency and has only a trivial difference from v3. Seems to work OK. So: Tested-by: Brian Norris <computersforpeace@gmail.com> Acked-by: Brian Norris <computersforpeace@gmail.com> Feel free to queue it in the dependent branch. Thanks, Brian ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] mtd: test: Replace timeval with ktime_t in speedtest.c and torturetest.c 2015-01-08 1:26 ` Brian Norris @ 2015-01-14 8:20 ` Chunyan Zhang 0 siblings, 0 replies; 4+ messages in thread From: Chunyan Zhang @ 2015-01-14 8:20 UTC (permalink / raw) To: Brian Norris Cc: Arnd Bergmann, David Woodhouse, John Stultz, linux-mtd@lists.infradead.org, linux-kernel, Lyra Zhang Hi, Brian Thank you so much ! Best regards, Chunyan On Thu, Jan 8, 2015 at 9:26 AM, Brian Norris <computersforpeace@gmail.com> wrote: > On Thu, Dec 18, 2014 at 08:53:10AM +0100, Arnd Bergmann wrote: >> On Thursday 18 December 2014 11:23:31 Chunyan Zhang wrote: >> > This patch changes the 32-bit time type (timeval) to the 64-bit one >> > (ktime_t), since 32-bit time types will break in the year 2038. >> > >> > I use ktime_t instead of timeval to define 'start' and 'finish' >> > which are used to get the time for tow points. >> > >> > This patch also changes do_gettimeofday() to ktime_get() accordingly, >> > since ktime_get returns a ktime_t, but do_gettimeofday returns a >> > struct timeval, and the other reason is that ktime_get() uses >> > the monotonic clock. >> > >> > This patch is based on another patch which privides a millisecond >> > time difference function 'ktime_ms_delta' in ktime.h >> > >> > http://lkml.iu.edu//hypermail/linux/kernel/1412.2/00625.html >> > >> > Signed-off-by: Chunyan Zhang <zhang.chunyan@linaro.org> >> > Reviewed-by: Arnd Bergmann <arnd@arndb.de> >> > >> >> The new version still looks good to me, but as there is now a >> dependency on another patch, I'd suggest we queue this up in the >> y2038 branch together with the patch that introduces ktime_ms_delta. >> >> David or Brian, can you provide an Ack for this, or do you have >> any objections? > > I just tested v2, which doesn't have this dependency and has only a > trivial difference from v3. Seems to work OK. So: > > Tested-by: Brian Norris <computersforpeace@gmail.com> > Acked-by: Brian Norris <computersforpeace@gmail.com> > > Feel free to queue it in the dependent branch. > > Thanks, > Brian ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-01-14 8:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mtdtestv3>
2014-12-18 3:23 ` [PATCH v3] mtd: test: Replace timeval with ktime_t in speedtest.c and torturetest.c Chunyan Zhang
2014-12-18 7:53 ` Arnd Bergmann
2015-01-08 1:26 ` Brian Norris
2015-01-14 8:20 ` Chunyan Zhang
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox