All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] softmmu/cpus: Check if the cpu work list is empty atomically
@ 2022-01-14  0:43 Idan Horowitz
  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:40 ` [PATCH 1/2] softmmu/cpus: Check if the cpu work list is empty atomically Richard Henderson
  0 siblings, 2 replies; 6+ messages in thread
From: Idan Horowitz @ 2022-01-14  0:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: richard.henderson, Idan Horowitz, pbonzini

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



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] qemu-timer: Skip empty timer lists before locking in qemu_clock_deadline_ns_all
  2022-01-14  0:43 [PATCH 1/2] softmmu/cpus: Check if the cpu work list is empty atomically Idan Horowitz
@ 2022-01-14  0:43 ` Idan Horowitz
  2022-01-26 21:43   ` Richard Henderson
  2022-01-26 21:40 ` [PATCH 1/2] softmmu/cpus: Check if the cpu work list is empty atomically Richard Henderson
  1 sibling, 1 reply; 6+ messages in thread
From: Idan Horowitz @ 2022-01-14  0:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: richard.henderson, Idan Horowitz, pbonzini

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 <idan.horowitz@gmail.com>
---
 util/qemu-timer.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/util/qemu-timer.c b/util/qemu-timer.c
index f36c75e594..e56895ef55 100644
--- a/util/qemu-timer.c
+++ b/util/qemu-timer.c
@@ -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 */
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] softmmu/cpus: Check if the cpu work list is empty atomically
  2022-01-14  0:43 [PATCH 1/2] softmmu/cpus: Check if the cpu work list is empty atomically Idan Horowitz
  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:40 ` Richard Henderson
  1 sibling, 0 replies; 6+ messages in thread
From: Richard Henderson @ 2022-01-26 21:40 UTC (permalink / raw)
  To: Idan Horowitz, qemu-devel; +Cc: pbonzini

On 1/14/22 11:43 AM, Idan Horowitz wrote:
> 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(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

Queued to tcg-next.


r~


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] qemu-timer: Skip empty timer lists before locking in qemu_clock_deadline_ns_all
  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
  0 siblings, 1 reply; 6+ messages in thread
From: Richard Henderson @ 2022-01-26 21:43 UTC (permalink / raw)
  To: Idan Horowitz, qemu-devel; +Cc: pbonzini

On 1/14/22 11:43 AM, Idan Horowitz wrote:
> 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<idan.horowitz@gmail.com>
> ---
>   util/qemu-timer.c | 3 +++
>   1 file changed, 3 insertions(+)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] qemu-timer: Skip empty timer lists before locking in qemu_clock_deadline_ns_all
  2022-01-26 21:43   ` Richard Henderson
@ 2022-06-19  8:54     ` Idan Horowitz
  2022-06-21 16:25       ` Richard Henderson
  0 siblings, 1 reply; 6+ messages in thread
From: Idan Horowitz @ 2022-06-19  8:54 UTC (permalink / raw)
  To: Richard Henderson; +Cc: qemu-devel@nongnu.org Developers, pbonzini

On Wed, 26 Jan 2022 at 23:43, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>
> r~

Hey, I believe this patch might have accidentally been missed?

Thanks,
Idan Horowitz


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] qemu-timer: Skip empty timer lists before locking in qemu_clock_deadline_ns_all
  2022-06-19  8:54     ` Idan Horowitz
@ 2022-06-21 16:25       ` Richard Henderson
  0 siblings, 0 replies; 6+ messages in thread
From: Richard Henderson @ 2022-06-21 16:25 UTC (permalink / raw)
  To: Idan Horowitz; +Cc: qemu-devel@nongnu.org Developers, pbonzini

On 6/19/22 01:54, Idan Horowitz wrote:
> On Wed, 26 Jan 2022 at 23:43, Richard Henderson
> <richard.henderson@linaro.org> wrote:
>>
>> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>>
>> 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~


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-06-21 16:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-14  0:43 [PATCH 1/2] softmmu/cpus: Check if the cpu work list is empty atomically Idan Horowitz
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

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.