All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Richard W.M. Jones" <rjones@redhat.com>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: qemu-devel@nongnu.org, peterz@infradead.org, arnd@arndb.de,
	naresh.kamboju@linaro.org, anders.roxell@linaro.org,
	daniel.diaz@linaro.org, ben.copeland@linaro.org,
	pbonzini@redhat.com
Subject: Re: [PATCH 1/2] accel/tcg: Split out cpu_exec_longjmp_cleanup
Date: Thu, 6 Jul 2023 18:46:42 +0100	[thread overview]
Message-ID: <20230706174642.GP7636@redhat.com> (raw)
In-Reply-To: <20230706170537.95959-2-richard.henderson@linaro.org>

On Thu, Jul 06, 2023 at 06:05:36PM +0100, Richard Henderson wrote:
> Share the setjmp cleanup between cpu_exec_step_atomic
> and cpu_exec_setjmp.
> 
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Reviewed-by: Richard W.M. Jones <rjones@redhat.com>

(I'm still testing the other one, but already up to 600 iterations)

Rich.

> ---
>  accel/tcg/cpu-exec.c | 43 +++++++++++++++++++------------------------
>  1 file changed, 19 insertions(+), 24 deletions(-)
> 
> diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
> index ba1890a373..31aa320513 100644
> --- a/accel/tcg/cpu-exec.c
> +++ b/accel/tcg/cpu-exec.c
> @@ -526,6 +526,23 @@ static void cpu_exec_exit(CPUState *cpu)
>      }
>  }
>  
> +static void cpu_exec_longjmp_cleanup(CPUState *cpu)
> +{
> +    /* Non-buggy compilers preserve this; assert the correct value. */
> +    g_assert(cpu == current_cpu);
> +
> +#ifdef CONFIG_USER_ONLY
> +    clear_helper_retaddr();
> +    if (have_mmap_lock()) {
> +        mmap_unlock();
> +    }
> +#endif
> +    if (qemu_mutex_iothread_locked()) {
> +        qemu_mutex_unlock_iothread();
> +    }
> +    assert_no_pages_locked();
> +}
> +
>  void cpu_exec_step_atomic(CPUState *cpu)
>  {
>      CPUArchState *env = cpu->env_ptr;
> @@ -568,16 +585,7 @@ void cpu_exec_step_atomic(CPUState *cpu)
>          cpu_tb_exec(cpu, tb, &tb_exit);
>          cpu_exec_exit(cpu);
>      } else {
> -#ifdef CONFIG_USER_ONLY
> -        clear_helper_retaddr();
> -        if (have_mmap_lock()) {
> -            mmap_unlock();
> -        }
> -#endif
> -        if (qemu_mutex_iothread_locked()) {
> -            qemu_mutex_unlock_iothread();
> -        }
> -        assert_no_pages_locked();
> +        cpu_exec_longjmp_cleanup(cpu);
>      }
>  
>      /*
> @@ -1023,20 +1031,7 @@ static int cpu_exec_setjmp(CPUState *cpu, SyncClocks *sc)
>  {
>      /* Prepare setjmp context for exception handling. */
>      if (unlikely(sigsetjmp(cpu->jmp_env, 0) != 0)) {
> -        /* Non-buggy compilers preserve this; assert the correct value. */
> -        g_assert(cpu == current_cpu);
> -
> -#ifdef CONFIG_USER_ONLY
> -        clear_helper_retaddr();
> -        if (have_mmap_lock()) {
> -            mmap_unlock();
> -        }
> -#endif
> -        if (qemu_mutex_iothread_locked()) {
> -            qemu_mutex_unlock_iothread();
> -        }
> -
> -        assert_no_pages_locked();
> +        cpu_exec_longjmp_cleanup(cpu);
>      }
>  
>      return cpu_exec_loop(cpu, sc);
> -- 
> 2.34.1

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-builder quickly builds VMs from scratch
http://libguestfs.org/virt-builder.1.html



  reply	other threads:[~2023-07-06 17:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-06 17:05 [PATCH 0/2] accel/tcg: Fix race condition in tb create/invalidate Richard Henderson
2023-07-06 17:05 ` [PATCH 1/2] accel/tcg: Split out cpu_exec_longjmp_cleanup Richard Henderson
2023-07-06 17:46   ` Richard W.M. Jones [this message]
2023-07-07  8:09   ` Philippe Mathieu-Daudé
2023-07-07 10:37     ` Richard Henderson
2023-07-06 17:05 ` [PATCH 2/2] accel/tcg: Always lock pages before translation Richard Henderson
2023-07-06 19:33   ` Richard W.M. Jones
2023-07-07  8:05   ` 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=20230706174642.GP7636@redhat.com \
    --to=rjones@redhat.com \
    --cc=anders.roxell@linaro.org \
    --cc=arnd@arndb.de \
    --cc=ben.copeland@linaro.org \
    --cc=daniel.diaz@linaro.org \
    --cc=naresh.kamboju@linaro.org \
    --cc=pbonzini@redhat.com \
    --cc=peterz@infradead.org \
    --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.