* [PATCH 11/19] UML - Track and make up lost ticks
@ 2008-04-25 17:56 Jeff Dike
2008-04-29 18:54 ` Nix
0 siblings, 1 reply; 7+ messages in thread
From: Jeff Dike @ 2008-04-25 17:56 UTC (permalink / raw)
To: Andrew Morton, LKML, uml-devel; +Cc: Nix
Alarm delivery could be noticably late in the !CONFIG_NOHZ case
because lost ticks weren't being taken into account. This is now
treated more carefully, with the time between ticks being calculated
and the appropriate number of ticks delivered to the timekeeping system.
Cc: Nix <nix@esperi.org.uk>
Signed-off-by: Jeff Dike <jdike@linux.intel.com>
---
arch/um/os-Linux/time.c | 54 ++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 50 insertions(+), 4 deletions(-)
Index: linux-2.6-git/arch/um/os-Linux/time.c
===================================================================
--- linux-2.6-git.orig/arch/um/os-Linux/time.c 2008-04-25 10:42:12.000000000 -0400
+++ linux-2.6-git/arch/um/os-Linux/time.c 2008-04-25 11:19:26.000000000 -0400
@@ -9,7 +9,9 @@
#include <time.h>
#include <sys/time.h>
#include "kern_constants.h"
+#include "kern_util.h"
#include "os.h"
+#include "process.h"
#include "user.h"
int set_interval(void)
@@ -58,12 +60,17 @@ static inline long long timeval_to_ns(co
long long disable_timer(void)
{
struct itimerval time = ((struct itimerval) { { 0, 0 }, { 0, 0 } });
+ int remain, max = UM_NSEC_PER_SEC / UM_HZ;
if (setitimer(ITIMER_VIRTUAL, &time, &time) < 0)
printk(UM_KERN_ERR "disable_timer - setitimer failed, "
"errno = %d\n", errno);
- return timeval_to_ns(&time.it_value);
+ remain = timeval_to_ns(&time.it_value);
+ if (remain > max)
+ remain = max;
+
+ return remain;
}
long long os_nsecs(void)
@@ -79,7 +86,44 @@ static int after_sleep_interval(struct t
{
return 0;
}
+
+static void deliver_alarm(void)
+{
+ alarm_handler(SIGVTALRM, NULL);
+}
+
+static unsigned long long sleep_time(unsigned long long nsecs)
+{
+ return nsecs;
+}
+
#else
+unsigned long long last_tick;
+unsigned long long skew;
+
+static void deliver_alarm(void)
+{
+ unsigned long long this_tick = os_nsecs();
+ int one_tick = UM_NSEC_PER_SEC / UM_HZ;
+
+ if (last_tick == 0)
+ last_tick = this_tick - one_tick;
+
+ skew += this_tick - last_tick;
+
+ while (skew >= one_tick) {
+ alarm_handler(SIGVTALRM, NULL);
+ skew -= one_tick;
+ }
+
+ last_tick = this_tick;
+}
+
+static unsigned long long sleep_time(unsigned long long nsecs)
+{
+ return nsecs > skew ? nsecs - skew : 0;
+}
+
static inline long long timespec_to_us(const struct timespec *ts)
{
return ((long long) ts->tv_sec * UM_USEC_PER_SEC) +
@@ -102,6 +146,8 @@ static int after_sleep_interval(struct t
*/
if (start_usecs > usec)
start_usecs = usec;
+
+ start_usecs -= skew / UM_NSEC_PER_USEC;
tv = ((struct timeval) { .tv_sec = start_usecs / UM_USEC_PER_SEC,
.tv_usec = start_usecs % UM_USEC_PER_SEC });
interval = ((struct itimerval) { { 0, usec }, tv });
@@ -113,8 +159,6 @@ static int after_sleep_interval(struct t
}
#endif
-extern void alarm_handler(int sig, struct sigcontext *sc);
-
void idle_sleep(unsigned long long nsecs)
{
struct timespec ts;
@@ -126,10 +170,12 @@ void idle_sleep(unsigned long long nsecs
*/
if (nsecs == 0)
nsecs = UM_NSEC_PER_SEC / UM_HZ;
+
+ nsecs = sleep_time(nsecs);
ts = ((struct timespec) { .tv_sec = nsecs / UM_NSEC_PER_SEC,
.tv_nsec = nsecs % UM_NSEC_PER_SEC });
if (nanosleep(&ts, &ts) == 0)
- alarm_handler(SIGVTALRM, NULL);
+ deliver_alarm();
after_sleep_interval(&ts);
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 11/19] UML - Track and make up lost ticks
2008-04-25 17:56 [PATCH 11/19] UML - Track and make up lost ticks Jeff Dike
@ 2008-04-29 18:54 ` Nix
2008-04-29 20:29 ` Jeff Dike
0 siblings, 1 reply; 7+ messages in thread
From: Nix @ 2008-04-29 18:54 UTC (permalink / raw)
To: Jeff Dike; +Cc: Andrew Morton, LKML, uml-devel
On 25 Apr 2008, Jeff Dike stated, in part:
> Index: linux-2.6-git/arch/um/os-Linux/time.c
> ===================================================================
> --- linux-2.6-git.orig/arch/um/os-Linux/time.c 2008-04-25 10:42:12.000000000 -0400
> +++ linux-2.6-git/arch/um/os-Linux/time.c 2008-04-25 11:19:26.000000000 -0400
> + alarm_handler(SIGVTALRM, NULL);
> + alarm_handler(SIGVTALRM, NULL);
> -extern void alarm_handler(int sig, struct sigcontext *sc);
> - alarm_handler(SIGVTALRM, NULL);
Yet, in arch/um/include/process.h, we see, unchanged since the year dot, the
obviously wrong prototype:
extern void alarm_handler(int sig, struct sigcontext sc);
Hence:
CC arch/um/os-Linux/time.o
arch/um/os-Linux/time.c: In function ‘deliver_alarm’:
arch/um/os-Linux/time.c:119: error: incompatible type for argument 2 of ‘alarm_handler’
make[1]: *** [arch/um/os-Linux/time.o] Error 1
make: *** [arch/um/os-Linux] Error 2
Fix trivial:
Signed-off-by: Nick Alcock <nix@esperi.org.uk>
--
Index: linux/arch/um/include/process.h
===================================================================
--- linux.orig/arch/um/include/process.h 2006-07-09 14:19:52.000000000 +0100
+++ linux/arch/um/include/process.h 2008-04-29 19:49:49.000000000 +0100
@@ -8,8 +8,8 @@
#include <signal.h>
-extern void sig_handler(int sig, struct sigcontext sc);
-extern void alarm_handler(int sig, struct sigcontext sc);
+extern void sig_handler(int sig, struct sigcontext *sc);
+extern void alarm_handler(int sig, struct sigcontext *sc);
#endif
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 11/19] UML - Track and make up lost ticks
2008-04-29 18:54 ` Nix
@ 2008-04-29 20:29 ` Jeff Dike
2008-05-06 20:46 ` Andrew Morton
0 siblings, 1 reply; 7+ messages in thread
From: Jeff Dike @ 2008-04-29 20:29 UTC (permalink / raw)
To: Nix; +Cc: Andrew Morton, LKML, uml-devel
On Tue, Apr 29, 2008 at 07:54:02PM +0100, Nix wrote:
> On 25 Apr 2008, Jeff Dike stated, in part:
> > Index: linux-2.6-git/arch/um/os-Linux/time.c
> > ===================================================================
> > --- linux-2.6-git.orig/arch/um/os-Linux/time.c 2008-04-25 10:42:12.000000000 -0400
> > +++ linux-2.6-git/arch/um/os-Linux/time.c 2008-04-25 11:19:26.000000000 -0400
> > + alarm_handler(SIGVTALRM, NULL);
> > + alarm_handler(SIGVTALRM, NULL);
> > -extern void alarm_handler(int sig, struct sigcontext *sc);
> > - alarm_handler(SIGVTALRM, NULL);
>
> Yet, in arch/um/include/process.h, we see, unchanged since the year dot, the
> obviously wrong prototype:
>
> extern void alarm_handler(int sig, struct sigcontext sc);
>
> Hence:
>
> CC arch/um/os-Linux/time.o
> arch/um/os-Linux/time.c: In function ‘deliver_alarm’:
> arch/um/os-Linux/time.c:119: error: incompatible type for argument 2 of ‘alarm_handler’
> make[1]: *** [arch/um/os-Linux/time.o] Error 1
> make: *** [arch/um/os-Linux] Error 2
>
> Fix trivial:
>
> Signed-off-by: Nick Alcock <nix@esperi.org.uk>
> --
> Index: linux/arch/um/include/process.h
> ===================================================================
> --- linux.orig/arch/um/include/process.h 2006-07-09 14:19:52.000000000 +0100
> +++ linux/arch/um/include/process.h 2008-04-29 19:49:49.000000000 +0100
> @@ -8,8 +8,8 @@
>
> #include <signal.h>
>
> -extern void sig_handler(int sig, struct sigcontext sc);
> -extern void alarm_handler(int sig, struct sigcontext sc);
> +extern void sig_handler(int sig, struct sigcontext *sc);
> +extern void alarm_handler(int sig, struct sigcontext *sc);
>
> #endif
Crap, I fixed that, but forgot to quilt add it, I guess.
ACK.
Jeff
--
Work email - jdike at linux dot intel dot com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 11/19] UML - Track and make up lost ticks
2008-04-29 20:29 ` Jeff Dike
@ 2008-05-06 20:46 ` Andrew Morton
2008-05-06 21:44 ` [uml-devel] " Jeff Dike
0 siblings, 1 reply; 7+ messages in thread
From: Andrew Morton @ 2008-05-06 20:46 UTC (permalink / raw)
To: Jeff Dike; +Cc: nix, linux-kernel, user-mode-linux-devel
On Tue, 29 Apr 2008 16:29:25 -0400
Jeff Dike <jdike@addtoit.com> wrote:
> On Tue, Apr 29, 2008 at 07:54:02PM +0100, Nix wrote:
> > On 25 Apr 2008, Jeff Dike stated, in part:
> > > Index: linux-2.6-git/arch/um/os-Linux/time.c
> > > ===================================================================
> > > --- linux-2.6-git.orig/arch/um/os-Linux/time.c 2008-04-25 10:42:12.000000000 -0400
> > > +++ linux-2.6-git/arch/um/os-Linux/time.c 2008-04-25 11:19:26.000000000 -0400
> > > + alarm_handler(SIGVTALRM, NULL);
> > > + alarm_handler(SIGVTALRM, NULL);
> > > -extern void alarm_handler(int sig, struct sigcontext *sc);
> > > - alarm_handler(SIGVTALRM, NULL);
> >
> > Yet, in arch/um/include/process.h, we see, unchanged since the year dot, the
> > obviously wrong prototype:
> >
> > extern void alarm_handler(int sig, struct sigcontext sc);
> >
> > Hence:
> >
> > CC arch/um/os-Linux/time.o
> > arch/um/os-Linux/time.c: In function ‘deliver_alarm’:
> > arch/um/os-Linux/time.c:119: error: incompatible type for argument 2 of ‘alarm_handler’
> > make[1]: *** [arch/um/os-Linux/time.o] Error 1
> > make: *** [arch/um/os-Linux] Error 2
> >
> > Fix trivial:
> >
> > Signed-off-by: Nick Alcock <nix@esperi.org.uk>
> > --
> > Index: linux/arch/um/include/process.h
> > ===================================================================
> > --- linux.orig/arch/um/include/process.h 2006-07-09 14:19:52.000000000 +0100
> > +++ linux/arch/um/include/process.h 2008-04-29 19:49:49.000000000 +0100
> > @@ -8,8 +8,8 @@
> >
> > #include <signal.h>
> >
> > -extern void sig_handler(int sig, struct sigcontext sc);
> > -extern void alarm_handler(int sig, struct sigcontext sc);
> > +extern void sig_handler(int sig, struct sigcontext *sc);
> > +extern void alarm_handler(int sig, struct sigcontext *sc);
> >
> > #endif
>
> Crap, I fixed that, but forgot to quilt add it, I guess.
>
> ACK.
>
This fix was already present in your "[PATCH 4/19] UML - Random driver fixes".
Perhaps we broke bisection?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [uml-devel] [PATCH 11/19] UML - Track and make up lost ticks
2008-05-06 20:46 ` Andrew Morton
@ 2008-05-06 21:44 ` Jeff Dike
2008-05-06 22:01 ` Andrew Morton
0 siblings, 1 reply; 7+ messages in thread
From: Jeff Dike @ 2008-05-06 21:44 UTC (permalink / raw)
To: Andrew Morton; +Cc: nix, linux-kernel, user-mode-linux-devel
On Tue, May 06, 2008 at 01:46:55PM -0700, Andrew Morton wrote:
> This fix was already present in your "[PATCH 4/19] UML - Random driver fixes".
Ah, so that's where it ended up.
> Perhaps we broke bisection?
No doubt. Drop those two and I'll send fixed ones.
Jeff
--
Work email - jdike at linux dot intel dot com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [uml-devel] [PATCH 11/19] UML - Track and make up lost ticks
2008-05-06 21:44 ` [uml-devel] " Jeff Dike
@ 2008-05-06 22:01 ` Andrew Morton
2008-05-06 23:54 ` Nix
0 siblings, 1 reply; 7+ messages in thread
From: Andrew Morton @ 2008-05-06 22:01 UTC (permalink / raw)
To: Jeff Dike; +Cc: nix, linux-kernel, user-mode-linux-devel
On Tue, 6 May 2008 17:44:35 -0400
Jeff Dike <jdike@addtoit.com> wrote:
> On Tue, May 06, 2008 at 01:46:55PM -0700, Andrew Morton wrote:
> > This fix was already present in your "[PATCH 4/19] UML - Random driver fixes".
>
> Ah, so that's where it ended up.
Strange that the bug has always been there. Some other change made it
apparent?
> > Perhaps we broke bisection?
>
> No doubt. Drop those two and I'll send fixed ones.
OK. uml-random-driver-style-fixes.patch needed to go also.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [uml-devel] [PATCH 11/19] UML - Track and make up lost ticks
2008-05-06 22:01 ` Andrew Morton
@ 2008-05-06 23:54 ` Nix
0 siblings, 0 replies; 7+ messages in thread
From: Nix @ 2008-05-06 23:54 UTC (permalink / raw)
To: Andrew Morton; +Cc: Jeff Dike, linux-kernel, user-mode-linux-devel
On 6 May 2008, Andrew Morton uttered the following:
> On Tue, 6 May 2008 17:44:35 -0400
> Jeff Dike <jdike@addtoit.com> wrote:
>
>> On Tue, May 06, 2008 at 01:46:55PM -0700, Andrew Morton wrote:
>> > This fix was already present in your "[PATCH 4/19] UML - Random driver fixes".
>>
>> Ah, so that's where it ended up.
>
> Strange that the bug has always been there. Some other change made it
> apparent?
Yeah, there was a re-prototyping of the broken prototype above the only
use outside the file where the function is defined, and this patch
removed that re-prottyping. :)
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2008-05-06 23:55 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-25 17:56 [PATCH 11/19] UML - Track and make up lost ticks Jeff Dike
2008-04-29 18:54 ` Nix
2008-04-29 20:29 ` Jeff Dike
2008-05-06 20:46 ` Andrew Morton
2008-05-06 21:44 ` [uml-devel] " Jeff Dike
2008-05-06 22:01 ` Andrew Morton
2008-05-06 23:54 ` Nix
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox