linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH] fsck.f2fs: report real wall time
@ 2020-03-09 21:19 Jaegeuk Kim
  2020-03-16  6:17 ` Chao Yu
  0 siblings, 1 reply; 2+ messages in thread
From: Jaegeuk Kim @ 2020-03-09 21:19 UTC (permalink / raw)
  To: linux-f2fs-devel; +Cc: Wei Wang, Jaegeuk Kim

From: Wei Wang <wvw@google.com>

clock_t time is per-process time, which is not wall time. For example,
if the CPU is shared by other processes, clock_t time may advance slower
than wall clock. On the other hand, if the current process is
multithreaded and more than one execution core is available, clock_t
time may advance faster than wall clock.

this CL changes it to use CLOCK_BOOTTIME (Linux-specific)

Signed-off-by: Wei Wang <wvw@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fsck/main.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/fsck/main.c b/fsck/main.c
index a6fd970..c481ce4 100644
--- a/fsck/main.c
+++ b/fsck/main.c
@@ -801,11 +801,18 @@ static int do_sload(struct f2fs_sb_info *sbi)
 	return f2fs_sload(sbi);
 }
 
+static u64 get_boottime_ns() {
+	struct timespec t;
+	t.tv_sec = t.tv_nsec = 0;
+	clock_gettime(CLOCK_BOOTTIME, &t);
+	return (u64)t.tv_sec * 1000000000LL + t.tv_nsec;
+}
+
 int main(int argc, char **argv)
 {
 	struct f2fs_sb_info *sbi;
 	int ret = 0;
-	clock_t start = clock();
+	u64 start = get_boottime_ns();
 
 	f2fs_init_configuration();
 
@@ -919,7 +926,7 @@ retry:
 	if (ret < 0)
 		return ret;
 
-	printf("\nDone: %lf secs\n", (clock() - start) / (double)CLOCKS_PER_SEC);
+	printf("\nDone: %lf secs\n", (get_boottime_ns() - start) / 1000000000.0);
 	return 0;
 
 out_err:
-- 
2.25.1.481.gfbce0eb801-goog



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [f2fs-dev] [PATCH] fsck.f2fs: report real wall time
  2020-03-09 21:19 [f2fs-dev] [PATCH] fsck.f2fs: report real wall time Jaegeuk Kim
@ 2020-03-16  6:17 ` Chao Yu
  0 siblings, 0 replies; 2+ messages in thread
From: Chao Yu @ 2020-03-16  6:17 UTC (permalink / raw)
  To: Jaegeuk Kim, linux-f2fs-devel; +Cc: Wei Wang

On 2020/3/10 5:19, Jaegeuk Kim wrote:
> From: Wei Wang <wvw@google.com>
> 
> clock_t time is per-process time, which is not wall time. For example,
> if the CPU is shared by other processes, clock_t time may advance slower
> than wall clock. On the other hand, if the current process is
> multithreaded and more than one execution core is available, clock_t
> time may advance faster than wall clock.
> 
> this CL changes it to use CLOCK_BOOTTIME (Linux-specific)
> 
> Signed-off-by: Wei Wang <wvw@google.com>
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-03-16  6:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-09 21:19 [f2fs-dev] [PATCH] fsck.f2fs: report real wall time Jaegeuk Kim
2020-03-16  6:17 ` Chao Yu

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).