qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: "Claudio Fontana" <cfontana@suse.de>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Alex Bennée" <alex.bennee@linaro.org>
Cc: qemu-devel@nongnu.org
Subject: Re: [RFC v1 1/2] accel/tcg: split CpusAccel into three TCG variants
Date: Wed, 14 Oct 2020 09:58:45 +0200	[thread overview]
Message-ID: <64b1e350-ed12-ffee-24a1-a6abfccc53ce@redhat.com> (raw)
In-Reply-To: <20201014073605.6155-2-cfontana@suse.de>

On 10/14/20 9:36 AM, Claudio Fontana wrote:
> split up the CpusAccel tcg_cpus into three TCG variants:
> 
> tcg_cpus_rr (single threaded, round robin cpus)
> tcg_cpus_icount (same as rr, but with instruction counting enabled)
> tcg_cpus_mttcg (multi-threaded cpus)
> 
> Signed-off-by: Claudio Fontana <cfontana@suse.de>
> ---
>   accel/tcg/meson.build       |   9 +-
>   accel/tcg/tcg-all.c         |   8 +-
>   accel/tcg/tcg-cpus-icount.c | 145 +++++++++++
>   accel/tcg/tcg-cpus-icount.h |  20 ++
>   accel/tcg/tcg-cpus-mttcg.c  | 118 +++++++++
>   accel/tcg/tcg-cpus-mttcg.h  |  25 ++
>   accel/tcg/tcg-cpus-rr.c     | 270 ++++++++++++++++++++
>   accel/tcg/tcg-cpus-rr.h     |  23 ++
>   accel/tcg/tcg-cpus.c        | 478 ++----------------------------------
>   accel/tcg/tcg-cpus.h        |   9 +-
>   softmmu/icount.c            |   2 +-
>   11 files changed, 647 insertions(+), 460 deletions(-)
>   create mode 100644 accel/tcg/tcg-cpus-icount.c
>   create mode 100644 accel/tcg/tcg-cpus-icount.h
>   create mode 100644 accel/tcg/tcg-cpus-mttcg.c
>   create mode 100644 accel/tcg/tcg-cpus-mttcg.h
>   create mode 100644 accel/tcg/tcg-cpus-rr.c
>   create mode 100644 accel/tcg/tcg-cpus-rr.h
...

> diff --git a/accel/tcg/tcg-cpus-icount.c b/accel/tcg/tcg-cpus-icount.c
> new file mode 100644
> index 0000000000..43505e8f1f
> --- /dev/null
> +++ b/accel/tcg/tcg-cpus-icount.c
> @@ -0,0 +1,145 @@
> +/*
> + * QEMU System Emulator

"QEMU single threaded vCPUs implementation using instruction counting"?

> + *
> + * Copyright (c) 2003-2008 Fabrice Bellard
> + * Copyright (c) 2014 Red Hat Inc.
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a copy
> + * of this software and associated documentation files (the "Software"), to deal
> + * in the Software without restriction, including without limitation the rights
> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> + * copies of the Software, and to permit persons to whom the Software is
> + * furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be included in
> + * all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> + * THE SOFTWARE.
> + */
...

> diff --git a/accel/tcg/tcg-cpus-icount.h b/accel/tcg/tcg-cpus-icount.h
> new file mode 100644
> index 0000000000..e2e25674c2
> --- /dev/null
> +++ b/accel/tcg/tcg-cpus-icount.h
> @@ -0,0 +1,20 @@
> +/*
> + * Accelerator CPUS Interface

Ditto.

> + *
> + * Copyright 2020 SUSE LLC
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2 or later.
> + * See the COPYING file in the top-level directory.
> + */
> +
> +#ifndef TCG_CPUS_ICOUNT_H
> +#define TCG_CPUS_ICOUNT_H
> +
> +extern const CpusAccel tcg_cpus_icount;
> +
> +int64_t tcg_get_icount_limit(void);
> +void handle_icount_deadline(void);
> +void prepare_icount_for_run(CPUState *cpu);
> +void process_icount_data(CPUState *cpu);
> +
> +#endif /* TCG_CPUS_ICOUNT_H */
> diff --git a/accel/tcg/tcg-cpus-mttcg.c b/accel/tcg/tcg-cpus-mttcg.c
> new file mode 100644
> index 0000000000..2f5317d767
> --- /dev/null
> +++ b/accel/tcg/tcg-cpus-mttcg.c
> @@ -0,0 +1,118 @@
> +/*
> + * QEMU System Emulator

"QEMU multi-threaded vCPUs implementation"?

> + *
> + * Copyright (c) 2003-2008 Fabrice Bellard
> + * Copyright (c) 2014 Red Hat Inc.
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a copy
> + * of this software and associated documentation files (the "Software"), to deal
> + * in the Software without restriction, including without limitation the rights
> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> + * copies of the Software, and to permit persons to whom the Software is
> + * furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be included in
> + * all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> + * THE SOFTWARE.
> + */
...

