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: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH for-4.2 10/14] util/qemu-timer: refactor deadline calculation for external timers
Date: Wed, 24 Jul 2019 16:28:35 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0

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.

Paolo



reply via email to

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