public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] mount03: flip to the next second before doing the access
@ 2023-02-27  7:21 Li Wang
  2023-02-27 11:37 ` Cyril Hrubis
  2023-02-28  1:31 ` xuyang2018.jy
  0 siblings, 2 replies; 3+ messages in thread
From: Li Wang @ 2023-02-27  7:21 UTC (permalink / raw)
  To: ltp; +Cc: llong

Mount03 occasionally reports failure on tmpfs:

  170	mount03.c:214: TINFO: Testing flag MS_STRICTATIME
  171	mount03.c:140: TFAIL: st.st_atime(1677086243) < atime(1677086243)
  172	mount03.c:151: TFAIL: dir_st.st_atime(1677086243) < dir_atime(1677086243)

From Waiman Long:

  Looking at the mount03.c test, it is reading a directory in tmpfs, sleeping for
  1 second and read the directory again. The test fails because the reported atime
  didn't change. Since tmpfs is in memory, access to them can be much faster and I
  believe that a race condition may happen that the two directory reads can happen
  within the same atime even though one second is supposed to have passed. The same
  test pass when applying to a real filesystem. So I believe the assumption made in
  the test may not be totally correct as the time lag can happen in different
  subsystems inside the kernel for time tracking. I believe it is more a test problem
  than a real kernel problem.

  There may be some slight discrepancy in how sleep and the tmpfs file system is
  keeping track of time. If the first access is right at the beginning of a second
  from the tmpfs perspective, the 2nd access may be at the end of that second, but
  not flip to the next second yet. What I would suggest is to sleep a little more
  like usleep(10 000) to make sure that it will flip to the next second before doing
  the access.

Suggested-by: Waiman Long <llong@redhat.com>
Signed-off-by: Li Wang <liwang@redhat.com>
---
 testcases/kernel/syscalls/mount/mount03.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/mount/mount03.c b/testcases/kernel/syscalls/mount/mount03.c
index 60f9963da..98d5933b7 100644
--- a/testcases/kernel/syscalls/mount/mount03.c
+++ b/testcases/kernel/syscalls/mount/mount03.c
@@ -122,7 +122,7 @@ static void test_file_dir_noatime(int update_fatime, int update_datime)
 	SAFE_CLOSEDIR(test_dir);
 	dir_atime = dir_st.st_atime;
 
-	sleep(1);
+	usleep(1001000);
 
 	SAFE_READ(0, otfd, readbuf, sizeof(readbuf));
 	SAFE_FSTAT(otfd, &st);
-- 
2.38.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH] mount03: flip to the next second before doing the access
  2023-02-27  7:21 [LTP] [PATCH] mount03: flip to the next second before doing the access Li Wang
@ 2023-02-27 11:37 ` Cyril Hrubis
  2023-02-28  1:31 ` xuyang2018.jy
  1 sibling, 0 replies; 3+ messages in thread
From: Cyril Hrubis @ 2023-02-27 11:37 UTC (permalink / raw)
  To: Li Wang; +Cc: llong, ltp

Hi!
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH] mount03: flip to the next second before doing the access
  2023-02-27  7:21 [LTP] [PATCH] mount03: flip to the next second before doing the access Li Wang
  2023-02-27 11:37 ` Cyril Hrubis
@ 2023-02-28  1:31 ` xuyang2018.jy
  1 sibling, 0 replies; 3+ messages in thread
From: xuyang2018.jy @ 2023-02-28  1:31 UTC (permalink / raw)
  To: Li Wang; +Cc: llong@redhat.com, ltp@lists.linux.it

Hi Li

Looks good to me,
Reviewed-by: Yang Xu <xuyang2018.jy@fujitsu.com>

Best Regards
Yang Xu
> Mount03 occasionally reports failure on tmpfs:
> 
>    170	mount03.c:214: TINFO: Testing flag MS_STRICTATIME
>    171	mount03.c:140: TFAIL: st.st_atime(1677086243) < atime(1677086243)
>    172	mount03.c:151: TFAIL: dir_st.st_atime(1677086243) < dir_atime(1677086243)
> 
>  From Waiman Long:
> 
>    Looking at the mount03.c test, it is reading a directory in tmpfs, sleeping for
>    1 second and read the directory again. The test fails because the reported atime
>    didn't change. Since tmpfs is in memory, access to them can be much faster and I
>    believe that a race condition may happen that the two directory reads can happen
>    within the same atime even though one second is supposed to have passed. The same
>    test pass when applying to a real filesystem. So I believe the assumption made in
>    the test may not be totally correct as the time lag can happen in different
>    subsystems inside the kernel for time tracking. I believe it is more a test problem
>    than a real kernel problem.
> 
>    There may be some slight discrepancy in how sleep and the tmpfs file system is
>    keeping track of time. If the first access is right at the beginning of a second
>    from the tmpfs perspective, the 2nd access may be at the end of that second, but
>    not flip to the next second yet. What I would suggest is to sleep a little more
>    like usleep(10 000) to make sure that it will flip to the next second before doing
>    the access.
> 
> Suggested-by: Waiman Long <llong@redhat.com>
> Signed-off-by: Li Wang <liwang@redhat.com>
> ---
>   testcases/kernel/syscalls/mount/mount03.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/testcases/kernel/syscalls/mount/mount03.c b/testcases/kernel/syscalls/mount/mount03.c
> index 60f9963da..98d5933b7 100644
> --- a/testcases/kernel/syscalls/mount/mount03.c
> +++ b/testcases/kernel/syscalls/mount/mount03.c
> @@ -122,7 +122,7 @@ static void test_file_dir_noatime(int update_fatime, int update_datime)
>   	SAFE_CLOSEDIR(test_dir);
>   	dir_atime = dir_st.st_atime;
>   
> -	sleep(1);
> +	usleep(1001000);
>   
>   	SAFE_READ(0, otfd, readbuf, sizeof(readbuf));
>   	SAFE_FSTAT(otfd, &st);

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

end of thread, other threads:[~2023-02-28  1:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-27  7:21 [LTP] [PATCH] mount03: flip to the next second before doing the access Li Wang
2023-02-27 11:37 ` Cyril Hrubis
2023-02-28  1:31 ` xuyang2018.jy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox