public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: george anzinger <george@mvista.com>
To: Andrew Morton <akpm@digeo.com>,
	Richard C Bilson <rcbilson@plg2.math.uwaterloo.ca>
Cc: linux-kernel@vger.kernel.org, Eric Piel <Eric.Piel@Bull.Net>
Subject: Re:  setitimer 1 usec fails
Date: Mon, 26 May 2003 15:00:53 -0700	[thread overview]
Message-ID: <3ED28E95.6000701@mvista.com> (raw)
In-Reply-To: <20030526142555.67a79694.akpm@digeo.com>

Andrew Morton wrote:
> Spotted on lkml...
> 
> 
> 
> Begin forwarded message:
> 
> Date: Mon, 26 May 2003 17:09:34 -0400
> From: Richard C Bilson <rcbilson@plg2.math.uwaterloo.ca>
> To: linux-kernel@vger.kernel.org
> Subject: setitimer 1 usec fails
> 
> 
> In trying the latest development kernel, I've noticed that calling
> setitimer with a 1 usec delay (the shortest possible delay) results in
> the timer never going off.  2 usec is ok but 1 is not, so I suspect
> that somehow things are being rounded off incorrectly.  The attached
> program demonstrates the problem on 2.5.69, but runs correctly on a
> 2.4.20 kernel.
> 
> I have only had the opportunity to try this on a single architecture
> (ia64), so if anyone can convince me that it's a platform-specific
> problem I'll be happy to take my gripe to the ia64 list.  I've tried to
> figure out how the usecs are converted to jiffies, but the code is
> sufficiently convoluted that I thought I'd throw it out in the hope of
> finding someone who understands the situation a little better.

I am not sure, but this could be related to the HZ=1024 problem Eric 
Piel and I are trying to run down.  This is a rather bad choice for HZ 
due to round off error on the conversions to usec.  We THINK the 
right thing to do is to convert to nsec (this is for TICK_NSEC()), 
directly rather than first to usec and then to nsec.

The additional problem is that the ntp code attempts to correct for 
the roundoff error which makes for an always correcting wall clock 
(even without turning on ntp).  What is needed and what I am trying to 
find time to do, is to convert the ntp code to work from the nsec 
resolution of xtime rather from the old usec resolution.  Problem is I 
don't know the ntp code so it is a bit of a learning curve.

Help here is welcome!!

As a test, you might try your test with HZ=1000 (a number I recommend 
for ia64, if at all possible).

-g
> 
> - Richard
> 
> // When run, this program should print "handled alarm" from within the
> // signal handler, and "out of sigsuspend" right after.  It works on
> // 2.4.20 or if MY_TIMER_USEC is >= 2, but not on 2.5.69 with
> // MY_TIMER_USEC = 1.
> 
> #define MY_TIMER_USEC 1
> 
> #include <stdio.h>
> #include <unistd.h>
> #include <signal.h>
> #include <sys/time.h>
> 
> void
> alarm_handler( int x )
> {
>   printf( "handled alarm\n" );
>   return;
> }
> 
> int
> main()
> {
>   struct itimerval it = { { 0, 0 }, { 0, MY_TIMER_USEC } };
>   sigset_t mask;
>   struct sigaction act;
> 
>   act.sa_handler = alarm_handler;
>   act.sa_flags = 0;
>   sigemptyset( &act.sa_mask );
>   if( sigaction(SIGALRM, &act, 0) ) {
>     perror( "sigaction" );
>     exit( 1 );
>   }
>   
>   if( setitimer(ITIMER_REAL, &it, 0) ) {
>     perror( "setitimer" );
>     exit( 1 );
>   }
>   
>   sigemptyset( &mask );
>   sigsuspend( &mask );
>   
>   printf( "out of sigsuspend\n" );
>   return 0;
> }
> 

-- 
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-05-26 21:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20030526142555.67a79694.akpm@digeo.com>
2003-05-26 22:00 ` george anzinger [this message]
2003-05-27  9:05   ` setitimer 1 usec fails Eric Piel
2003-05-27 18:27   ` David Mosberger
2003-05-27 20:01     ` george anzinger
2003-05-27 17:19 Richard C Bilson
  -- strict thread matches above, loose matches on Subject: below --
2003-05-26 21:09 Richard C Bilson

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=3ED28E95.6000701@mvista.com \
    --to=george@mvista.com \
    --cc=Eric.Piel@Bull.Net \
    --cc=akpm@digeo.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rcbilson@plg2.math.uwaterloo.ca \
    /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