qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH for-4.2 10/14] util/qemu-timer: refactor deadlin


From: Pavel Dovgalyuk
Subject: Re: [Qemu-devel] [PATCH for-4.2 10/14] util/qemu-timer: refactor deadline calculation for external timers
Date: Thu, 25 Jul 2019 09:00:18 +0300

> From: Paolo Bonzini [mailto:address@hidden]
> On 24/07/19 10:44, Pavel Dovgalyuk wrote:
> > -int64_t qemu_clock_deadline_ns_all(QEMUClockType type)
> > +int64_t virtual_clock_deadline_ns(void)
> >  {
> >      int64_t deadline = -1;
> > +    int64_t delta;
> > +    int64_t expire_time;
> > +    QEMUTimer *ts;
> >      QEMUTimerList *timer_list;
> > -    QEMUClock *clock = qemu_clock_ptr(type);
> > +    QEMUClock *clock = qemu_clock_ptr(QEMU_CLOCK_VIRTUAL);
> > +
> > +    if (!clock->enabled) {
> > +        return -1;
> > +    }
> > +
> >      QLIST_FOREACH(timer_list, &clock->timerlists, list) {
> > -        deadline = qemu_soonest_timeout(deadline,
> > -                                        timerlist_deadline_ns(timer_list));
> > +        qemu_mutex_lock(&timer_list->active_timers_lock);
> > +        ts = timer_list->active_timers;
> > +        /* Skip all external timers */
> > +        while (ts && (ts->attributes & QEMU_TIMER_ATTR_EXTERNAL)) {
> > +            ts = ts->next;
> > +        }
> > +        if (!ts) {
> > +            qemu_mutex_unlock(&timer_list->active_timers_lock);
> > +            continue;
> > +        }
> > +        expire_time = ts->expire_time;
> > +        qemu_mutex_unlock(&timer_list->active_timers_lock);
> > +
> > +        delta = expire_time - qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
> > +        if (delta <= 0) {
> > +            delta = 0;
> > +        }
> > +        deadline = qemu_soonest_timeout(deadline, delta);
> >      }
> >      return deadline;
> >  }
> >
> 
> Why would this change be exclusive to QEMU_CLOCK_VIRTUAL?  I don't think
> it's useful to remove the argument.  Otherwise, the patch makes sense.

Ok, I'll rewrite this one and keep the argument.

Pavel Dovgalyuk




reply via email to

[Prev in Thread] Current Thread [Next in Thread]