qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Robert Foley <robert.foley@linaro.org>, qemu-devel@nongnu.org
Cc: peter.puhov@linaro.org, cota@braap.org, alex.bennee@linaro.org,
	rth@twiddle.net
Subject: Re: [PATCH 2/2] accel/tcg: interrupt/exception handling uses bql_interrupt flag
Date: Fri, 31 Jul 2020 20:02:47 +0200	[thread overview]
Message-ID: <67497c73-d2b9-941e-471d-de0ccd61bb7f@redhat.com> (raw)
In-Reply-To: <20200731125127.30866-3-robert.foley@linaro.org>

On 31/07/20 14:51, Robert Foley wrote:
> This change removes the implied BQL from the cpu_handle_interrupt,
> and cpu_handle_exception paths. We can now select per-arch if
> the BQL is needed or not by using the bql_interrupt flag.
> By default, the core code holds the BQL.
> One benefit of this change is that it leaves it up to the arch
> to make the change to remove BQL when it makes sense.
> 
> Signed-off-by: Robert Foley <robert.foley@linaro.org>

No, please just modify all implementation to do lock/unlock.  It's a
simpler patch than this on.

Paolo

> ---
>  accel/tcg/cpu-exec.c | 34 ++++++++++++++++++++++++++--------
>  1 file changed, 26 insertions(+), 8 deletions(-)
> 
> diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
> index 80d0e649b2..cde27ee0bf 100644
> --- a/accel/tcg/cpu-exec.c
> +++ b/accel/tcg/cpu-exec.c
> @@ -517,9 +517,13 @@ static inline bool cpu_handle_exception(CPUState *cpu, int *ret)
>  #else
>          if (replay_exception()) {
>              CPUClass *cc = CPU_GET_CLASS(cpu);
> -            qemu_mutex_lock_iothread();
> +            if (cc->bql_interrupt) {
> +                qemu_mutex_lock_iothread();
> +            }
>              cc->do_interrupt(cpu);
> -            qemu_mutex_unlock_iothread();
> +            if (cc->bql_interrupt) {
> +                qemu_mutex_unlock_iothread();
> +            }
>              cpu->exception_index = -1;
>  
>              if (unlikely(cpu->singlestep_enabled)) {
> @@ -558,7 +562,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu,
>      if (unlikely(cpu_interrupt_request(cpu))) {
>          int interrupt_request;
>  
> -        qemu_mutex_lock_iothread();
> +        cpu_mutex_lock(cpu);
>          interrupt_request = cpu_interrupt_request(cpu);
>          if (unlikely(cpu->singlestep_enabled & SSTEP_NOIRQ)) {
>              /* Mask out external interrupts for this step. */
> @@ -567,7 +571,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu,
>          if (interrupt_request & CPU_INTERRUPT_DEBUG) {
>              cpu_reset_interrupt(cpu, CPU_INTERRUPT_DEBUG);
>              cpu->exception_index = EXCP_DEBUG;
> -            qemu_mutex_unlock_iothread();
> +            cpu_mutex_unlock(cpu);
>              return true;
>          }
>          if (replay_mode == REPLAY_MODE_PLAY && !replay_has_interrupt()) {
> @@ -577,13 +581,15 @@ static inline bool cpu_handle_interrupt(CPUState *cpu,
>              cpu_reset_interrupt(cpu, CPU_INTERRUPT_HALT);
>              cpu_halted_set(cpu, 1);
>              cpu->exception_index = EXCP_HLT;
> -            qemu_mutex_unlock_iothread();
> +            cpu_mutex_unlock(cpu);
>              return true;
>          }
>  #if defined(TARGET_I386)
>          else if (interrupt_request & CPU_INTERRUPT_INIT) {
>              X86CPU *x86_cpu = X86_CPU(cpu);
>              CPUArchState *env = &x86_cpu->env;
> +            cpu_mutex_unlock(cpu);
> +            qemu_mutex_lock_iothread();
>              replay_interrupt();
>              cpu_svm_check_intercept_param(env, SVM_EXIT_INIT, 0, 0);
>              do_cpu_init(x86_cpu);
> @@ -595,7 +601,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu,
>          else if (interrupt_request & CPU_INTERRUPT_RESET) {
>              replay_interrupt();
>              cpu_reset(cpu);
> -            qemu_mutex_unlock_iothread();
> +            cpu_mutex_unlock(cpu);
>              return true;
>          }
>  #endif
> @@ -604,7 +610,15 @@ static inline bool cpu_handle_interrupt(CPUState *cpu,
>             True when it is, and we should restart on a new TB,
>             and via longjmp via cpu_loop_exit.  */
>          else {
> +            cpu_mutex_unlock(cpu);
> +            if (cc->bql_interrupt) {
> +                qemu_mutex_lock_iothread();
> +            }
>              if (cc->cpu_exec_interrupt(cpu, interrupt_request)) {
> +                if (cc->bql_interrupt) {
> +                    qemu_mutex_unlock_iothread();
> +                }
> +                cpu_mutex_lock(cpu);
>                  replay_interrupt();
>                  /*
>                   * After processing the interrupt, ensure an EXCP_DEBUG is
> @@ -614,6 +628,11 @@ static inline bool cpu_handle_interrupt(CPUState *cpu,
>                  cpu->exception_index =
>                      (cpu->singlestep_enabled ? EXCP_DEBUG : -1);
>                  *last_tb = NULL;
> +            } else {
> +                if (cc->bql_interrupt) {
> +                    qemu_mutex_unlock_iothread();
> +                }
> +                cpu_mutex_lock(cpu);
>              }
>              /* The target hook may have updated the 'cpu->interrupt_request';
>               * reload the 'interrupt_request' value */
> @@ -627,7 +646,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu,
>          }
>  
>          /* If we exit via cpu_loop_exit/longjmp it is reset in cpu_exec */
> -        qemu_mutex_unlock_iothread();
> +        cpu_mutex_unlock(cpu);
>      }
>  
>      /* Finally, check if we need to exit to the main loop.  */
> @@ -691,7 +710,6 @@ static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock *tb,
>      }
>  #endif
>  }
> -
>  /* main execution loop */
>  
>  int cpu_exec(CPUState *cpu)
> 



  reply	other threads:[~2020-07-31 18:03 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-31 12:51 [PATCH 0/2] accel/tcg: remove implied BQL from cpu_handle_interrupt/exception path Robert Foley
2020-07-31 12:51 ` [PATCH 1/2] hw/core: Add bql_interrupt flag to CPUClass Robert Foley
2020-07-31 17:43   ` Eduardo Habkost
2020-07-31 19:14     ` Robert Foley
2020-07-31 19:24       ` Eduardo Habkost
2020-08-02 16:05         ` Alex Bennée
2020-08-04 20:36           ` Eduardo Habkost
2020-07-31 12:51 ` [PATCH 2/2] accel/tcg: interrupt/exception handling uses bql_interrupt flag Robert Foley
2020-07-31 18:02   ` Paolo Bonzini [this message]
2020-07-31 20:09     ` Robert Foley
2020-07-31 20:21       ` Paolo Bonzini
2020-08-02 16:09         ` Alex Bennée
2020-08-03  7:11           ` Paolo Bonzini

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=67497c73-d2b9-941e-471d-de0ccd61bb7f@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=cota@braap.org \
    --cc=peter.puhov@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=robert.foley@linaro.org \
    --cc=rth@twiddle.net \
    /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).