Skip to content

Commit

Permalink
softmmu/cpus: Check if the cpu work list is empty atomically
Browse files Browse the repository at this point in the history
Instead of taking the lock of the cpu work list in order to check if it's
empty, we can just read the head pointer atomically. This decreases
cpu_work_list_empty's share from 5% to 1.3% in a profile of icount-enabled
aarch64-softmmu.

Signed-off-by: Idan Horowitz <idan.horowitz@gmail.com>
Message-Id: <20220114004358.299534-1-idan.horowitz@gmail.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
  • Loading branch information
IdanHo authored and rth7680 committed Feb 8, 2022
1 parent cfc2a2d commit 25e82fb
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions softmmu/cpus.c
Expand Up @@ -73,12 +73,7 @@ bool cpu_is_stopped(CPUState *cpu)

bool cpu_work_list_empty(CPUState *cpu)
{
bool ret;

qemu_mutex_lock(&cpu->work_mutex);
ret = QSIMPLEQ_EMPTY(&cpu->work_list);
qemu_mutex_unlock(&cpu->work_mutex);
return ret;
return QSIMPLEQ_EMPTY_ATOMIC(&cpu->work_list);
}

bool cpu_thread_is_idle(CPUState *cpu)
Expand Down

0 comments on commit 25e82fb

Please sign in to comment.