Skip to contentSkip to conversation

syscalls/statx06: use a fine-grained timestamp for the second time fetch

PATCH In review Jeff Layton 4 participants 8 messages May 18, 2023 – May 25, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 syscalls/statx06: use a fine-grained timestamp for the second time fetch

I have a patchset in progress to change the kernel to sometimes use fine-grained timestamps for the mtime/ctime. With this, the statx06 test sometimes fails.

Change the test to grab a fine-grained timestamp for the "after" value, which fixes the issue.

---
 testcases/kernel/syscalls/statx/statx06.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/syscalls/statx/statx06.c +1 -1
index ce82b905bebd..fa75982b0901 100644
@@ -109,7 +109,7 @@ static void test_statx(unsigned int test_nr)
 	clock_wait_tick();
 	tc->operation();
 	clock_wait_tick();
-	SAFE_CLOCK_GETTIME(CLOCK_REALTIME_COARSE, &after_time);
+	SAFE_CLOCK_GETTIME(CLOCK_REALTIME, &after_time);
 
 	TEST(statx(AT_FDCWD, TEST_FILE, 0, STATX_ALL, &buff));
 	if (TST_RET != 0) {
Signature · 5 lines
2.40.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw
Quoted 6 lines · Jeff Layton

I have a patchset in progress to change the kernel to sometimes use fine-grained timestamps for the mtime/ctime. With this, the statx06 test sometimes fails.

Change the test to grab a fine-grained timestamp for the "after" value, which fixes the issue.

Now, it is not a right time to review this patch, I prefer to review this when your kernel patchset is merged into linux master or linux-next. Then we can add a comment or a kernel commit id to explain this..

Best Regard
Yang Xu

Quoted 19 lines
---
  testcases/kernel/syscalls/statx/statx06.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/syscalls/statx/statx06.c +1 -1
index ce82b905bebd..fa75982b0901 100644
@@ -109,7 +109,7 @@ static void test_statx(unsigned int test_nr)
  	clock_wait_tick();
  	tc->operation();
  	clock_wait_tick();
-	SAFE_CLOCK_GETTIME(CLOCK_REALTIME_COARSE, &after_time);
+	SAFE_CLOCK_GETTIME(CLOCK_REALTIME, &after_time);
 
  	TEST(statx(AT_FDCWD, TEST_FILE, 0, STATX_ALL, &buff));
  	if (TST_RET != 0) {
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw
Quoted 6 lines · Yang Xu (Fujitsu)
Quoted 4 lines · Jeff Layton

I have a patchset in progress to change the kernel to sometimes use fine-grained timestamps for the mtime/ctime. With this, the statx06 test sometimes fails.

Quoted 9 lines
Quoted 2 lines

Change the test to grab a fine-grained timestamp for the "after" value, which fixes the issue.

Now, it is not a right time to review this patch, I prefer to review this when your kernel patchset is merged into linux master or linux-next. Then we can add a comment or a kernel commit id to explain this..

Fair enough. I don't think there is any issue with taking this patch in earlier however.

The problem with this test is that it makes the assumption that coarse- grained timestamps are sufficient to bracket a filesystem operation. While that has largely been true in the past, it's certainly not specified by any standard.

Quoted 19 lines
Quoted 19 lines
---
  testcases/kernel/syscalls/statx/statx06.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/syscalls/statx/statx06.c +1 -1
index ce82b905bebd..fa75982b0901 100644
@@ -109,7 +109,7 @@ static void test_statx(unsigned int test_nr)
  	clock_wait_tick();
  	tc->operation();
  	clock_wait_tick();
-	SAFE_CLOCK_GETTIME(CLOCK_REALTIME_COARSE, &after_time);
+	SAFE_CLOCK_GETTIME(CLOCK_REALTIME, &after_time);
 
  	TEST(statx(AT_FDCWD, TEST_FILE, 0, STATX_ALL, &buff));
  	if (TST_RET != 0) {
Signature · 4 lines
Jeff Layton <[email protected]>

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by
#3 lore raw

Hi!

Quoted 7 lines
Quoted 6 lines

Now, it is not a right time to review this patch, I prefer to review this when your kernel patchset is merged into linux master or linux-next. Then we can add a comment or a kernel commit id to explain this..

Quoted 7 lines

Fair enough. I don't think there is any issue with taking this patch in earlier however.

The problem with this test is that it makes the assumption that coarse- grained timestamps are sufficient to bracket a filesystem operation. While that has largely been true in the past, it's certainly not specified by any standard.

Do we have any API to ask the kernel what the granularity of filesystem the timestamps is? Would that make sense to be added if it's not present?

Apart from that I think that this patch is fine, since the CLOCK_REALTIME value would be between CLOCK_REALTIME_COARSE and CLOCK_REALTIME_COARSE + one tick. So the change is backward compatible and we will not loose any precision in the assertions either.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#4 lore raw
Quoted 11 lines · Cyril Hrubis

Hi!

Quoted 10 lines
Quoted 6 lines

Now, it is not a right time to review this patch, I prefer to review this when your kernel patchset is merged into linux master or linux-next. Then we can add a comment or a kernel commit id to explain this..

Fair enough. I don't think there is any issue with taking this patch in earlier however.

Quoted 9 lines
Quoted 4 lines

The problem with this test is that it makes the assumption that coarse- grained timestamps are sufficient to bracket a filesystem operation. While that has largely been true in the past, it's certainly not specified by any standard.

Do we have any API to ask the kernel what the granularity of filesystem the timestamps is? Would that make sense to be added if it's not present?

No, we don't have such a thing now, and we don't really track that information in the kernel.

We do have a sb->s_time_gran field which is in units of nanoseconds, but that really is more about the granularity that the filesystem itself can store on disk. It doesn't tell you whether the kernel decided to put a coarse or fine grained timestamp in there.

Quoted 7 lines

Apart from that I think that this patch is fine, since the CLOCK_REALTIME value would be between CLOCK_REALTIME_COARSE and CLOCK_REALTIME_COARSE + one tick. So the change is backward compatible and we will not loose any precision in the assertions either.

Thanks, and yes. This should be safe to apply now even if the kernel patch series never goes in.

Signature · 4 lines
Jeff Layton <[email protected]>

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by
#5 lore raw

Hi all,

Quoted 2 lines

Thanks, and yes. This should be safe to apply now even if the kernel patch series never goes in.

I'd be ok to merge this now. Xu, please let me know if you're against.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by
#6 lore raw

Hi Petr

Quoted 8 lines

Hi all,

Quoted 2 lines

Thanks, and yes. This should be safe to apply now even if the kernel patch series never goes in.

I'd be ok to merge this now. Xu, please let me know if you're against.

This patch is right, so please merged.

Best Regards
Yang Xu

Quoted 3 lines

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#7 lore raw

Hi all,

I merged the patchset, linking the original RFC patchset in kernel and explaining that we merged it because the change is backward compatible anyway.

Thanks to all!

Kind regards,
Petr

[1] https://lore.kernel.org/lkml/[email protected]/

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp