qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Claudio Fontana <cfontana@suse.de>
To: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>,
	"Pavel Dovgalyuk" <dovgaluk@ispras.ru>
Cc: Laurent Vivier <lvivier@redhat.com>,
	Thomas Huth <thuth@redhat.com>,
	Eduardo Habkost <ehabkost@redhat.com>,
	Marcelo Tosatti <mtosatti@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	qemu-devel@nongnu.org, Roman Bolshakov <r.bolshakov@yadro.com>,
	haxm-team@intel.com, Wenchao Wang <wenchao.wang@intel.com>,
	Sunil Muthuswamy <sunilmut@microsoft.com>,
	Richard Henderson <rth@twiddle.net>,
	Colin Xu <colin.xu@intel.com>
Subject: Re: [RFC v3 1/8] cpu-timers, icount: new modules
Date: Tue, 4 Aug 2020 10:13:41 +0200	[thread overview]
Message-ID: <910286a7-805d-3b62-a3b0-aeb5d0a9606e@suse.de> (raw)
In-Reply-To: <20200803090533.7410-2-cfontana@suse.de>

Hi Alex, Paolo and all,

thank you for your feedback, could you help me answer the question below?

On 8/3/20 11:05 AM, Claudio Fontana wrote:
> ...

> diff --git a/dma-helpers.c b/dma-helpers.c
> index 2a77b5a9cb..240ef4d5b8 100644
> --- a/dma-helpers.c
> +++ b/dma-helpers.c
> @@ -13,7 +13,7 @@
>  #include "trace-root.h"
>  #include "qemu/thread.h"
>  #include "qemu/main-loop.h"
> -#include "sysemu/cpus.h"
> +#include "sysemu/cpu-timers.h"
>  #include "qemu/range.h"
>  
>  /* #define DEBUG_IOMMU */
> @@ -151,7 +151,7 @@ static void dma_blk_cb(void *opaque, int ret)
>           * from several sectors. This code splits all SGs into several
>           * groups. SGs in every group do not overlap.
>           */
> -        if (mem && use_icount && dbs->dir == DMA_DIRECTION_FROM_DEVICE) {
> +        if (mem && icount_enabled() && dbs->dir == DMA_DIRECTION_FROM_DEVICE) {




In this specific case, where dma_blk_cb() changes its behaviour to be more deterministic
if icount_enabled(),

do you think that if qtest_enabled() we should also follow the more deterministic path,
or should we go through the "normal" path instead, as this patch does?

Tests pass in any case, but I wonder what would be the best behavior for qtest accel in this case.
(Maybe Pavel?)



>              int i;
>              for (i = 0 ; i < dbs->iov.niov ; ++i) {
>                  if (ranges_overlap((intptr_t)dbs->iov.iov[i].iov_base,
> diff --git a/docs/replay.txt b/docs/replay.txt
> index 70c27edb36..8952e6d852 100644
> --- a/docs/replay.txt
> +++ b/docs/replay.txt
> @@ -184,11 +184,11 @@ is then incremented (which is called "warping" the virtual clock) as
>  soon as the timer fires or the CPUs need to go out of the idle state.
>  Two functions are used for this purpose; because these actions change
>  virtual machine state and must be deterministic, each of them creates a
> -checkpoint.  qemu_start_warp_timer checks if the CPUs are idle and if so
> -starts accounting real time to virtual clock.  qemu_account_warp_timer
> +checkpoint.  icount_start_warp_timer checks if the CPUs are idle and if so
> +starts accounting real time to virtual clock.  icount_account_warp_timer
>  is called when the CPUs get an interrupt or when the warp timer fires,
>  and it warps the virtual clock by the amount of real time that has passed
> -since qemu_start_warp_timer.
> +since icount_start_warp_timer.
>  
>  Bottom halves
>  -------------
> diff --git a/exec.c b/exec.c
> index 6f381f98e2..a89ffa93c1 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -102,10 +102,6 @@ uintptr_t qemu_host_page_size;
>  intptr_t qemu_host_page_mask;
>  
>  #if !defined(CONFIG_USER_ONLY)
> -/* 0 = Do not count executed instructions.
> -   1 = Precise instruction counting.
> -   2 = Adaptive rate instruction counting.  */
> -int use_icount;
>  
>  typedef struct PhysPageEntry PhysPageEntry;
>  
> diff --git a/hw/core/ptimer.c b/hw/core/ptimer.c
> index b5a54e2536..c6d2beb1da 100644
> --- a/hw/core/ptimer.c
> +++ b/hw/core/ptimer.c
> @@ -7,11 +7,11 @@
>   */
>  
>  #include "qemu/osdep.h"
> -#include "qemu/timer.h"
>  #include "hw/ptimer.h"
>  #include "migration/vmstate.h"
>  #include "qemu/host-utils.h"
>  #include "sysemu/replay.h"
> +#include "sysemu/cpu-timers.h"
>  #include "sysemu/qtest.h"
>  #include "block/aio.h"
>  #include "sysemu/cpus.h"
> @@ -134,7 +134,8 @@ static void ptimer_reload(ptimer_state *s, int delta_adjust)
>       * on the current generation of host machines.
>       */
>  
> -    if (s->enabled == 1 && (delta * period < 10000) && !use_icount) {
> +    if (s->enabled == 1 && (delta * period < 10000) &&
> +        !icount_enabled() && !qtest_enabled()) {


In this case, it is necessary to also make qtest more deterministic in order to make existing tests pass,
as the results of the timer are affecting the ptimer test results (IIRC tests/ptimer-test.c)


>          period = 10000 / delta;
>          period_frac = 0;
>      }
> @@ -217,7 +218,8 @@ uint64_t ptimer_get_count(ptimer_state *s)
>              uint32_t period_frac = s->period_frac;
>              uint64_t period = s->period;
>  
> -            if (!oneshot && (s->delta * period < 10000) && !use_icount) {
> +            if (!oneshot && (s->delta * period < 10000) &&
> +                !icount_enabled() && !qtest_enabled()) {

...same here.

>                  period = 10000 / s->delta;
>                  period_frac = 0;
>              }


Thanks for your feedback,

Claudio


  reply	other threads:[~2020-08-04  8:34 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-03  9:05 [RFC v3 0/8] QEMU cpus.c refactoring part2 Claudio Fontana
2020-08-03  9:05 ` [RFC v3 1/8] cpu-timers, icount: new modules Claudio Fontana
2020-08-04  8:13   ` Claudio Fontana [this message]
2020-08-04  8:23     ` Paolo Bonzini
2020-08-03  9:05 ` [RFC v3 2/8] cpus: prepare new CpusAccel cpu accelerator interface Claudio Fontana
2020-08-05  8:40   ` Claudio Fontana
2020-08-05  8:47     ` Paolo Bonzini
2020-08-05  8:50       ` Claudio Fontana
2020-08-11  8:59   ` Roman Bolshakov
2020-08-11 10:57     ` Claudio Fontana
2020-08-20  8:17   ` Claudio Fontana
2020-08-30 13:34     ` Claudio Fontana
2020-08-30 16:41       ` Paolo Bonzini
2020-08-03  9:05 ` [RFC v3 3/8] cpus: extract out TCG-specific code to accel/tcg Claudio Fontana
2020-08-03  9:05 ` [RFC v3 4/8] cpus: extract out qtest-specific code to accel/qtest Claudio Fontana
2020-08-03  9:05 ` [RFC v3 5/8] cpus: extract out kvm-specific code to accel/kvm Claudio Fontana
2020-08-03  9:05 ` [RFC v3 6/8] cpus: extract out hax-specific code to target/i386/ Claudio Fontana
2020-08-03  9:05 ` [RFC v3 7/8] cpus: extract out whpx-specific " Claudio Fontana
2020-08-03  9:05 ` [RFC v3 8/8] cpus: extract out hvf-specific code to target/i386/hvf/ Claudio Fontana
2020-08-11  9:00   ` Roman Bolshakov
2020-08-11 13:42     ` Claudio Fontana
2020-08-11 14:28       ` Claudio Fontana
2020-08-03  9:40 ` [RFC v3 0/8] QEMU cpus.c refactoring part2 Paolo Bonzini
2020-08-03 11:48 ` Alex Bennée
2020-08-05 17:03   ` Claudio Fontana

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=910286a7-805d-3b62-a3b0-aeb5d0a9606e@suse.de \
    --to=cfontana@suse.de \
    --cc=alex.bennee@linaro.org \
    --cc=armbru@redhat.com \
    --cc=colin.xu@intel.com \
    --cc=dovgaluk@ispras.ru \
    --cc=ehabkost@redhat.com \
    --cc=haxm-team@intel.com \
    --cc=lvivier@redhat.com \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=r.bolshakov@yadro.com \
    --cc=rth@twiddle.net \
    --cc=sunilmut@microsoft.com \
    --cc=thuth@redhat.com \
    --cc=wenchao.wang@intel.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).