[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC v2 07/11] tcg: cpus rm tcg_exec_all()
From: |
Alex Bennée |
Subject: |
Re: [Qemu-devel] [RFC v2 07/11] tcg: cpus rm tcg_exec_all() |
Date: |
Thu, 26 May 2016 14:10:15 +0100 |
User-agent: |
mu4e 0.9.17; emacs 25.0.94.3 |
Sergey Fedorov <address@hidden> writes:
> On 05/04/16 18:32, Alex Bennée wrote:
>> diff --git a/cpus.c b/cpus.c
>> index e118fdf..46732a5 100644
>> --- a/cpus.c
>> +++ b/cpus.c
> (snip)
>> @@ -1109,7 +1108,7 @@ static void *qemu_dummy_cpu_thread_fn(void *arg)
>> #endif
>> }
>>
>> -static void tcg_exec_all(void);
>> +static int tcg_cpu_exec(CPUState *cpu);
>
> Why don't just move tcg_cpu_exec() here and avoid this forward
> declaration. Such forward declarations of static functions are a bit
> annoying :)
Sounds like a plan.
>
>>
>> static void *qemu_tcg_cpu_thread_fn(void *arg)
>> {
>> @@ -1140,8 +1139,35 @@ static void *qemu_tcg_cpu_thread_fn(void *arg)
>> /* process any pending work */
>> atomic_mb_set(&exit_request, 1);
>>
>> + cpu = first_cpu;
>> +
>> while (1) {
>> - tcg_exec_all();
>> + /* Account partial waits to QEMU_CLOCK_VIRTUAL. */
>> + qemu_account_warp_timer();
>> +
>> + if (!cpu) {
>> + cpu = first_cpu;
>> + }
>> +
>> + for (; cpu != NULL && !exit_request; cpu = CPU_NEXT(cpu)) {
>
> Maybe a "while" cycle would be a bit neater here, like:
>
> while (cpu != NULL && !exit_request) {
> /* ... */
> cpu = CPU_NEXT(cpu);
> }
Yeah, I prefer the while to non-standard for loops.
>
>
>> +
>> + qemu_clock_enable(QEMU_CLOCK_VIRTUAL,
>> + (cpu->singlestep_enabled & SSTEP_NOTIMER) ==
>> 0);
>> +
>> + if (cpu_can_run(cpu)) {
>> + int r = tcg_cpu_exec(cpu);
>> + if (r == EXCP_DEBUG) {
>> + cpu_handle_guest_debug(cpu);
>> + break;
>> + }
>> + } else if (cpu->stop || cpu->stopped) {
>> + break;
>> + }
>> +
>> + } /* for cpu.. */
>> +
>> + /* Pairs with smp_wmb in qemu_cpu_kick. */
>
> While at it, we could also fix this comment like this:
>
> /* Pairs with atomic_mb_read() in cpu_exec(). */
Will do.
>
>> + atomic_mb_set(&exit_request, 0);
>>
>> if (use_icount) {
>> int64_t deadline =
>> qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL);
>
> Kind regards,
> Sergey
Thanks,
--
Alex Bennée