kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andre Przywara <andre.przywara@arm.com>
To: Alexandru Elisei <alexandru.elisei@arm.com>
Cc: kvm@vger.kernel.org, Will Deacon <will@kernel.org>,
	Julien Thierry <julien.thierry.kdev@gmail.com>,
	Marc Zyngier <maz@kernel.org>,
	Suzuki Poulose <suzuki.poulose@arm.com>,
	Julien Grall <julien.grall.oss@gmail.com>
Subject: Re: [PATCH kvmtool 02/16] kvm__arch_init: Don't pass hugetlbfs_path and ram_size in parameter
Date: Wed, 6 Nov 2019 16:47:28 +0000	[thread overview]
Message-ID: <20191106164728.7cba9e9e@donnerap.cambridge.arm.com> (raw)
In-Reply-To: <1569245722-23375-3-git-send-email-alexandru.elisei@arm.com>

On Mon, 23 Sep 2019 14:35:08 +0100
Alexandru Elisei <alexandru.elisei@arm.com> wrote:

Hi,

> From: Julien Grall <julien.grall@arm.com>
> 
> The structure KVM already contains a pointer to the configuration. Both
> hugetlbfs_path and ram_size are part of the configuration, so is it not
> necessary to path them again in parameter.
> 
> Signed-off-by: Julien Grall <julien.grall@arm.com>
> Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
> ---
>  arm/kvm.c         | 5 ++++-
>  include/kvm/kvm.h | 2 +-
>  kvm.c             | 2 +-
>  mips/kvm.c        | 5 ++++-
>  powerpc/kvm.c     | 5 ++++-
>  x86/kvm.c         | 5 ++++-
>  6 files changed, 18 insertions(+), 6 deletions(-)
> 
> diff --git a/arm/kvm.c b/arm/kvm.c
> index 1c5bdb8026bf..198cee5c0997 100644
> --- a/arm/kvm.c
> +++ b/arm/kvm.c
> @@ -57,9 +57,12 @@ void kvm__arch_set_cmdline(char *cmdline, bool video)
>  {
>  }
>  
> -void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size)
> +void kvm__arch_init(struct kvm *kvm)
>  {
>  	unsigned long alignment;
> +	/* Convenience aliases */
> +	u64 ram_size = kvm->cfg.ram_size;
> +	const char *hugetlbfs_path = kvm->cfg.hugetlbfs_path;

Do we really need these aliases?
Definitely we should lose the comment ...

>  	/*
>  	 * Allocate guest memory. If the user wants to use hugetlbfs, then the
> diff --git a/include/kvm/kvm.h b/include/kvm/kvm.h
> index 7a738183d67a..635ce0f40b1e 100644
> --- a/include/kvm/kvm.h
> +++ b/include/kvm/kvm.h
> @@ -140,7 +140,7 @@ int kvm__enumerate_instances(int (*callback)(const char *name, int pid));
>  void kvm__remove_socket(const char *name);
>  
>  void kvm__arch_set_cmdline(char *cmdline, bool video);
> -void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size);
> +void kvm__arch_init(struct kvm *kvm);
>  void kvm__arch_delete_ram(struct kvm *kvm);
>  int kvm__arch_setup_firmware(struct kvm *kvm);
>  int kvm__arch_free_firmware(struct kvm *kvm);
> diff --git a/kvm.c b/kvm.c
> index 57c4ff98ec4c..36b238791fc1 100644
> --- a/kvm.c
> +++ b/kvm.c
> @@ -392,7 +392,7 @@ int kvm__init(struct kvm *kvm)
>  		goto err_vm_fd;
>  	}
>  
> -	kvm__arch_init(kvm, kvm->cfg.hugetlbfs_path, kvm->cfg.ram_size);
> +	kvm__arch_init(kvm);
>  
>  	INIT_LIST_HEAD(&kvm->mem_banks);
>  	kvm__init_ram(kvm);
> diff --git a/mips/kvm.c b/mips/kvm.c
> index 211770da0d85..e2a0c63b14b8 100644
> --- a/mips/kvm.c
> +++ b/mips/kvm.c
> @@ -57,9 +57,12 @@ void kvm__arch_set_cmdline(char *cmdline, bool video)
>  }
>  
>  /* Architecture-specific KVM init */
> -void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size)
> +void kvm__arch_init(struct kvm *kvm)
>  {
>  	int ret;
> +	/* Convenience aliases */
> +	u64 ram_size = kvm->cfg.ram_size;
> +	const char *hugetlbfs_path = kvm->cfg.hugetlbfs_path;

Same here, there is only one user of hugetlbfs_path.

>  	kvm->ram_start = mmap_anon_or_hugetlbfs(kvm, hugetlbfs_path, ram_size);
>  	kvm->ram_size = ram_size;
> diff --git a/powerpc/kvm.c b/powerpc/kvm.c
> index 702d67dca614..034bc4608ad9 100644
> --- a/powerpc/kvm.c
> +++ b/powerpc/kvm.c
> @@ -88,10 +88,13 @@ void kvm__arch_set_cmdline(char *cmdline, bool video)
>  }
>  
>  /* Architecture-specific KVM init */
> -void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size)
> +void kvm__arch_init(struct kvm *kvm)
>  {
>  	int cap_ppc_rma;
>  	unsigned long hpt;
> +	/* Convenience aliases */

Not needed and not even true for hugetlbfs_path.

> +	u64 ram_size = kvm->cfg.ram_size;

This is somewhat pointless, the only user is right below the next line ...

> +	const char *hugetlbfs_path = kvm->cfg.hugetlbfs_path;

We need to keep that, though, as the code modifies it.

>  
>  	kvm->ram_size		= ram_size;
>  
> diff --git a/x86/kvm.c b/x86/kvm.c
> index 3e0f0b743f8c..5abb41e370bb 100644
> --- a/x86/kvm.c
> +++ b/x86/kvm.c
> @@ -130,10 +130,13 @@ void kvm__arch_set_cmdline(char *cmdline, bool video)
>  }
>  
>  /* Architecture-specific KVM init */
> -void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size)
> +void kvm__arch_init(struct kvm *kvm)
>  {
>  	struct kvm_pit_config pit_config = { .flags = 0, };
>  	int ret;
> +	/* Convenience aliases */

I don't think the comment is needed.

Otherwise it's a nice cleanup.

Cheers,
Andre

> +	u64 ram_size = kvm->cfg.ram_size;
> +	const char *hugetlbfs_path = kvm->cfg.hugetlbfs_path;
>  
>  	ret = ioctl(kvm->vm_fd, KVM_SET_TSS_ADDR, 0xfffbd000);
>  	if (ret < 0)


  reply	other threads:[~2019-11-06 16:47 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-23 13:35 [PATCH kvmtool 00/16] arm: Allow the user to define the memory layout Alexandru Elisei
2019-09-23 13:35 ` [PATCH kvmtool 01/16] arm: Allow use of hugepage with 16K pagesize host Alexandru Elisei
2019-11-06 16:47   ` Andre Przywara
2019-11-06 17:29     ` Alexandru Elisei
2019-09-23 13:35 ` [PATCH kvmtool 02/16] kvm__arch_init: Don't pass hugetlbfs_path and ram_size in parameter Alexandru Elisei
2019-11-06 16:47   ` Andre Przywara [this message]
2019-11-07 10:03     ` Alexandru Elisei
2019-09-23 13:35 ` [PATCH kvmtool 03/16] virtio/scsi: Allow the use of multiple banks Alexandru Elisei
2019-11-06 16:48   ` Andre Przywara
2020-02-05 18:07   ` Suzuki Kuruppassery Poulose
2019-09-23 13:35 ` [PATCH kvmtool 04/16] kvmtool: Add helper to sanitize arch specific KVM configuration Alexandru Elisei
2019-11-06 16:48   ` Andre Przywara
2019-11-07 10:05     ` Alexandru Elisei
2020-02-05 18:16   ` Suzuki Kuruppassery Poulose
2019-09-23 13:35 ` [PATCH kvmtool 05/16] kvmtool: Use MB consistently Alexandru Elisei
2019-11-06 16:49   ` Andre Przywara
2020-02-05 18:17   ` Suzuki Kuruppassery Poulose
2019-09-23 13:35 ` [PATCH kvmtool 06/16] builtin-run.c: Always use ram_size in bytes Alexandru Elisei
2019-11-06 16:49   ` Andre Przywara
2019-11-07 10:08     ` Alexandru Elisei
2020-02-05 19:03   ` Suzuki Kuruppassery Poulose
2019-09-23 13:35 ` [PATCH kvmtool 07/16] arm: Remove redundant define ARM_PCI_CFG_SIZE Alexandru Elisei
2019-11-06 16:49   ` Andre Przywara
2020-02-06 11:49   ` Suzuki Kuruppassery Poulose
2019-09-23 13:35 ` [PATCH kvmtool 08/16] arm: Move anything related to RAM initialization in kvm__init_ram Alexandru Elisei
2019-11-07 13:46   ` Andre Przywara
2019-09-23 13:35 ` [PATCH kvmtool 09/16] arm: Allow the user to specify RAM base address Alexandru Elisei
2019-11-07 13:54   ` Andre Przywara
2020-02-06 12:20   ` Suzuki Kuruppassery Poulose
2019-09-23 13:35 ` [PATCH kvmtool 10/16] kvmtool: Allow standard size specifiers for memory Alexandru Elisei
2019-11-07 13:55   ` Andre Przywara
2019-09-23 13:35 ` [PATCH kvmtool 11/16] arm/pci: Remove unused ioports Alexandru Elisei
2019-09-23 13:35 ` [PATCH kvmtool 12/16] Fold kvm__init_ram call in kvm__arch_init and rename it Alexandru Elisei
2019-09-23 13:35 ` [PATCH kvmtool 13/16] arm: Allow any base address for RAM Alexandru Elisei
2019-09-23 13:35 ` [PATCH kvmtool 14/16] arm: Move memory related code to memory.c Alexandru Elisei
2019-09-23 13:35 ` [PATCH kvmtool 15/16] kvmtool: Make the size@addr option parser globally visible Alexandru Elisei
2019-09-23 13:35 ` [PATCH kvmtool 16/16] arm: Allow the user to define the MMIO regions Alexandru Elisei
2020-02-05 17:16 ` [PATCH kvmtool 00/16] arm: Allow the user to define the memory layout Will Deacon
2020-02-05 17:18   ` Alexandru Elisei
2020-02-06  9:20     ` Marc Zyngier

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=20191106164728.7cba9e9e@donnerap.cambridge.arm.com \
    --to=andre.przywara@arm.com \
    --cc=alexandru.elisei@arm.com \
    --cc=julien.grall.oss@gmail.com \
    --cc=julien.thierry.kdev@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=suzuki.poulose@arm.com \
    --cc=will@kernel.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).