diff options
author | Jeff Dike <jdike@addtoit.com> | 2006-09-26 02:33:05 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-09-26 11:49:08 -0400 |
commit | 537ae946e808d0f22d660f7a3500832fe0c07d14 (patch) | |
tree | 843f9adaa3c7de8b10c51d0059e2b567d81ff566 /arch | |
parent | 4b84c69b5f6c08a540e3683f1360a6cdef2806c7 (diff) |
[PATCH] uml: timer cleanups
set_interval returns an error instead of panicing if setitimer fails. Some of
its callers now check the return.
enable_timer is largely tt-mode-specific, so it is marked as such, and the
only skas-mode caller is made to call set-interval instead.
user_time_init was a no-value-added wrapper around set_interval, so it is
gone.
Since set_interval is now called from kernel code, callers no longer pass
ITIMER_* to it. Instead, they pass a flag which is converted into ITIMER_REAL
or ITIMER_VIRTUAL.
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/um/include/os.h | 4 | ||||
-rw-r--r-- | arch/um/kernel/time.c | 7 | ||||
-rw-r--r-- | arch/um/os-Linux/skas/process.c | 6 | ||||
-rw-r--r-- | arch/um/os-Linux/time.c | 18 |
4 files changed, 22 insertions, 13 deletions
diff --git a/arch/um/include/os.h b/arch/um/include/os.h index c73dfa78f943..24fb6d8680e1 100644 --- a/arch/um/include/os.h +++ b/arch/um/include/os.h | |||
@@ -276,9 +276,11 @@ extern int setjmp_wrapper(void (*proc)(void *, void *), ...); | |||
276 | 276 | ||
277 | extern void switch_timers(int to_real); | 277 | extern void switch_timers(int to_real); |
278 | extern void idle_sleep(int secs); | 278 | extern void idle_sleep(int secs); |
279 | extern int set_interval(int is_virtual); | ||
280 | #ifdef CONFIG_MODE_TT | ||
279 | extern void enable_timer(void); | 281 | extern void enable_timer(void); |
282 | #endif | ||
280 | extern void disable_timer(void); | 283 | extern void disable_timer(void); |
281 | extern void user_time_init(void); | ||
282 | extern void uml_idle_timer(void); | 284 | extern void uml_idle_timer(void); |
283 | extern unsigned long long os_nsecs(void); | 285 | extern unsigned long long os_nsecs(void); |
284 | 286 | ||
diff --git a/arch/um/kernel/time.c b/arch/um/kernel/time.c index 552ca1cb9847..d1d799346e04 100644 --- a/arch/um/kernel/time.c +++ b/arch/um/kernel/time.c | |||
@@ -113,12 +113,15 @@ static void register_timer(void) | |||
113 | 113 | ||
114 | err = request_irq(TIMER_IRQ, um_timer, IRQF_DISABLED, "timer", NULL); | 114 | err = request_irq(TIMER_IRQ, um_timer, IRQF_DISABLED, "timer", NULL); |
115 | if(err != 0) | 115 | if(err != 0) |
116 | printk(KERN_ERR "timer_init : request_irq failed - " | 116 | printk(KERN_ERR "register_timer : request_irq failed - " |
117 | "errno = %d\n", -err); | 117 | "errno = %d\n", -err); |
118 | 118 | ||
119 | timer_irq_inited = 1; | 119 | timer_irq_inited = 1; |
120 | 120 | ||
121 | user_time_init(); | 121 | err = set_interval(1); |
122 | if(err != 0) | ||
123 | printk(KERN_ERR "register_timer : set_interval failed - " | ||
124 | "errno = %d\n", -err); | ||
122 | } | 125 | } |
123 | 126 | ||
124 | extern void (*late_time_init)(void); | 127 | extern void (*late_time_init)(void); |
diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c index 88ff0de95cd3..42e3d1ed802c 100644 --- a/arch/um/os-Linux/skas/process.c +++ b/arch/um/os-Linux/skas/process.c | |||
@@ -155,11 +155,15 @@ extern int __syscall_stub_start; | |||
155 | static int userspace_tramp(void *stack) | 155 | static int userspace_tramp(void *stack) |
156 | { | 156 | { |
157 | void *addr; | 157 | void *addr; |
158 | int err; | ||
158 | 159 | ||
159 | ptrace(PTRACE_TRACEME, 0, 0, 0); | 160 | ptrace(PTRACE_TRACEME, 0, 0, 0); |
160 | 161 | ||
161 | init_new_thread_signals(); | 162 | init_new_thread_signals(); |
162 | enable_timer(); | 163 | err = set_interval(1); |
164 | if(err) | ||
165 | panic("userspace_tramp - setting timer failed, errno = %d\n", | ||
166 | err); | ||
163 | 167 | ||
164 | if(!proc_mm){ | 168 | if(!proc_mm){ |
165 | /* This has a pte, but it can't be mapped in with the usual | 169 | /* This has a pte, but it can't be mapped in with the usual |
diff --git a/arch/um/os-Linux/time.c b/arch/um/os-Linux/time.c index 7f5ebbadca63..38be096e750f 100644 --- a/arch/um/os-Linux/time.c +++ b/arch/um/os-Linux/time.c | |||
@@ -17,20 +17,25 @@ | |||
17 | #include "kern_constants.h" | 17 | #include "kern_constants.h" |
18 | #include "os.h" | 18 | #include "os.h" |
19 | 19 | ||
20 | static void set_interval(int timer_type) | 20 | int set_interval(int is_virtual) |
21 | { | 21 | { |
22 | int usec = 1000000/hz(); | 22 | int usec = 1000000/hz(); |
23 | int timer_type = is_virtual ? ITIMER_VIRTUAL : ITIMER_REAL; | ||
23 | struct itimerval interval = ((struct itimerval) { { 0, usec }, | 24 | struct itimerval interval = ((struct itimerval) { { 0, usec }, |
24 | { 0, usec } }); | 25 | { 0, usec } }); |
25 | 26 | ||
26 | if(setitimer(timer_type, &interval, NULL) == -1) | 27 | if(setitimer(timer_type, &interval, NULL) == -1) |
27 | panic("setitimer failed - errno = %d\n", errno); | 28 | return -errno; |
29 | |||
30 | return 0; | ||
28 | } | 31 | } |
29 | 32 | ||
33 | #ifdef CONFIG_MODE_TT | ||
30 | void enable_timer(void) | 34 | void enable_timer(void) |
31 | { | 35 | { |
32 | set_interval(ITIMER_VIRTUAL); | 36 | set_interval(1); |
33 | } | 37 | } |
38 | #endif | ||
34 | 39 | ||
35 | void disable_timer(void) | 40 | void disable_timer(void) |
36 | { | 41 | { |
@@ -74,7 +79,7 @@ void uml_idle_timer(void) | |||
74 | 79 | ||
75 | set_handler(SIGALRM, (__sighandler_t) alarm_handler, | 80 | set_handler(SIGALRM, (__sighandler_t) alarm_handler, |
76 | SA_RESTART, SIGUSR1, SIGIO, SIGWINCH, SIGVTALRM, -1); | 81 | SA_RESTART, SIGUSR1, SIGIO, SIGWINCH, SIGVTALRM, -1); |
77 | set_interval(ITIMER_REAL); | 82 | set_interval(0); |
78 | } | 83 | } |
79 | #endif | 84 | #endif |
80 | 85 | ||
@@ -94,8 +99,3 @@ void idle_sleep(int secs) | |||
94 | ts.tv_nsec = 0; | 99 | ts.tv_nsec = 0; |
95 | nanosleep(&ts, NULL); | 100 | nanosleep(&ts, NULL); |
96 | } | 101 | } |
97 | |||
98 | void user_time_init(void) | ||
99 | { | ||
100 | set_interval(ITIMER_VIRTUAL); | ||
101 | } | ||