Commit 5cb38bc4 authored by Jeff Dike's avatar Jeff Dike Committed by Linus Torvalds

[PATCH] uml: fix wall_to_monotonic initialization

From: Jeff Dike <jdike@addtoit.com>

Initialize wall_to_monotonic correctly.  This fixes a problem where sleeps
lasted about one secone less than they should.  This also called for a bit of
code restructuring, following a patch which Blaisorblade had been keeping.
Signed-off-by: default avatarJeff Dike <jdike@addtoit.com>
Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 65e62974
...@@ -120,20 +120,11 @@ extern int is_syscall(unsigned long addr); ...@@ -120,20 +120,11 @@ extern int is_syscall(unsigned long addr);
extern void free_irq(unsigned int, void *); extern void free_irq(unsigned int, void *);
extern int cpu(void); extern int cpu(void);
extern void time_init_kern(void);
/* Are we disallowed to sleep? Used to choose between GFP_KERNEL and GFP_ATOMIC. */ /* Are we disallowed to sleep? Used to choose between GFP_KERNEL and GFP_ATOMIC. */
extern int __cant_sleep(void); extern int __cant_sleep(void);
extern void segv_handler(int sig, union uml_pt_regs *regs); extern void segv_handler(int sig, union uml_pt_regs *regs);
extern void sigio_handler(int sig, union uml_pt_regs *regs); extern void sigio_handler(int sig, union uml_pt_regs *regs);
#endif #endif
/*
* Overrides for Emacs so that we follow Linus's tabbing style.
* Emacs will notice this stuff at the end of the file and automatically
* adjust the settings for this buffer only. This must remain at the end
* of the file.
* ---------------------------------------------------------------------------
* Local variables:
* c-file-style: "linux"
* End:
*/
...@@ -84,6 +84,16 @@ void timer_irq(union uml_pt_regs *regs) ...@@ -84,6 +84,16 @@ void timer_irq(union uml_pt_regs *regs)
} }
} }
void time_init_kern(void)
{
unsigned long long nsecs;
nsecs = os_nsecs();
set_normalized_timespec(&wall_to_monotonic, -nsecs / BILLION,
-nsecs % BILLION);
}
void do_boot_timer_handler(struct sigcontext * sc) void do_boot_timer_handler(struct sigcontext * sc)
{ {
struct pt_regs regs; struct pt_regs regs;
......
...@@ -81,20 +81,12 @@ void uml_idle_timer(void) ...@@ -81,20 +81,12 @@ void uml_idle_timer(void)
set_interval(ITIMER_REAL); set_interval(ITIMER_REAL);
} }
extern void ktime_get_ts(struct timespec *ts);
#define do_posix_clock_monotonic_gettime(ts) ktime_get_ts(ts)
void time_init(void) void time_init(void)
{ {
struct timespec now;
if(signal(SIGVTALRM, boot_timer_handler) == SIG_ERR) if(signal(SIGVTALRM, boot_timer_handler) == SIG_ERR)
panic("Couldn't set SIGVTALRM handler"); panic("Couldn't set SIGVTALRM handler");
set_interval(ITIMER_VIRTUAL); set_interval(ITIMER_VIRTUAL);
time_init_kern();
do_posix_clock_monotonic_gettime(&now);
wall_to_monotonic.tv_sec = -now.tv_sec;
wall_to_monotonic.tv_nsec = -now.tv_nsec;
} }
unsigned long long os_nsecs(void) unsigned long long os_nsecs(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment