qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] cpus: Move CPU code from exec.c to cpus.c


From: Paolo Bonzini
Subject: Re: [PATCH] cpus: Move CPU code from exec.c to cpus.c
Date: Thu, 2 Jul 2020 11:38:24 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0

On 01/07/20 19:54, Philippe Mathieu-Daudé wrote:
> This code was introduced with SMP support in commit 6a00d60127,
> later commit 296af7c952 moved CPU parts to cpus.c but forgot this
> code. Move now and simplify ifdef'ry.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  cpus.c | 18 ++++++++++++++++++
>  exec.c | 22 ----------------------
>  2 files changed, 18 insertions(+), 22 deletions(-)
> 
> diff --git a/cpus.c b/cpus.c
> index 41d1c5099f..472686cbbc 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -92,6 +92,11 @@ static unsigned int throttle_percentage;
>  #define CPU_THROTTLE_PCT_MAX 99
>  #define CPU_THROTTLE_TIMESLICE_NS 10000000
>  
> +CPUTailQ cpus = QTAILQ_HEAD_INITIALIZER(cpus);
> +
> +/* current CPU in the current thread. It is only valid inside cpu_exec() */
> +__thread CPUState *current_cpu;
> +
>  bool cpu_is_stopped(CPUState *cpu)
>  {
>      return cpu->stopped || !runstate_is_running();
> @@ -134,6 +139,19 @@ static bool all_cpu_threads_idle(void)
>      return true;
>  }
>  
> +CPUState *qemu_get_cpu(int index)
> +{
> +    CPUState *cpu;
> +
> +    CPU_FOREACH(cpu) {
> +        if (cpu->cpu_index == index) {
> +            return cpu;
> +        }
> +    }
> +
> +    return NULL;
> +}
> +
>  /***********************************************************/
>  /* guest cycle counter */
>  
> diff --git a/exec.c b/exec.c
> index 21926dc9c7..997b7db15f 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -98,12 +98,6 @@ AddressSpace address_space_memory;
>  static MemoryRegion io_mem_unassigned;
>  #endif
>  
> -CPUTailQ cpus = QTAILQ_HEAD_INITIALIZER(cpus);
> -
> -/* current CPU in the current thread. It is only valid inside
> -   cpu_exec() */
> -__thread CPUState *current_cpu;
> -
>  uintptr_t qemu_host_page_size;
>  intptr_t qemu_host_page_mask;
>  
> @@ -832,22 +826,6 @@ const VMStateDescription vmstate_cpu_common = {
>      }
>  };
>  
> -#endif
> -
> -CPUState *qemu_get_cpu(int index)
> -{
> -    CPUState *cpu;
> -
> -    CPU_FOREACH(cpu) {
> -        if (cpu->cpu_index == index) {
> -            return cpu;
> -        }
> -    }
> -
> -    return NULL;
> -}
> -
> -#if !defined(CONFIG_USER_ONLY)
>  void cpu_address_space_init(CPUState *cpu, int asidx,
>                              const char *prefix, MemoryRegion *mr)
>  {
> 

Queued, thanks.

Paolo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]