qemu-s390x
[Top][All Lists]
Advanced

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

Re: [PATCH v1 06/14] s390x: introduce s390_get_memory_limit()


From: Nina Schoetterl-Glausch
Subject: Re: [PATCH v1 06/14] s390x: introduce s390_get_memory_limit()
Date: Mon, 16 Sep 2024 15:20:04 +0200
User-agent: Evolution 3.52.3 (3.52.3-1.fc40)

On Tue, 2024-09-10 at 19:58 +0200, David Hildenbrand wrote:
> Let's add s390_get_memory_limit(), to query what has been successfully
> set via s390_set_memory_limit(). Allow setting the limit only once.
> 
> Signed-off-by: David Hildenbrand <david@redhat.com>

Reviewed-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>

Comment below.
> ---
>  target/s390x/cpu-sysemu.c | 19 +++++++++++++++++--
>  target/s390x/cpu.h        |  1 +
>  2 files changed, 18 insertions(+), 2 deletions(-)
> 
> diff --git a/target/s390x/cpu-sysemu.c b/target/s390x/cpu-sysemu.c
> index 1cd30c1d84..1915567b3a 100644
> --- a/target/s390x/cpu-sysemu.c
> +++ b/target/s390x/cpu-sysemu.c
> @@ -255,12 +255,27 @@ unsigned int s390_cpu_set_state(uint8_t cpu_state, 
> S390CPU *cpu)
>      return s390_count_running_cpus();
>  }
>  
> +static uint64_t memory_limit;
> +
>  int s390_set_memory_limit(uint64_t new_limit, uint64_t *hw_limit)
>  {
> +    int ret = 0;
> +
> +    if (memory_limit) {
> +        return -EBUSY;
> +    }
>      if (kvm_enabled()) {
> -        return kvm_s390_set_mem_limit(new_limit, hw_limit);
> +        ret = kvm_s390_set_mem_limit(new_limit, hw_limit);
> +    }
> +    if (!ret) {
> +        memory_limit = new_limit;
>      }
> -    return 0;
> +    return ret;
> +}
> +
> +uint64_t s390_get_memory_limit(void)
> +{

Might be nice to guard/warn against s390_set_memory_limit not having been 
called before.

> +    return memory_limit;
>  }
>  
>  void s390_set_max_pagesize(uint64_t pagesize, Error **errp)
> diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
> index d6b75ad0e0..7a51b606ed 100644
> --- a/target/s390x/cpu.h
> +++ b/target/s390x/cpu.h
> @@ -895,6 +895,7 @@ static inline void s390_do_cpu_load_normal(CPUState *cs, 
> run_on_cpu_data arg)
>  /* cpu.c */
>  void s390_crypto_reset(void);
>  int s390_set_memory_limit(uint64_t new_limit, uint64_t *hw_limit);
> +uint64_t s390_get_memory_limit(void);
>  void s390_set_max_pagesize(uint64_t pagesize, Error **errp);
>  void s390_cmma_reset(void);
>  void s390_enable_css_support(S390CPU *cpu);




reply via email to

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