ia64/xen-unstable

changeset 696:f5dcc59a0d3f

bitkeeper revision 1.410 (3f5858837RI05aQRsQBYONi4X_g2Kw)

ac_timer.c:
Fix a bug in timer softirq.
author kaf24@scramble.cl.cam.ac.uk
date Fri Sep 05 09:33:55 2003 +0000 (2003-09-05)
parents c66f5e9d6427
children 86f8a7112ba1
files xen/common/ac_timer.c
line diff
     1.1 --- a/xen/common/ac_timer.c	Thu Sep 04 17:31:41 2003 +0000
     1.2 +++ b/xen/common/ac_timer.c	Fri Sep 05 09:33:55 2003 +0000
     1.3 @@ -277,30 +277,32 @@ static void ac_timer_softirq_action(stru
     1.4      unsigned long flags;
     1.5      struct ac_timer *t;
     1.6      struct list_head *tlist;
     1.7 +    int process_timer_list = 0;
     1.8  
     1.9      spin_lock_irqsave(&ac_timers[cpu].lock, flags);
    1.10      
    1.11      tlist = &ac_timers[cpu].timers;
    1.12      if ( list_empty(tlist) ) 
    1.13      {
    1.14 +        /* No deadline to program the timer with.*/
    1.15          reprogram_ac_timer((s_time_t)0);
    1.16 -        spin_unlock_irqrestore(&ac_timers[cpu].lock, flags);
    1.17 -        return;
    1.18 +    }
    1.19 +    else
    1.20 +    {
    1.21 +        /*
    1.22 +         * Reprogram timer with earliest deadline. If that has already passed
    1.23 +         * then we will process the timer list as soon as we release the lock.
    1.24 +         */
    1.25 +        t = list_entry(tlist, struct ac_timer, timer_list);
    1.26 +        if ( (t->expires < (NOW() + TIMER_SLOP)) ||
    1.27 +             !reprogram_ac_timer(t->expires) )
    1.28 +            process_timer_list = 1;
    1.29      }
    1.30  
    1.31 -    t = list_entry(tlist, struct ac_timer, timer_list);
    1.32 +    spin_unlock_irqrestore(&ac_timers[cpu].lock, flags);
    1.33  
    1.34 -    if ( (t->expires < (NOW() + TIMER_SLOP)) ||
    1.35 -         !reprogram_ac_timer(t->expires) ) 
    1.36 -    {
    1.37 -        /*
    1.38 -         * Timer handler needs protecting from local APIC interrupts, but takes
    1.39 -         * the spinlock itself, so we release that before calling in.
    1.40 -         */
    1.41 -        spin_unlock(&ac_timers[cpu].lock);
    1.42 +    if ( process_timer_list )
    1.43          do_ac_timer();
    1.44 -        local_irq_restore(flags);
    1.45 -    }
    1.46  }
    1.47  
    1.48