From: Marc Orr <marcorr@google.com>
To: dave.hansen@intel.com
Cc: kvm@vger.kernel.org, Jim Mattson <jmattson@google.com>,
David Rientjes <rientjes@google.com>,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
linux-mm@kvack.org, akpm@linux-foundation.org,
pbonzini@redhat.com, rkrcmar@redhat.com, willy@infradead.org,
sean.j.christopherson@intel.com, dave.hansen@linux.intel.com,
Wanpeng Li <kernellwp@gmail.com>
Subject: Re: [kvm PATCH v5 2/4] kvm: x86: Dynamically allocate guest_fpu
Date: Wed, 31 Oct 2018 14:13:51 -0700 [thread overview]
Message-ID: <CAA03e5HmMq-+9WsJ+Kd05ary85A7HJ5HJbNMUzc87QCRxamJGg@mail.gmail.com> (raw)
In-Reply-To: <cf476e07-e2fc-45c9-7259-3952a5cbb30e@intel.com>
> We should basically never be using sizeof(struct fpu), anywhere. As you
> saw, it's about a page in size, but the actual hardware FPU structure
> can be as small as ~500 bytes or as big as ~3k. Doing it this way is a
> pretty unnecessary waste of memory because sizeof(struct fpu) is sized
> for the worst-case (largest) possible XSAVE buffer that we support on
> *any* CPU. It will also get way worse if anyone ever throws a bunch
> more state into the XSAVE area and we need to make it way bigger.
>
> If you want a kmem cache for this, I'd suggest creating a cache which is
> the size of the host XSAVE buffer. That can be found in a variable
> called 'fpu_kernel_xstate_size'. I'm assuming here that the guest FPU
> is going to support a strict subset of host kernel XSAVE states.
This suggestion sounds good. Though, I have one uncertainty. KVM
explicitly cast guest_fpu.state as a fxregs_state in a few places
(e.g., the ioctls). Yet, I see a code path in
fpu__init_system_xstate_size_legacy() that sets fpu_kernel_xstate_size
to sizeof(struct fregs_state). Will this cause problems? You mentioned
that the fpu's state field is expected to range from ~500 bytes to
~3k, which implies that it should never get set to sizeof(struct
fregs_state). But I want to confirm.
>
>
> The other alternative is to calculate the actual size of the XSAVE
> buffer that the guest needs. You can do that from the values that KVM
> sets to limit guest XCR0 values (the name of the control field is
> escaping me at the moment).
next prev parent reply other threads:[~2018-10-31 21:14 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-31 13:26 [kvm PATCH v5 0/4] shrink vcpu_vmx down to order 2 Marc Orr
2018-10-31 13:26 ` [kvm PATCH v5 1/4] kvm: x86: Use task structs fpu field for user Marc Orr
2018-10-31 13:26 ` [kvm PATCH v5 2/4] kvm: x86: Dynamically allocate guest_fpu Marc Orr
2018-10-31 14:11 ` Dave Hansen
2018-10-31 21:13 ` Marc Orr [this message]
2018-10-31 21:21 ` Dave Hansen
2018-10-31 21:24 ` Marc Orr
2018-10-31 21:30 ` Dave Hansen
2018-10-31 21:39 ` Marc Orr
2018-10-31 21:44 ` Dave Hansen
2018-10-31 13:26 ` [kvm PATCH v5 3/4] kvm: vmx: refactor vmx_msrs struct for vmalloc Marc Orr
2018-10-31 14:12 ` Dave Hansen
2018-10-31 14:15 ` Sean Christopherson
2018-10-31 14:19 ` Marc Orr
2018-10-31 13:26 ` [kvm PATCH v5 4/4] kvm: vmx: use vmalloc() to allocate vcpus Marc Orr
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=CAA03e5HmMq-+9WsJ+Kd05ary85A7HJ5HJbNMUzc87QCRxamJGg@mail.gmail.com \
--to=marcorr@google.com \
--cc=akpm@linux-foundation.org \
--cc=dave.hansen@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=jmattson@google.com \
--cc=kernellwp@gmail.com \
--cc=konrad.wilk@oracle.com \
--cc=kvm@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=pbonzini@redhat.com \
--cc=rientjes@google.com \
--cc=rkrcmar@redhat.com \
--cc=sean.j.christopherson@intel.com \
--cc=willy@infradead.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