Commit 22331dad authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] slab: add_timer_on: add a timer on a particular CPU

add_timer_on is like add_timer, except it takes a target CPU on which
to add the timer.

The slab code needs per-cpu timers for shrinking the per-cpu caches.
parent 706489d8
......@@ -44,6 +44,7 @@ static inline int timer_pending(const struct timer_list * timer)
}
extern void add_timer(struct timer_list * timer);
extern void add_timer_on(struct timer_list *timer, int cpu);
extern int del_timer(struct timer_list * timer);
extern int mod_timer(struct timer_list *timer, unsigned long expires);
......
......@@ -134,6 +134,26 @@ void add_timer(timer_t *timer)
put_cpu();
}
/***
* add_timer_on - start a timer on a particular CPU
* @timer: the timer to be added
* @cpu: the CPU to start it on
*
* This is not very scalable on SMP.
*/
void add_timer_on(struct timer_list *timer, int cpu)
{
tvec_base_t *base = tvec_bases+ cpu;
unsigned long flags;
BUG_ON(timer_pending(timer) || !timer->function);
spin_lock_irqsave(&base->lock, flags);
internal_add_timer(base, timer);
timer->base = base;
spin_unlock_irqrestore(&base->lock, flags);
}
/***
* mod_timer - modify a timer's timeout
* @timer: the timer to be modified
......
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