提交 05cfb614 编写于 作者: R Roman Zippel 提交者: Linus Torvalds

[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: NRoman Zippel <zippel@linux-m68k.org>
Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 df869b63
...@@ -632,7 +632,7 @@ static int de_thread(struct task_struct *tsk) ...@@ -632,7 +632,7 @@ static int de_thread(struct task_struct *tsk)
* synchronize with any firing (by calling del_timer_sync) * synchronize with any firing (by calling del_timer_sync)
* before we can safely let the old group leader die. * before we can safely let the old group leader die.
*/ */
sig->real_timer.data = current; sig->tsk = current;
spin_unlock_irq(lock); spin_unlock_irq(lock);
if (hrtimer_cancel(&sig->real_timer)) if (hrtimer_cancel(&sig->real_timer))
hrtimer_restart(&sig->real_timer); hrtimer_restart(&sig->real_timer);
......
...@@ -45,9 +45,7 @@ struct hrtimer_base; ...@@ -45,9 +45,7 @@ struct hrtimer_base;
* @expires: the absolute expiry time in the hrtimers internal * @expires: the absolute expiry time in the hrtimers internal
* representation. The time is related to the clock on * representation. The time is related to the clock on
* which the timer is based. * which the timer is based.
* @state: state of the timer
* @function: timer expiry callback function * @function: timer expiry callback function
* @data: argument for the callback function
* @base: pointer to the timer base (per cpu and per clock) * @base: pointer to the timer base (per cpu and per clock)
* *
* The hrtimer structure must be initialized by init_hrtimer_#CLOCKTYPE() * The hrtimer structure must be initialized by init_hrtimer_#CLOCKTYPE()
...@@ -55,8 +53,7 @@ struct hrtimer_base; ...@@ -55,8 +53,7 @@ struct hrtimer_base;
struct hrtimer { struct hrtimer {
struct rb_node node; struct rb_node node;
ktime_t expires; ktime_t expires;
int (*function)(void *); int (*function)(struct hrtimer *);
void *data;
struct hrtimer_base *base; struct hrtimer_base *base;
}; };
......
...@@ -402,6 +402,7 @@ struct signal_struct { ...@@ -402,6 +402,7 @@ struct signal_struct {
/* ITIMER_REAL timer for the process */ /* ITIMER_REAL timer for the process */
struct hrtimer real_timer; struct hrtimer real_timer;
struct task_struct *tsk;
ktime_t it_real_incr; ktime_t it_real_incr;
/* ITIMER_PROF and ITIMER_VIRTUAL timers for the process */ /* ITIMER_PROF and ITIMER_VIRTUAL timers for the process */
......
...@@ -96,6 +96,7 @@ static inline void add_timer(struct timer_list *timer) ...@@ -96,6 +96,7 @@ static inline void add_timer(struct timer_list *timer)
extern void init_timers(void); extern void init_timers(void);
extern void run_local_timers(void); extern void run_local_timers(void);
extern int it_real_fn(void *); struct hrtimer;
extern int it_real_fn(struct hrtimer *);
#endif #endif
...@@ -848,7 +848,7 @@ static inline int copy_signal(unsigned long clone_flags, struct task_struct * ts ...@@ -848,7 +848,7 @@ static inline int copy_signal(unsigned long clone_flags, struct task_struct * ts
hrtimer_init(&sig->real_timer, CLOCK_MONOTONIC, HRTIMER_REL); hrtimer_init(&sig->real_timer, CLOCK_MONOTONIC, HRTIMER_REL);
sig->it_real_incr.tv64 = 0; sig->it_real_incr.tv64 = 0;
sig->real_timer.function = it_real_fn; sig->real_timer.function = it_real_fn;
sig->real_timer.data = tsk; sig->tsk = tsk;
sig->it_virt_expires = cputime_zero; sig->it_virt_expires = cputime_zero;
sig->it_virt_incr = cputime_zero; sig->it_virt_incr = cputime_zero;
......
...@@ -613,21 +613,19 @@ static inline void run_hrtimer_queue(struct hrtimer_base *base) ...@@ -613,21 +613,19 @@ static inline void run_hrtimer_queue(struct hrtimer_base *base)
while ((node = base->first)) { while ((node = base->first)) {
struct hrtimer *timer; struct hrtimer *timer;
int (*fn)(void *); int (*fn)(struct hrtimer *);
int restart; int restart;
void *data;
timer = rb_entry(node, struct hrtimer, node); timer = rb_entry(node, struct hrtimer, node);
if (base->softirq_time.tv64 <= timer->expires.tv64) if (base->softirq_time.tv64 <= timer->expires.tv64)
break; break;
fn = timer->function; fn = timer->function;
data = timer->data;
set_curr_timer(base, timer); set_curr_timer(base, timer);
__remove_hrtimer(timer, base); __remove_hrtimer(timer, base);
spin_unlock_irq(&base->lock); spin_unlock_irq(&base->lock);
restart = fn(data); restart = fn(timer);
spin_lock_irq(&base->lock); spin_lock_irq(&base->lock);
...@@ -664,9 +662,10 @@ struct sleep_hrtimer { ...@@ -664,9 +662,10 @@ struct sleep_hrtimer {
int expired; int expired;
}; };
static int nanosleep_wakeup(void *data) static int nanosleep_wakeup(struct hrtimer *timer)
{ {
struct sleep_hrtimer *t = data; struct sleep_hrtimer *t =
container_of(timer, struct sleep_hrtimer, timer);
t->expired = 1; t->expired = 1;
wake_up_process(t->task); wake_up_process(t->task);
...@@ -677,7 +676,6 @@ static int nanosleep_wakeup(void *data) ...@@ -677,7 +676,6 @@ static int nanosleep_wakeup(void *data)
static int __sched do_nanosleep(struct sleep_hrtimer *t, enum hrtimer_mode mode) static int __sched do_nanosleep(struct sleep_hrtimer *t, enum hrtimer_mode mode)
{ {
t->timer.function = nanosleep_wakeup; t->timer.function = nanosleep_wakeup;
t->timer.data = t;
t->task = current; t->task = current;
t->expired = 0; t->expired = 0;
......
...@@ -128,17 +128,16 @@ asmlinkage long sys_getitimer(int which, struct itimerval __user *value) ...@@ -128,17 +128,16 @@ asmlinkage long sys_getitimer(int which, struct itimerval __user *value)
/* /*
* The timer is automagically restarted, when interval != 0 * The timer is automagically restarted, when interval != 0
*/ */
int it_real_fn(void *data) int it_real_fn(struct hrtimer *timer)
{ {
struct task_struct *tsk = (struct task_struct *) data; struct signal_struct *sig =
container_of(timer, struct signal_struct, real_timer);
send_group_sig_info(SIGALRM, SEND_SIG_PRIV, tsk); send_group_sig_info(SIGALRM, SEND_SIG_PRIV, sig->tsk);
if (tsk->signal->it_real_incr.tv64 != 0) {
hrtimer_forward(&tsk->signal->real_timer,
tsk->signal->real_timer.base->softirq_time,
tsk->signal->it_real_incr);
if (sig->it_real_incr.tv64 != 0) {
hrtimer_forward(timer, timer->base->softirq_time,
sig->it_real_incr);
return HRTIMER_RESTART; return HRTIMER_RESTART;
} }
return HRTIMER_NORESTART; return HRTIMER_NORESTART;
......
...@@ -145,7 +145,7 @@ static int common_timer_set(struct k_itimer *, int, ...@@ -145,7 +145,7 @@ static int common_timer_set(struct k_itimer *, int,
struct itimerspec *, struct itimerspec *); struct itimerspec *, struct itimerspec *);
static int common_timer_del(struct k_itimer *timer); static int common_timer_del(struct k_itimer *timer);
static int posix_timer_fn(void *data); static int posix_timer_fn(struct hrtimer *data);
static struct k_itimer *lock_timer(timer_t timer_id, unsigned long *flags); static struct k_itimer *lock_timer(timer_t timer_id, unsigned long *flags);
...@@ -334,14 +334,14 @@ EXPORT_SYMBOL_GPL(posix_timer_event); ...@@ -334,14 +334,14 @@ EXPORT_SYMBOL_GPL(posix_timer_event);
* This code is for CLOCK_REALTIME* and CLOCK_MONOTONIC* timers. * This code is for CLOCK_REALTIME* and CLOCK_MONOTONIC* timers.
*/ */
static int posix_timer_fn(void *data) static int posix_timer_fn(struct hrtimer *timer)
{ {
struct k_itimer *timr = data; struct k_itimer *timr;
struct hrtimer *timer = &timr->it.real.timer;
unsigned long flags; unsigned long flags;
int si_private = 0; int si_private = 0;
int ret = HRTIMER_NORESTART; int ret = HRTIMER_NORESTART;
timr = container_of(timer, struct k_itimer, it.real.timer);
spin_lock_irqsave(&timr->it_lock, flags); spin_lock_irqsave(&timr->it_lock, flags);
if (timr->it.real.interval.tv64 != 0) if (timr->it.real.interval.tv64 != 0)
...@@ -725,7 +725,6 @@ common_timer_set(struct k_itimer *timr, int flags, ...@@ -725,7 +725,6 @@ common_timer_set(struct k_itimer *timr, int flags,
mode = flags & TIMER_ABSTIME ? HRTIMER_ABS : HRTIMER_REL; mode = flags & TIMER_ABSTIME ? HRTIMER_ABS : HRTIMER_REL;
hrtimer_init(&timr->it.real.timer, timr->it_clock, mode); hrtimer_init(&timr->it.real.timer, timr->it_clock, mode);
timr->it.real.timer.data = timr;
timr->it.real.timer.function = posix_timer_fn; timr->it.real.timer.function = posix_timer_fn;
timer->expires = timespec_to_ktime(new_setting->it_value); timer->expires = timespec_to_ktime(new_setting->it_value);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册