softmmu/cpus: Check if the cpu work list is empty atomically
PATCH 1/2 softmmu/cpus: Check if the cpu work list is empty atomically
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.
--- softmmu/cpus.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
softmmu/cpus.c +1 -6
@@ -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)
Signature · 1 line
2.34.1
PATCH 2/2 qemu-timer: Skip empty timer lists before locking in qemu_clock_deadline_ns_all
This decreases qemu_clock_deadline_ns_all's share from 23.2% to 13% in a profile of icount-enabled aarch64-softmmu.
--- util/qemu-timer.c | 3 +++ 1 file changed, 3 insertions(+)
util/qemu-timer.c +3 -0
@@ -261,6 +261,9 @@ int64_t qemu_clock_deadline_ns_all(QEMUClockType type, int attr_mask) } QLIST_FOREACH(timer_list, &clock->timerlists, list) { +if (!qatomic_read (&timer_list->active_timers)) { +continue ; + }qemu_mutex_lock (&timer_list->active_timers_lock); ts = timer_list->active_timers;/* Skip all external timers */
Signature · 1 line
2.34.1
Re: [PATCH 2/2] qemu-timer: Skip empty timer lists before locking in qemu_clock_deadline_ns_all
Quoted 7 lines · Idan Horowitz
This decreases qemu_clock_deadline_ns_all's share from 23.2% to 13% in a profile of icount-enabled aarch64-softmmu.
Signed-off-by Idan Horowitz<[email protected]>--- util/qemu-timer.c | 3 +++ 1 file changed, 3 insertions(+)
r~
Re: [PATCH 2/2] qemu-timer: Skip empty timer lists before locking in qemu_clock_deadline_ns_all
Quoted 4 lines · Richard Henderson
Reviewed-by Richard Henderson <[email protected]>r~
Hey, I believe this patch might have accidentally been missed?
Thanks,
Idan Horowitz
Re: [PATCH 2/2] qemu-timer: Skip empty timer lists before locking in qemu_clock_deadline_ns_all
Quoted 8 lines · Idan Horowitz
Quoted 4 lines · Richard Henderson
Reviewed-by Richard Henderson <[email protected]>r~
Hey, I believe this patch might have accidentally been missed?
Oops, yes. Got 1/2 but not 2/2. Queued to tcg-next.
r~
Quoted 9 lines · Idan Horowitz
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<[email protected]>--- softmmu/cpus.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
Queued to tcg-next.
r~