* [PATCH 12/13] hrtimer: optimize hrtimer_get_remaining
@ 2006-02-13 1:11 Roman Zippel
2006-02-13 14:12 ` Ingo Molnar
0 siblings, 1 reply; 2+ messages in thread
From: Roman Zippel @ 2006-02-13 1:11 UTC (permalink / raw)
To: Andrew Morton, tglx, linux-kernel
hrtimer_get_remaining doesn't need to lock the hrtimer_base to read the
time. Also use hrtimer_get_remaining at two other places.
Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
kernel/hrtimer.c | 18 +++---------------
1 file changed, 3 insertions(+), 15 deletions(-)
Index: linux-2.6-git/kernel/hrtimer.c
===================================================================
--- linux-2.6-git.orig/kernel/hrtimer.c 2006-02-13 01:39:19.000000000 +0100
+++ linux-2.6-git/kernel/hrtimer.c 2006-02-13 01:41:59.000000000 +0100
@@ -482,15 +482,7 @@ int hrtimer_cancel(struct hrtimer *timer
*/
ktime_t hrtimer_get_remaining(const struct hrtimer *timer)
{
- struct hrtimer_base *base;
- unsigned long flags;
- ktime_t rem;
-
- base = lock_hrtimer_base(timer, &flags);
- rem = ktime_sub(timer->expires, timer->base->get_time());
- unlock_hrtimer_base(timer, &flags);
-
- return rem;
+ return ktime_sub(timer->expires, timer->base->get_time());
}
/**
@@ -639,7 +631,6 @@ static long __sched nanosleep_restart(st
struct sleep_hrtimer t;
struct timespec __user *rmtp;
struct timespec tu;
- ktime_t time;
restart->fn = do_no_restart_syscall;
@@ -650,8 +641,7 @@ static long __sched nanosleep_restart(st
rmtp = (struct timespec __user *) restart->arg2;
if (rmtp) {
- time = ktime_sub(t.timer.expires, t.timer.base->get_time());
- tu = ktime_to_timespec(time);
+ tu = ktime_to_timespec(hrtimer_get_remaining(&t.timer));
if (copy_to_user(rmtp, &tu, sizeof(tu)))
return -EFAULT;
}
@@ -668,7 +658,6 @@ long hrtimer_nanosleep(struct timespec *
struct restart_block *restart;
struct sleep_hrtimer t;
struct timespec tu;
- ktime_t rem;
hrtimer_init(&t.timer, clockid, mode);
t.timer.expires = timespec_to_ktime(*rqtp);
@@ -680,8 +669,7 @@ long hrtimer_nanosleep(struct timespec *
return -ERESTARTNOHAND;
if (rmtp) {
- rem = ktime_sub(t.timer.expires, t.timer.base->get_time());
- tu = ktime_to_timespec(rem);
+ tu = ktime_to_timespec(hrtimer_get_remaining(&t.timer));
if (copy_to_user(rmtp, &tu, sizeof(tu)))
return -EFAULT;
}
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH 12/13] hrtimer: optimize hrtimer_get_remaining
2006-02-13 1:11 [PATCH 12/13] hrtimer: optimize hrtimer_get_remaining Roman Zippel
@ 2006-02-13 14:12 ` Ingo Molnar
0 siblings, 0 replies; 2+ messages in thread
From: Ingo Molnar @ 2006-02-13 14:12 UTC (permalink / raw)
To: Roman Zippel; +Cc: Andrew Morton, tglx, linux-kernel
* Roman Zippel <zippel@linux-m68k.org> wrote:
> hrtimer_get_remaining doesn't need to lock the hrtimer_base to read
> the time. Also use hrtimer_get_remaining at two other places.
nack - it's not only about ->get_time() atomicity:
> - base = lock_hrtimer_base(timer, &flags);
> - rem = ktime_sub(timer->expires, timer->base->get_time());
> - unlock_hrtimer_base(timer, &flags);
timer->expires is a 64-bit value, which might be read nonatomically on
32-bit platforms. Wherever it's safe, we already open-code this
ktime_sub() - if you find more places then please do it that way.
definitely not something for v2.6.16.
Ingo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-02-13 14:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-13 1:11 [PATCH 12/13] hrtimer: optimize hrtimer_get_remaining Roman Zippel
2006-02-13 14:12 ` Ingo Molnar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®