On 09/01/2017 18:01, Stefan Hajnoczi wrote: > Or use a simpler scheme: > > struct CPUState { > ... > uint32_t dstate_update_count; > }; > > In trace_event_set_vcpu_state_dynamic(): > > if (state) { > trace_events_enabled_count++; > set_bit(vcpu_id, vcpu->trace_dstate_delayed); > atomic_inc(&vcpu->dstate_update_count, 1); > (*ev->dstate)++; > } ... > > In cpu_exec() and friends: > > last_dstate_update_count = atomic_read(&vcpu->dstate_update_count); > > tb = tb_find(cpu, last_tb, tb_exit); > cpu_loop_exec_tb(cpu, tb, &last_tb, &tb_exit, &sc); > > /* apply and disable delayed dstate changes */ > if (unlikely(atomic_read(&cpu->dstate_update_count) != last_dstate_update_count)) { > bitmap_copy(cpu->trace_dstate, cpu->trace_dstate_delayed, > trace_get_vcpu_event_count()); > } > > (You'll need to adjust the details but the update counter approach > should be workable.) Would it work to use async_run_on_cpu? Thanks, Paolo