linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: george anzinger <george@mvista.com>
To: Andrew Morton <akpm@osdl.org>
Cc: john stultz <johnstul@us.ibm.com>,
	linux-kernel@vger.kernel.org, Amos Waterland <apw@us.ibm.com>
Subject: Re: Fw: Re: 2.5 kernel regression in alarm() syscall behaviour?
Date: Mon, 14 Jul 2003 17:16:06 -0700	[thread overview]
Message-ID: <3F1347C6.3030105@mvista.com> (raw)
In-Reply-To: <20030714101656.73cdb75f.akpm@osdl.org>

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


       reply	other threads:[~2003-07-17 23:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20030714101656.73cdb75f.akpm@osdl.org>
2003-07-15  0:16 ` george anzinger [this message]
2003-07-15  1:53   ` Fw: Re: 2.5 kernel regression in alarm() syscall behaviour? Amos Waterland
2003-07-15  2:21     ` george anzinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3F1347C6.3030105@mvista.com \
    --to=george@mvista.com \
    --cc=akpm@osdl.org \
    --cc=apw@us.ibm.com \
    --cc=johnstul@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).