From: Idan Horowitz <idan.horowitz@gmail.com>
To: qemu-devel@nongnu.org
Cc: richard.henderson@linaro.org,
Idan Horowitz <idan.horowitz@gmail.com>,
pbonzini@redhat.com
Subject: [PATCH 1/2] softmmu/cpus: Check if the cpu work list is empty atomically
Date: Fri, 14 Jan 2022 02:43:57 +0200 [thread overview]
Message-ID: <20220114004358.299534-1-idan.horowitz@gmail.com> (raw)
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>
---
softmmu/cpus.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/softmmu/cpus.c b/softmmu/cpus.c
index 23bca46b07..035395ae13 100644
--- a/softmmu/cpus.c
+++ b/softmmu/cpus.c
@@ -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)
--
2.34.1
next reply other threads:[~2022-01-14 0:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-14 0:43 Idan Horowitz [this message]
2022-01-14 0:43 ` [PATCH 2/2] qemu-timer: Skip empty timer lists before locking in qemu_clock_deadline_ns_all Idan Horowitz
2022-01-26 21:43 ` Richard Henderson
2022-06-19 8:54 ` Idan Horowitz
2022-06-21 16:25 ` Richard Henderson
2022-01-26 21:40 ` [PATCH 1/2] softmmu/cpus: Check if the cpu work list is empty atomically Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220114004358.299534-1-idan.horowitz@gmail.com \
--to=idan.horowitz@gmail.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.