From: Cornelia Huck <cohuck@redhat.com>
To: Igor Mammedov <imammedo@redhat.com>
Cc: qemu-devel@nongnu.org, pasic@linux.ibm.com,
borntraeger@de.ibm.com, rth@twiddle.net, david@redhat.com,
qemu-s390x@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] s390x: remove direct reference to mem_path global form s90x code
Date: Fri, 25 Jan 2019 10:23:05 +0100 [thread overview]
Message-ID: <20190125102305.76f1bc71.cohuck@redhat.com> (raw)
In-Reply-To: <1548349076-350255-1-git-send-email-imammedo@redhat.com>
On Thu, 24 Jan 2019 17:57:56 +0100
Igor Mammedov <imammedo@redhat.com> wrote:
> I plan to deprecate -mem-path option and replace it with memory-backend,
> for that it's necessary to get rid of mem_path global variable.
> Do it for s390x case, replacing it with alternative way to enable
> 1Mb hugepages capability.
Getting rid of accessing mem_path directly sounds good.
>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
> PS:
> Original code nor the new one probably is not entirely correct when
> huge pages are enabled in case where mixed initial RAM and memory
> backends are used, backend's page size might not match initial RAM's
> so I'm not sure if enabling 1MB cap is correct in this case on s390
> (should it be the same for all RAM???).
> With new approach 1Mb cap is not enabled if the smallest page size
> is not 1Mb.
> ---
> target/s390x/kvm.c | 37 ++++++++++++++++---------------------
> 1 file changed, 16 insertions(+), 21 deletions(-)
>
> diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
> index 2ebf26a..22e868a 100644
> --- a/target/s390x/kvm.c
> +++ b/target/s390x/kvm.c
> @@ -285,33 +285,28 @@ void kvm_s390_crypto_reset(void)
> }
> }
>
> -static int kvm_s390_configure_mempath_backing(KVMState *s)
> +static int kvm_s390_configure_hugepage_backing(KVMState *s)
> {
> - size_t path_psize = qemu_mempath_getpagesize(mem_path);
> + size_t psize = qemu_getrampagesize();
>
> - if (path_psize == 4 * KiB) {
> - return 0;
> - }
> -
> - if (!hpage_1m_allowed()) {
> - error_report("This QEMU machine does not support huge page "
> - "mappings");
> - return -EINVAL;
> - }
> + if (psize == 1 * MiB) {
> + if (!hpage_1m_allowed()) {
> + error_report("This QEMU machine does not support huge page "
> + "mappings");
> + return -EINVAL;
> + }
>
> - if (path_psize != 1 * MiB) {
> + if (kvm_vm_enable_cap(s, KVM_CAP_S390_HPAGE_1M, 0)) {
> + error_report("Memory backing with 1M pages was specified, "
> + "but KVM does not support this memory backing");
> + return -EINVAL;
> + }
> + cap_hpage_1m = 1;
> + } else if (psize == 2 * GiB) {
> error_report("Memory backing with 2G pages was specified, "
> "but KVM does not support this memory backing");
> return -EINVAL;
> }
> -
> - if (kvm_vm_enable_cap(s, KVM_CAP_S390_HPAGE_1M, 0)) {
> - error_report("Memory backing with 1M pages was specified, "
> - "but KVM does not support this memory backing");
> - return -EINVAL;
> - }
> -
> - cap_hpage_1m = 1;
> return 0;
Just to compare, the old code did:
- 4K pages -> all fine, do nothing
- 1MB pages not allowed -> get out, regardless of the actual huge page
size
- 1MB pages -> try to enable, if possible
- all other sizes -> moan about 2G pages and get out
And the new code does:
- 1M pages -> get out if 1MB not allowed, otherwise try to enable
- 2G pages -> moan about 2G pages and get out
- all other sizes -> all fine, do nothing
So, now the user will:
- get a different error if they try to run with a 2G backing but
hpage_1m_allowed is off (which does not sound like a problem to me)
- get the all-clear if they specified a hypothetical different page
size, while the code always complained about 2G pages before
Are there any chances at all that there may Yet Another Size? If not,
this looks fine.
> }
>
> @@ -319,7 +314,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
> {
> MachineClass *mc = MACHINE_GET_CLASS(ms);
>
> - if (mem_path && kvm_s390_configure_mempath_backing(s)) {
> + if (kvm_s390_configure_hugepage_backing(s)) {
> return -EINVAL;
> }
>
next prev parent reply other threads:[~2019-01-25 9:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-24 16:57 [Qemu-devel] [PATCH] s390x: remove direct reference to mem_path global form s90x code Igor Mammedov
2019-01-25 8:03 ` David Hildenbrand
2019-01-25 10:40 ` Igor Mammedov
2019-01-25 11:41 ` Christian Borntraeger
2019-01-28 11:28 ` David Hildenbrand
2019-01-25 9:23 ` Cornelia Huck [this message]
2019-01-25 9:27 ` David Hildenbrand
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=20190125102305.76f1bc71.cohuck@redhat.com \
--to=cohuck@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=david@redhat.com \
--cc=imammedo@redhat.com \
--cc=pasic@linux.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=rth@twiddle.net \
/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).