> diff --git a/accel/tcg/tcg-cpus-mttcg.h b/accel/tcg/tcg-cpus-mttcg.h
> new file mode 100644
> index 0000000000..c8966b2f8a
> --- /dev/null
> +++ b/accel/tcg/tcg-cpus-mttcg.h
> @@ -0,0 +1,25 @@
> +/*
> + * Accelerator CPUS Interface

Ditto.

> + *
> + * Copyright 2020 SUSE LLC
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2 or later.
> + * See the COPYING file in the top-level directory.
> + */
> +
> +#ifndef TCG_CPUS_MTTCG_H
> +#define TCG_CPUS_MTTCG_H
> +
> +extern const CpusAccel tcg_cpus_mttcg;
> +
> +/*
> + * Multi-threaded TCG
> + *
> + * In the multi-threaded case each vCPU has its own thread. The TLS
> + * variable current_cpu can be used deep in the code to find the
> + * current CPUState for a given thread.
> + */
> +
> +void *tcg_cpu_thread_fn(void *arg);
> +
> +#endif /* TCG_CPUS_MTTCG_H */
> diff --git a/accel/tcg/tcg-cpus-rr.c b/accel/tcg/tcg-cpus-rr.c
> new file mode 100644
> index 0000000000..b8fd33d9d3
> --- /dev/null
> +++ b/accel/tcg/tcg-cpus-rr.c
> @@ -0,0 +1,270 @@
> +/*
> + * QEMU System Emulator

"QEMU single threaded (using round robin) vCPUs implementation"?

> + *
> + * Copyright (c) 2003-2008 Fabrice Bellard
> + * Copyright (c) 2014 Red Hat Inc.
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a copy
> + * of this software and associated documentation files (the "Software"), to deal
> + * in the Software without restriction, including without limitation the rights
> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> + * copies of the Software, and to permit persons to whom the Software is
> + * furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be included in
> + * all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> + * THE SOFTWARE.
> + */
...

> diff --git a/accel/tcg/tcg-cpus-rr.h b/accel/tcg/tcg-cpus-rr.h
> new file mode 100644
> index 0000000000..155510cfd4
> --- /dev/null
> +++ b/accel/tcg/tcg-cpus-rr.h
> @@ -0,0 +1,23 @@
> +/*
> + * Accelerator CPUS Interface

Ditto.

> + *
> + * Copyright 2020 SUSE LLC
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2 or later.
> + * See the COPYING file in the top-level directory.
> + */
> +
> +#ifndef TCG_CPUS_RR_H
> +#define TCG_CPUS_RR_H
> +
> +extern const CpusAccel tcg_cpus_rr;
> +
> +#define TCG_KICK_PERIOD (NANOSECONDS_PER_SECOND / 10)
> +
> +/* Kick all RR vCPUs. */
> +void qemu_cpu_kick_rr_cpus(CPUState *unused);
> +
> +/* Single-threaded TCG */
> +void *tcg_rr_cpu_thread_fn(void *arg);
> +
> +#endif /* TCG_CPUS_RR_H */
...

> diff --git a/accel/tcg/tcg-cpus.h b/accel/tcg/tcg-cpus.h
> index 8b1d9d2abc..871e58507d 100644
> --- a/accel/tcg/tcg-cpus.h
> +++ b/accel/tcg/tcg-cpus.h
> @@ -12,6 +12,13 @@
>   
>   #include "sysemu/cpus.h"
>   
> -extern const CpusAccel tcg_cpus;
> +#include "tcg-cpus-rr.h"
> +#include "tcg-cpus-icount.h"
> +#include "tcg-cpus-mttcg.h"

Why do we need to include the implementation declarations?

> +
> +void tcg_start_vcpu_thread(CPUState *cpu);
> +void qemu_tcg_destroy_vcpu(CPUState *cpu);
> +int tcg_cpu_exec(CPUState *cpu);
> +void tcg_handle_interrupt(CPUState *cpu, int mask);
>   
>   #endif /* TCG_CPUS_H */
> diff --git a/softmmu/icount.c b/softmmu/icount.c
> index 020a201a01..dbcd8c3594 100644
> --- a/softmmu/icount.c
> +++ b/softmmu/icount.c
> @@ -396,7 +396,7 @@ void icount_start_warp_timer(void)
>   
>   void icount_account_warp_timer(void)
>   {
> -    if (!icount_enabled() || !icount_sleep) {
> +    if (!icount_sleep) {
>           return;
>       }
>   
> 



  reply	other threads:[~2020-10-14  7:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-14  7:36 [RFC v1 0/2] tcg-cpus: split into 3 tcg variants Claudio Fontana
2020-10-14  7:36 ` [RFC v1 1/2] accel/tcg: split CpusAccel into three TCG variants Claudio Fontana
2020-10-14  7:58   ` Philippe Mathieu-Daudé [this message]
2020-10-14  7:36 ` [RFC v1 2/2] accel/tcg: split tcg_start_vcpu_thread Claudio Fontana
2020-10-14  8:00 ` [RFC v1 0/2] tcg-cpus: split into 3 tcg variants Philippe Mathieu-Daudé
2020-10-14 10:14 ` Alex Bennée
2020-10-14 10:21   ` Claudio Fontana
2020-10-14 11:21   ` Philippe Mathieu-Daudé

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=64b1e350-ed12-ffee-24a1-a6abfccc53ce@redhat.com \
    --to=philmd@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=cfontana@suse.de \
    --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 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).