Skip to contentSkip to conversation

times03: don't assume process initial [us]time is 0

PATCH Superseded Jan Stancek 3 participants 5 messages Mar 9, 2018

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 times03: don't assume process initial [us]time is 0

times() runs immediately after fork(), but syscall alone seems to be enough for some systems to already account ticks.

For example on arm64 with 4.14:
tst_test.c:980: INFO: Timeout per run is 0h 05m 00s times03.c:102: PASS: buf1.tms_utime = 0 times03.c:105: FAIL: buf1.tms_stime = 1
...

This patch replaces zero check with a comparison against a small enough number < 5 (which should be between 5ms and 50ms depending on CONFIG_HZ).

---
 testcases/kernel/syscalls/times/times03.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
testcases/kernel/syscalls/times/times03.c +4 -4
index 78d72d259ec1..c34faf5a2ff9 100644
@@ -96,15 +96,15 @@ static void verify_times(void)
 	if (times(&buf1) == -1)
 		tst_brk(TBROK | TERRNO, "times()");
 
-	if (buf1.tms_utime != 0)
+	if (buf1.tms_utime > 5)
 		tst_res(TFAIL, "buf1.tms_utime = %li", buf1.tms_utime);
 	else
-		tst_res(TPASS, "buf1.tms_utime = 0");
+		tst_res(TPASS, "buf1.tms_utime > 5");
 
-	if (buf1.tms_stime != 0)
+	if (buf1.tms_stime > 5)
 		tst_res(TFAIL, "buf1.tms_stime = %li", buf1.tms_stime);
 	else
-		tst_res(TPASS, "buf1.tms_stime = 0");
+		tst_res(TPASS, "buf1.tms_stime > 5");
 
 	generate_utime();
 	generate_stime();
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH v2 1/1 times03: don't assume process initial [us]time is 0

Quoted 34 lines · Jan Stancek

times() runs immediately after fork(), but syscall alone seems to be enough for some systems to already account ticks.

For example on arm64 with 4.14:
tst_test.c:980: INFO: Timeout per run is 0h 05m 00s times03.c:102: PASS: buf1.tms_utime = 0 times03.c:105: FAIL: buf1.tms_stime = 1
...

This patch replaces zero check with a comparison against a small enough number < 5 (which should be between 5ms and 50ms depending on CONFIG_HZ).

---
 testcases/kernel/syscalls/times/times03.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
testcases/kernel/syscalls/times/times03.c +2 -2
index 78d72d259ec1..c34faf5a2ff9 100644
@@ -96,15 +96,15 @@ static void verify_times(void)
        if (times(&buf1) == -1)
                tst_brk(TBROK | TERRNO, "times()");
 
-       if (buf1.tms_utime != 0)
+       if (buf1.tms_utime > 5)
                tst_res(TFAIL, "buf1.tms_utime = %li", buf1.tms_utime);
        else
-               tst_res(TPASS, "buf1.tms_utime = 0");
+               tst_res(TPASS, "
Quoted 3 lines

​​
buf1.tms_utime > 5");

​shouldn't this ​buf1.tms_utime <= 5 ?​

testcases/kernel/syscalls/times/times03.c static void verify_times(void) · line 107

Quoted 8 lines
testcases/kernel/syscalls/times/times03.c +2 -2
-       if (buf1.tms_stime != 0)
+       if (buf1.tms_stime > 5)
                tst_res(TFAIL, "buf1.tms_stime = %li", buf1.tms_stime);
        else
-               tst_res(TPASS, "buf1.tms_stime = 0");
+               tst_res(TPASS, "buf1.tms_stime > 5");

​here as well.
​

Quoted 7 lines
        generate_utime();
        generate_stime();

--
1.8.3.1

​Other than that this looks good to me. I also run this changes more than 100 times and ​all passed.

Signature · 6 lines
Regards,
Li Wang
Email: [email protected]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20180309/8fd371fd/attachment-0001.html>
#2 lore raw

PATCH v2 1/1 times03: don't assume process initial [us]time is 0

----- Original Message -----

Quoted 30 lines · Jan Stancek
Quoted 29 lines

times() runs immediately after fork(), but syscall alone seems to be enough for some systems to already account ticks.

For example on arm64 with 4.14:
tst_test.c:980: INFO: Timeout per run is 0h 05m 00s times03.c:102: PASS: buf1.tms_utime = 0 times03.c:105: FAIL: buf1.tms_stime = 1
...

This patch replaces zero check with a comparison against a small enough number < 5 (which should be between 5ms and 50ms depending on CONFIG_HZ).

---
 testcases/kernel/syscalls/times/times03.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
testcases/kernel/syscalls/times/times03.c +0 -0
index 78d72d259ec1..c34faf5a2ff9 100644
@@ -96,15 +96,15 @@ static void verify_times(void)
        if (times(&buf1) == -1)
                tst_brk(TBROK | TERRNO, "times()");
 
Quoted 11 lines
Quoted 9 lines
testcases/kernel/syscalls/times/times03.c +2 -2
-       if (buf1.tms_utime != 0)
+       if (buf1.tms_utime > 5)
                tst_res(TFAIL, "buf1.tms_utime = %li", buf1.tms_utime);
        else
-               tst_res(TPASS, "buf1.tms_utime = 0");
+               tst_res(TPASS, "

​​
buf1.tms_utime > 5");

​shouldn't this ​buf1.tms_utime <= 5 ?​

You're right, the TPASS message is wrong.

Quoted 26 lines

testcases/kernel/syscalls/times/times03.c static void verify_times(void) · line 107

Quoted 11 lines
testcases/kernel/syscalls/times/times03.c +2 -2
-       if (buf1.tms_stime != 0)
+       if (buf1.tms_stime > 5)
                tst_res(TFAIL, "buf1.tms_stime = %li", buf1.tms_stime);
        else
-               tst_res(TPASS, "buf1.tms_stime = 0");
+               tst_res(TPASS, "buf1.tms_stime > 5");

​here as well.
​

Quoted 7 lines
        generate_utime();
        generate_stime();

--
1.8.3.1

​Other than that this looks good to me. I also run this changes more than 100 times and ​all passed.

#3 lore raw

PATCH v2 1/1 times03: don't assume process initial [us]time is 0

Hi!

Quoted 1 line

You're right, the TPASS message is wrong.

Acked with fixed TPASS messages.

Signature · 2 lines
Cyril Hrubis
[email protected]
#4 lore raw

PATCH v2 1/1 times03: don't assume process initial [us]time is 0

----- Original Message -----

Quoted 4 lines

Hi!

Quoted 1 line

You're right, the TPASS message is wrong.

Acked with fixed TPASS messages.

Pushed with fixed TPASS messages.

Regards,
Jan