qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 6/8] timers: introduce cpu_get_clock_locked


From: Alex Bligh
Subject: Re: [Qemu-devel] [PATCH 6/8] timers: introduce cpu_get_clock_locked
Date: Tue, 8 Oct 2013 17:55:35 +0100

On 8 Oct 2013, at 09:47, Paolo Bonzini wrote:

> This fixes a deadlock in cpu_disable_ticks.
> 
> Signed-off-by: Paolo Bonzini <address@hidden>

Reviewed-by: Alex Bligh <address@hidden>

> ---
>       Should be squashed in Ping Fan's patches.
> 
> cpus.c | 21 +++++++++++++++------
> 1 file changed, 15 insertions(+), 6 deletions(-)
> 
> diff --git a/cpus.c b/cpus.c
> index 08eaf23..01acce2 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -166,6 +166,20 @@ int64_t cpu_get_ticks(void)
>     }
> }
> 
> +static int64_t cpu_get_clock_locked(void)
> +{
> +    int64_t ti;
> +
> +    if (!timers_state.cpu_ticks_enabled) {
> +        ti = timers_state.cpu_clock_offset;
> +    } else {
> +        ti = get_clock();
> +        ti += timers_state.cpu_clock_offset;
> +    }
> +
> +    return ti;
> +}
> +
> /* return the host CPU monotonic timer and handle stop/restart */
> int64_t cpu_get_clock(void)
> {
> @@ -174,12 +188,7 @@ int64_t cpu_get_clock(void)
> 
>     do {
>         start = seqlock_read_begin(&timers_state.clock_seqlock);
> -        if (!timers_state.cpu_ticks_enabled) {
> -            ti = timers_state.cpu_clock_offset;
> -        } else {
> -            ti = get_clock();
> -            ti += timers_state.cpu_clock_offset;
> -        }
> +        ti = cpu_get_clock_locked();
>     } while (seqlock_read_retry(&timers_state.clock_seqlock, start));
> 
>     return ti;
> @@ -220,7 +233,7 @@ void cpu_disable_ticks(void)
>     seqlock_write_lock(&timers_state.clock_seqlock);
>     if (timers_state.cpu_ticks_enabled) {
>         timers_state.cpu_ticks_offset = cpu_get_ticks();
> -        timers_state.cpu_clock_offset = cpu_get_clock();
> +        timers_state.cpu_clock_offset = cpu_get_clock_locked();
>         timers_state.cpu_ticks_enabled = 0;
>     }
>     seqlock_write_unlock(&timers_state.clock_seqlock);
> -- 
> 1.8.3.1
> 
> 
> 
> 

-- 
Alex Bligh







reply via email to

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