[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC PATCH v4 13/23] cpus: only take BQL for sleeping t
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [RFC PATCH v4 13/23] cpus: only take BQL for sleeping threads |
Date: |
Fri, 19 Jan 2018 13:19:46 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 |
On 19/01/2018 13:05, Pavel Dovgalyuk wrote:
>> From: Paolo Bonzini [mailto:address@hidden
>> On 19/01/2018 09:44, Pavel Dovgalyuk wrote:
>>> while (all_cpu_threads_idle()) {
>>> + qemu_mutex_lock_iothread();
>>> stop_tcg_kick_timer();
>>> qemu_cond_wait(cpu->halt_cond, &qemu_global_mutex);
>>> + qemu_mutex_unlock_iothread();
>>> }
>>
>> cpu_has_work cannot be called outside BQL yet. You first need to access
>> cpu->interrupt_request with atomics.
>>
>> In general, testing the condition outside the mutex is a very dangerous
>> pattern (and I'm usually the one who enjoys dangerous patterns).
>
> It means, that I'll have to fix all the has_work function to avoid races,
> because x86_cpu_has_work may have them?
Why only x86_cpu_has_work?
Even reading cs->interrupt_request outside the mutex is unsafe.
Paolo
> static bool x86_cpu_has_work(CPUState *cs)
> {
> X86CPU *cpu = X86_CPU(cs);
> CPUX86State *env = &cpu->env;
>
> return ((cs->interrupt_request & (CPU_INTERRUPT_HARD |
> CPU_INTERRUPT_POLL)) &&
> (env->eflags & IF_MASK)) ||
> (cs->interrupt_request & (CPU_INTERRUPT_NMI |
> CPU_INTERRUPT_INIT |
> CPU_INTERRUPT_SIPI |
> CPU_INTERRUPT_MCE)) ||
> ((cs->interrupt_request & CPU_INTERRUPT_SMI) &&
> !(env->hflags & HF_SMM_MASK));
> }
>
> Pavel Dovgalyuk
>
- [Qemu-devel] [RFC PATCH v4 09/23] replay: make safe vmstop at record/replay, (continued)
- [Qemu-devel] [RFC PATCH v4 09/23] replay: make safe vmstop at record/replay, Pavel Dovgalyuk, 2018/01/19
- [Qemu-devel] [RFC PATCH v4 10/23] replay: save prior value of the host clock, Pavel Dovgalyuk, 2018/01/19
- [Qemu-devel] [RFC PATCH v4 11/23] target/arm/arm-powertctl: drop BQL assertions, Pavel Dovgalyuk, 2018/01/19
- [Qemu-devel] [RFC PATCH v4 12/23] cpus: push BQL lock to qemu_*_wait_io_event, Pavel Dovgalyuk, 2018/01/19
- [Qemu-devel] [RFC PATCH v4 14/23] replay/replay.c: bump REPLAY_VERSION again, Pavel Dovgalyuk, 2018/01/19
- [Qemu-devel] [RFC PATCH v4 13/23] cpus: only take BQL for sleeping threads, Pavel Dovgalyuk, 2018/01/19
- Re: [Qemu-devel] [RFC PATCH v4 13/23] cpus: only take BQL for sleeping threads, Paolo Bonzini, 2018/01/19
- Re: [Qemu-devel] [RFC PATCH v4 13/23] cpus: only take BQL for sleeping threads, Pavel Dovgalyuk, 2018/01/19
- Re: [Qemu-devel] [RFC PATCH v4 13/23] cpus: only take BQL for sleeping threads,
Paolo Bonzini <=
- Re: [Qemu-devel] [RFC PATCH v4 13/23] cpus: only take BQL for sleeping threads, Pavel Dovgalyuk, 2018/01/19
- Re: [Qemu-devel] [RFC PATCH v4 13/23] cpus: only take BQL for sleeping threads, Paolo Bonzini, 2018/01/19
- Re: [Qemu-devel] [RFC PATCH v4 13/23] cpus: only take BQL for sleeping threads, Pavel Dovgalyuk, 2018/01/19
- Re: [Qemu-devel] [RFC PATCH v4 13/23] cpus: only take BQL for sleeping threads, Pavel Dovgalyuk, 2018/01/19
- Re: [Qemu-devel] [RFC PATCH v4 13/23] cpus: only take BQL for sleeping threads, Paolo Bonzini, 2018/01/19
- Re: [Qemu-devel] [RFC PATCH v4 13/23] cpus: only take BQL for sleeping threads, Pavel Dovgalyuk, 2018/01/22
[Qemu-devel] [RFC PATCH v4 15/23] replay/replay-internal.c: track holding of replay_lock, Pavel Dovgalyuk, 2018/01/19
[Qemu-devel] [RFC PATCH v4 16/23] replay: make locking visible outside replay code, Pavel Dovgalyuk, 2018/01/19
[Qemu-devel] [RFC PATCH v4 17/23] replay: push replay_mutex_lock up the call tree, Pavel Dovgalyuk, 2018/01/19
[Qemu-devel] [RFC PATCH v4 18/23] replay: don't destroy mutex at exit, Pavel Dovgalyuk, 2018/01/19