lkml.org 
[lkml]   [2003]   [Jul]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Fw: Re: 2.5 kernel regression in alarm() syscall behaviour?
Andrew Morton wrote:
>
> Begin forwarded message:
>
> Date: Mon, 14 Jul 2003 09:39:33 -0500
> From: Amos Waterland <apw@us.ibm.com>
> To: linux-kernel@vger.kernel.org
> Subject: Re: 2.5 kernel regression in alarm() syscall behaviour?
>
>
> I think Wes' mail client mangled his testcase a bit. Here is a cleaned
> up version.

I suppose we are going to have a lot of these. The test calls alarm
which sets up an itimer for the specified number of seconds and
returns the number of seconds remaining on the old itimer. If any
useconds remain, seconds is boosted by 1. The test expects the number
returned to be the same as what was sent, i.e. 1 second wait is
expected to return 1 second if it is immeadiatly queried.

The problem with this test is that it assumes that seconds can be
translated into jiffies with out any error. Jiffies, however, is now
defined to be close but not equal to 1/HZ. In fact, on the x86
jiffies is 999848 nano seconds. The conversion of a second with the
proper round up gives 1001 jiffies and converting this back to seconds
gives 1.000847848 seconds. It is this 0.000847848 that is forcing the
subject test to report a number higher than expected.

IMHO it is the test that is wrong, not the kernel.

-g
>
> Compile with:
>
> % gcc -Wall -Werror alarm.c -o alarm
>
> Output on 2.4 kernel is:
>
> % ./alarm
> [1058193354] alarm(0), want retval:0; got retval:0 (PASS)
> ...
> [1058193354] alarm(9), want retval:8; got retval:8 (PASS)
> 0/10 tests failed
>
> Output on 2.5 kernel is: many failures. The number of failures go down
> when the system is heavily stressed.
>
> ---- Begin alarm.c ----
>
> #include <unistd.h>
> #include <stdio.h>
> #include <sys/time.h>
>
> #define MINVAL 0
> #define MAXVAL 10
> #define NOALARM 0
>
> int main(int argc, char **argv)
> {
> int retval = 0, failed = 0, tests = MAXVAL, prev = 0, curr = 0;
> struct timeval time;
>
> if (argc > 1)
> if (sscanf(argv[1], "%d", &tests) != 1)
> return 1;
>
> for (curr = MINVAL; curr < tests; curr++) {
> retval = alarm(curr);
> gettimeofday(&time, NULL);
> printf("[%li] alarm(%d), want retval:%d; ",
> time.tv_sec, curr, prev);
> /* was there a previous alarm? */
> if (retval == NOALARM && prev == NOALARM) {
> printf("got retval:0 (PASS)");
> } else if (retval == NOALARM && prev > NOALARM) {
> printf("got retval:0 (FAIL)");
> failed++;
> } else if (retval != prev) {
> printf("got retval:%d (FAIL)", retval);
> failed++;
> } else {
> printf("got retval:%d (PASS)", retval);
> }
> printf("\n");
> prev = curr;
> }
> printf("%d/%d tests failed\n", failed, tests);
> return failed;
> }
>
> ---- End alarm.c ----
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
>

--
George Anzinger george@mvista.com
High-res-timers: http://sourceforge.net/projects/high-res-timers/
Preemption patch: http://www.kernel.org/pub/linux/kernel/people/rml

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:46    [W:0.227 / U:0.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site