]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] slab: add_timer_on: add a timer on a particular CPU
authorAndrew Morton <akpm@digeo.com>
Wed, 30 Oct 2002 07:23:44 +0000 (23:23 -0800)
committerLinus Torvalds <torvalds@penguin.transmeta.com>
Wed, 30 Oct 2002 07:23:44 +0000 (23:23 -0800)
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.

include/linux/timer.h
kernel/timer.c

index cfedb5e8bb07dfc44f8ce41158c6486c11baea97..d8ed753c8caa74ca10bcd9de7791b4a4d620ab1d 100644 (file)
@@ -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);
   
index 2d30f7fd0ecb6389f6f2990bfef93743efb3b06b..58c80293060b156bc43cf33a6accd393a2fe7943 100644 (file)
@@ -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