aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorRoman Zippel <zippel@linux-m68k.org>2006-03-26 04:38:12 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-26 11:57:03 -0500
commit05cfb614ddbf3181540ce09d44d96486f8ba8d6a (patch)
treeaafed98638557a4643141d906fbb2406f0764a94 /kernel
parentdf869b630d9d9131c10cf073fb61646048874b2f (diff)
[PATCH] hrtimers: remove data field
The nanosleep cleanup allows to remove the data field of hrtimer. The callback function can use container_of() to get it's own data. Since the hrtimer structure is anyway embedded in other structures, this adds no overhead. Signed-off-by: Roman Zippel <zippel@linux-m68k.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/fork.c2
-rw-r--r--kernel/hrtimer.c12
-rw-r--r--kernel/itimer.c15
-rw-r--r--kernel/posix-timers.c9
4 files changed, 17 insertions, 21 deletions
diff --git a/kernel/fork.c b/kernel/fork.c
index a02063903aaa..4bd6486aa67d 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -848,7 +848,7 @@ static inline int copy_signal(unsigned long clone_flags, struct task_struct * ts
848 hrtimer_init(&sig->real_timer, CLOCK_MONOTONIC, HRTIMER_REL); 848 hrtimer_init(&sig->real_timer, CLOCK_MONOTONIC, HRTIMER_REL);
849 sig->it_real_incr.tv64 = 0; 849 sig->it_real_incr.tv64 = 0;
850 sig->real_timer.function = it_real_fn; 850 sig->real_timer.function = it_real_fn;
851 sig->real_timer.data = tsk; 851 sig->tsk = tsk;
852 852
853 sig->it_virt_expires = cputime_zero; 853 sig->it_virt_expires = cputime_zero;
854 sig->it_virt_incr = cputime_zero; 854 sig->it_virt_incr = cputime_zero;
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
index 44108de4f028..0237a556eb1f 100644
--- a/kernel/hrtimer.c
+++ b/kernel/hrtimer.c
@@ -613,21 +613,19 @@ static inline void run_hrtimer_queue(struct hrtimer_base *base)
613 613
614 while ((node = base->first)) { 614 while ((node = base->first)) {
615 struct hrtimer *timer; 615 struct hrtimer *timer;
616 int (*fn)(void *); 616 int (*fn)(struct hrtimer *);
617 int restart; 617 int restart;
618 void *data;
619 618
620 timer = rb_entry(node, struct hrtimer, node); 619 timer = rb_entry(node, struct hrtimer, node);
621 if (base->softirq_time.tv64 <= timer->expires.tv64) 620 if (base->softirq_time.tv64 <= timer->expires.tv64)
622 break; 621 break;
623 622
624 fn = timer->function; 623 fn = timer->function;
625 data = timer->data;
626 set_curr_timer(base, timer); 624 set_curr_timer(base, timer);
627 __remove_hrtimer(timer, base); 625 __remove_hrtimer(timer, base);
628 spin_unlock_irq(&base->lock); 626 spin_unlock_irq(&base->lock);
629 627
630 restart = fn(data); 628 restart = fn(timer);
631 629
632 spin_lock_irq(&base->lock); 630 spin_lock_irq(&base->lock);
633 631
@@ -664,9 +662,10 @@ struct sleep_hrtimer {
664 int expired; 662 int expired;
665}; 663};
666 664
667static int nanosleep_wakeup(void *data) 665static int nanosleep_wakeup(struct hrtimer *timer)
668{ 666{
669 struct sleep_hrtimer *t = data; 667 struct sleep_hrtimer *t =
668 container_of(timer, struct sleep_hrtimer, timer);
670 669
671 t->expired = 1; 670 t->expired = 1;
672 wake_up_process(t->task); 671 wake_up_process(t->task);
@@ -677,7 +676,6 @@ static int nanosleep_wakeup(void *data)
677static int __sched do_nanosleep(struct sleep_hrtimer *t, enum hrtimer_mode mode) 676static int __sched do_nanosleep(struct sleep_hrtimer *t, enum hrtimer_mode mode)
678{ 677{
679 t->timer.function = nanosleep_wakeup; 678 t->timer.function = nanosleep_wakeup;
680 t->timer.data = t;
681 t->task = current; 679 t->task = current;
682 t->expired = 0; 680 t->expired = 0;
683 681
diff --git a/kernel/itimer.c b/kernel/itimer.c
index af2ec6b4392c..204ed7939e75 100644
--- a/kernel/itimer.c
+++ b/kernel/itimer.c
@@ -128,17 +128,16 @@ asmlinkage long sys_getitimer(int which, struct itimerval __user *value)
128/* 128/*
129 * The timer is automagically restarted, when interval != 0 129 * The timer is automagically restarted, when interval != 0
130 */ 130 */
131int it_real_fn(void *data) 131int it_real_fn(struct hrtimer *timer)
132{ 132{
133 struct task_struct *tsk = (struct task_struct *) data; 133 struct signal_struct *sig =
134 container_of(timer, struct signal_struct, real_timer);
134 135
135 send_group_sig_info(SIGALRM, SEND_SIG_PRIV, tsk); 136 send_group_sig_info(SIGALRM, SEND_SIG_PRIV, sig->tsk);
136
137 if (tsk->signal->it_real_incr.tv64 != 0) {
138 hrtimer_forward(&tsk->signal->real_timer,
139 tsk->signal->real_timer.base->softirq_time,
140 tsk->signal->it_real_incr);
141 137
138 if (sig->it_real_incr.tv64 != 0) {
139 hrtimer_forward(timer, timer->base->softirq_time,
140 sig->it_real_incr);
142 return HRTIMER_RESTART; 141 return HRTIMER_RESTART;
143 } 142 }
144 return HRTIMER_NORESTART; 143 return HRTIMER_NORESTART;
diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
index 7c5f44787c8c..ac6dc8744429 100644
--- a/kernel/posix-timers.c
+++ b/kernel/posix-timers.c
@@ -145,7 +145,7 @@ static int common_timer_set(struct k_itimer *, int,
145 struct itimerspec *, struct itimerspec *); 145 struct itimerspec *, struct itimerspec *);
146static int common_timer_del(struct k_itimer *timer); 146static int common_timer_del(struct k_itimer *timer);
147 147
148static int posix_timer_fn(void *data); 148static int posix_timer_fn(struct hrtimer *data);
149 149
150static struct k_itimer *lock_timer(timer_t timer_id, unsigned long *flags); 150static struct k_itimer *lock_timer(timer_t timer_id, unsigned long *flags);
151 151
@@ -334,14 +334,14 @@ EXPORT_SYMBOL_GPL(posix_timer_event);
334 334
335 * This code is for CLOCK_REALTIME* and CLOCK_MONOTONIC* timers. 335 * This code is for CLOCK_REALTIME* and CLOCK_MONOTONIC* timers.
336 */ 336 */
337static int posix_timer_fn(void *data) 337static int posix_timer_fn(struct hrtimer *timer)
338{ 338{
339 struct k_itimer *timr = data; 339 struct k_itimer *timr;
340 struct hrtimer *timer = &timr->it.real.timer;
341 unsigned long flags; 340 unsigned long flags;
342 int si_private = 0; 341 int si_private = 0;
343 int ret = HRTIMER_NORESTART; 342 int ret = HRTIMER_NORESTART;
344 343
344 timr = container_of(timer, struct k_itimer, it.real.timer);
345 spin_lock_irqsave(&timr->it_lock, flags); 345 spin_lock_irqsave(&timr->it_lock, flags);
346 346
347 if (timr->it.real.interval.tv64 != 0) 347 if (timr->it.real.interval.tv64 != 0)
@@ -725,7 +725,6 @@ common_timer_set(struct k_itimer *timr, int flags,
725 725
726 mode = flags & TIMER_ABSTIME ? HRTIMER_ABS : HRTIMER_REL; 726 mode = flags & TIMER_ABSTIME ? HRTIMER_ABS : HRTIMER_REL;
727 hrtimer_init(&timr->it.real.timer, timr->it_clock, mode); 727 hrtimer_init(&timr->it.real.timer, timr->it_clock, mode);
728 timr->it.real.timer.data = timr;
729 timr->it.real.timer.function = posix_timer_fn; 728 timr->it.real.timer.function = posix_timer_fn;
730 729
731 timer->expires = timespec_to_ktime(new_setting->it_value); 730 timer->expires = timespec_to_ktime(new_setting->it_value);