ChangeSet 1.1552, 2005/05/25 14:43:27+01:00, kaf24@xxxxxxxxxxxxxxxxxxxx
Simplify the ac_timer interface: mod_ac_timer/add_ac_timer replaced
by set_ac_timer.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
arch/ia64/vlsapic.c | 13 ++-------
arch/x86/vmx_intercept.c | 5 ---
common/ac_timer.c | 65 +++++++++++++++++++----------------------------
common/sched_bvt.c | 15 ++--------
common/schedule.c | 15 ++++------
include/xen/ac_timer.h | 10 -------
6 files changed, 43 insertions(+), 80 deletions(-)
diff -Nru a/xen/arch/ia64/vlsapic.c b/xen/arch/ia64/vlsapic.c
--- a/xen/arch/ia64/vlsapic.c 2005-05-25 10:01:38 -04:00
+++ b/xen/arch/ia64/vlsapic.c 2005-05-25 10:01:38 -04:00
@@ -216,18 +216,13 @@
/* Both last_itc & cur_itc < itm, wait for fire condition */
else if ( vtm->timer_hooked ) {
expires = NOW() + tick_to_ns(0-diff_now) + TIMER_SLOP;
- mod_ac_timer (&(vtm->vtm_timer), expires);
- printf("mod vtm_timer\n");
-//fire_itc = cur_itc;
-//fire_itm = vitm;
+ set_ac_timer(&vtm->vtm_timer, expires);
}
else {
- vtm->vtm_timer.expires = NOW() + tick_to_ns(0-diff_now) + TIMER_SLOP;
+ expires = NOW() + tick_to_ns(0-diff_now) + TIMER_SLOP;
vtm->vtm_timer.cpu = vcpu->processor;
- add_ac_timer(&(vtm->vtm_timer));
- vtm->timer_hooked = 1;
-//fire_itc = cur_itc;
-//fire_itm = vitm;
+ set_ac_timer(&vtm->vtm_timer, expires);
+ vtm->timer_hooked = 1;
}
local_irq_restore(spsr);
}
diff -Nru a/xen/arch/x86/vmx_intercept.c b/xen/arch/x86/vmx_intercept.c
--- a/xen/arch/x86/vmx_intercept.c 2005-05-25 10:01:38 -04:00
+++ b/xen/arch/x86/vmx_intercept.c 2005-05-25 10:01:38 -04:00
@@ -193,14 +193,11 @@
{
struct vmx_virpit_t *vpit = (struct vmx_virpit_t*)data;
- /* rearm itself */
- vpit->pit_timer.expires = NOW() + MILLISECS(vpit->period);
-
/*set the pending intr bit in shared page, send evtchn notification to
myself*/
if (test_and_set_bit(vpit->vector, vpit->intr_bitmap))
vpit->pending_intr_nr++; /* if originaly set, then count the pending
intr */
- add_ac_timer(&(vpit->pit_timer));
+ set_ac_timer(&vpit->pit_timer, NOW() + MILLISECS(vpit->period));
}
diff -Nru a/xen/common/ac_timer.c b/xen/common/ac_timer.c
--- a/xen/common/ac_timer.c 2005-05-25 10:01:38 -04:00
+++ b/xen/common/ac_timer.c 2005-05-25 10:01:38 -04:00
@@ -114,23 +114,31 @@
/* Add new entry @t to @heap. Return TRUE if new top of heap. */
-static int add_entry(struct ac_timer **heap, struct ac_timer *t)
+static int add_entry(struct ac_timer ***pheap, struct ac_timer *t)
{
- int sz = GET_HEAP_SIZE(heap);
+ int sz, limit;
+ struct ac_timer **heap;
+
+ /* Create initial heap if not already initialised. */
+ if ( unlikely((heap = *pheap) == NULL) )
+ {
+ heap = xmalloc_array(struct ac_timer *, DEFAULT_HEAP_LIMIT + 1);
+ BUG_ON(heap == NULL);
+ SET_HEAP_SIZE(heap, 0);
+ SET_HEAP_LIMIT(heap, DEFAULT_HEAP_LIMIT);
+ *pheap = heap;
+ }
/* Copy the heap if it is full. */
- if ( unlikely(sz == GET_HEAP_LIMIT(heap)) )
+ if ( unlikely((sz = GET_HEAP_SIZE(heap)) == GET_HEAP_LIMIT(heap)) )
{
- int i, limit = (GET_HEAP_LIMIT(heap)+1) << 1;
- struct ac_timer **new_heap = xmalloc_array(struct ac_timer *, limit);
- if ( new_heap == NULL ) BUG();
- memcpy(new_heap, heap, (limit>>1)*sizeof(struct ac_timer *));
- for ( i = 0; i < NR_CPUS; i++ )
- if ( ac_timers[i].heap == heap )
- ac_timers[i].heap = new_heap;
- xfree(heap);
- heap = new_heap;
- SET_HEAP_LIMIT(heap, limit-1);
+ limit = (GET_HEAP_LIMIT(heap) << 1) + 1; /* 2^(n+1) - 1 */
+ heap = xmalloc_array(struct ac_timer *, limit + 1);
+ BUG_ON(heap == NULL);
+ memcpy(heap, *pheap, ((limit >> 1) + 1) * sizeof(struct ac_timer *));
+ SET_HEAP_LIMIT(heap, limit);
+ xfree(*pheap);
+ *pheap = heap;
}
SET_HEAP_SIZE(heap, ++sz);
@@ -148,22 +156,10 @@
static inline void __add_ac_timer(struct ac_timer *timer)
{
int cpu = timer->cpu;
- if ( add_entry(ac_timers[cpu].heap, timer) )
+ if ( add_entry(&ac_timers[cpu].heap, timer) )
cpu_raise_softirq(cpu, AC_TIMER_SOFTIRQ);
}
-void add_ac_timer(struct ac_timer *timer)
-{
- int cpu = timer->cpu;
- unsigned long flags;
-
- spin_lock_irqsave(&ac_timers[cpu].lock, flags);
- ASSERT(timer != NULL);
- ASSERT(!active_ac_timer(timer));
- __add_ac_timer(timer);
- spin_unlock_irqrestore(&ac_timers[cpu].lock, flags);
-}
-
static inline void __rem_ac_timer(struct ac_timer *timer)
{
@@ -172,7 +168,8 @@
cpu_raise_softirq(cpu, AC_TIMER_SOFTIRQ);
}
-void rem_ac_timer(struct ac_timer *timer)
+
+void set_ac_timer(struct ac_timer *timer, s_time_t expires)
{
int cpu = timer->cpu;
unsigned long flags;
@@ -181,11 +178,13 @@
ASSERT(timer != NULL);
if ( active_ac_timer(timer) )
__rem_ac_timer(timer);
+ timer->expires = expires;
+ __add_ac_timer(timer);
spin_unlock_irqrestore(&ac_timers[cpu].lock, flags);
}
-void mod_ac_timer(struct ac_timer *timer, s_time_t new_time)
+void rem_ac_timer(struct ac_timer *timer)
{
int cpu = timer->cpu;
unsigned long flags;
@@ -194,8 +193,6 @@
ASSERT(timer != NULL);
if ( active_ac_timer(timer) )
__rem_ac_timer(timer);
- timer->expires = new_time;
- __add_ac_timer(timer);
spin_unlock_irqrestore(&ac_timers[cpu].lock, flags);
}
@@ -271,15 +268,7 @@
open_softirq(AC_TIMER_SOFTIRQ, ac_timer_softirq_action);
for ( i = 0; i < NR_CPUS; i++ )
- {
- ac_timers[i].heap = xmalloc_array(
- struct ac_timer *, DEFAULT_HEAP_LIMIT+1);
- BUG_ON(ac_timers[i].heap == NULL);
-
- SET_HEAP_SIZE(ac_timers[i].heap, 0);
- SET_HEAP_LIMIT(ac_timers[i].heap, DEFAULT_HEAP_LIMIT);
spin_lock_init(&ac_timers[i].lock);
- }
register_keyhandler('a', dump_timerq, "dump ac_timer queues");
}
diff -Nru a/xen/common/sched_bvt.c b/xen/common/sched_bvt.c
--- a/xen/common/sched_bvt.c 2005-05-25 10:01:38 -04:00
+++ b/xen/common/sched_bvt.c 2005-05-25 10:01:38 -04:00
@@ -110,9 +110,7 @@
cpu_raise_softirq(cpu, SCHEDULE_SOFTIRQ);
}
- /* set unwarp timer */
- inf->unwarp_timer.expires = NOW() + inf->warpu;
- add_ac_timer(&inf->unwarp_timer);
+ set_ac_timer(&inf->unwarp_timer, NOW() + inf->warpu);
spin_unlock_irq(&schedule_data[cpu].schedule_lock);
}
@@ -276,7 +274,7 @@
if ( is_idle_task(curr->domain) || (einf->evt <= curr_evt) )
cpu_raise_softirq(cpu, SCHEDULE_SOFTIRQ);
else if ( schedule_data[cpu].s_timer.expires > r_time )
- mod_ac_timer(&schedule_data[cpu].s_timer, r_time);
+ set_ac_timer(&schedule_data[cpu].s_timer, r_time);
}
@@ -439,13 +437,8 @@
min_avt = p_einf->avt;
}
- if(next_einf->inf->warp && next_einf->inf->warpl > 0)
- {
- /* Set the timer up */
- next_einf->inf->warp_timer.expires = now + next_einf->inf->warpl;
- /* Add it to the heap */
- add_ac_timer(&next_einf->inf->warp_timer);
- }
+ if ( next_einf->inf->warp && next_einf->inf->warpl > 0 )
+ set_ac_timer(&next_einf->inf->warp_timer, now + next_einf->inf->warpl);
/* Extract the domain pointers from the dom infos */
next = next_einf->exec_domain;
diff -Nru a/xen/common/schedule.c b/xen/common/schedule.c
--- a/xen/common/schedule.c 2005-05-25 10:01:38 -04:00
+++ b/xen/common/schedule.c 2005-05-25 10:01:38 -04:00
@@ -298,10 +298,10 @@
{
struct exec_domain *ed = current;
- rem_ac_timer(&ed->timer);
-
- if ( (ed->timer.expires = timeout) != 0 )
- add_ac_timer(&ed->timer);
+ if ( timeout == 0 )
+ rem_ac_timer(&ed->timer);
+ else
+ set_ac_timer(&ed->timer, timeout);
return 0;
}
@@ -423,9 +423,7 @@
next->lastschd = now;
- /* reprogramm the timer */
- schedule_data[cpu].s_timer.expires = now + r_time;
- add_ac_timer(&schedule_data[cpu].s_timer);
+ set_ac_timer(&schedule_data[cpu].s_timer, now + r_time);
/* Must be protected by the schedule_lock! */
set_bit(_VCPUF_running, &next->vcpu_flags);
@@ -510,8 +508,7 @@
page_scrub_schedule_work();
- t_timer[cpu].expires = NOW() + MILLISECS(10);
- add_ac_timer(&t_timer[cpu]);
+ set_ac_timer(&t_timer[cpu], NOW() + MILLISECS(10));
}
/* Domain timer function, sends a virtual timer interrupt to domain */
diff -Nru a/xen/include/xen/ac_timer.h b/xen/include/xen/ac_timer.h
--- a/xen/include/xen/ac_timer.h 2005-05-25 10:01:38 -04:00
+++ b/xen/include/xen/ac_timer.h 2005-05-25 10:01:38 -04:00
@@ -62,9 +62,8 @@
* This function can be called for any CPU from any CPU in any context, BUT:
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|