From: David Hildenbrand <david@redhat.com>
To: Xiaoyao Li <xiaoyao.li@intel.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Sean Christopherson <seanjc@google.com>,
Igor Mammedov <imammedo@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
Marcel Apfelbaum <marcel.apfelbaum@gmail.com>,
Richard Henderson <richard.henderson@linaro.org>,
Marcelo Tosatti <mtosatti@redhat.com>
Cc: "Markus Armbruster" <armbru@redhat.com>,
"Eric Blake" <eblake@redhat.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Peter Xu" <peterx@redhat.com>,
"Chao Peng" <chao.p.peng@linux.intel.com>,
"Michael Roth" <michael.roth@amd.com>,
isaku.yamahata@gmail.com, qemu-devel@nongnu.org,
kvm@vger.kernel.org
Subject: Re: [RFC PATCH 08/19] HostMem: Add private property to indicate to use kvm gmem
Date: Wed, 2 Aug 2023 16:14:29 +0200 [thread overview]
Message-ID: <a154c33d-b24d-b713-0dc0-027d54f2340f@redhat.com> (raw)
In-Reply-To: <2addfff0-88bf-59aa-f2f3-8129366a006d@intel.com>
On 02.08.23 10:03, Xiaoyao Li wrote:
> On 8/2/2023 1:21 AM, David Hildenbrand wrote:
>> On 31.07.23 18:21, Xiaoyao Li wrote:
>>> From: Isaku Yamahata <isaku.yamahata@intel.com>
>>>
>>> Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com>
>>> Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
>>> ---
>>> backends/hostmem.c | 18 ++++++++++++++++++
>>> include/sysemu/hostmem.h | 2 +-
>>> qapi/qom.json | 4 ++++
>>> 3 files changed, 23 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/backends/hostmem.c b/backends/hostmem.c
>>> index 747e7838c031..dbdbb0aafd45 100644
>>> --- a/backends/hostmem.c
>>> +++ b/backends/hostmem.c
>>> @@ -461,6 +461,20 @@ static void
>>> host_memory_backend_set_reserve(Object *o, bool value, Error **errp)
>>> }
>>> backend->reserve = value;
>>> }
>>> +
>>> +static bool host_memory_backend_get_private(Object *o, Error **errp)
>>> +{
>>> + HostMemoryBackend *backend = MEMORY_BACKEND(o);
>>> +
>>> + return backend->private;
>>> +}
>>> +
>>> +static void host_memory_backend_set_private(Object *o, bool value,
>>> Error **errp)
>>> +{
>>> + HostMemoryBackend *backend = MEMORY_BACKEND(o);
>>> +
>>> + backend->private = value;
>>> +}
>>> #endif /* CONFIG_LINUX */
>>> static bool
>>> @@ -541,6 +555,10 @@ host_memory_backend_class_init(ObjectClass *oc,
>>> void *data)
>>> host_memory_backend_get_reserve,
>>> host_memory_backend_set_reserve);
>>> object_class_property_set_description(oc, "reserve",
>>> "Reserve swap space (or huge pages) if applicable");
>>> + object_class_property_add_bool(oc, "private",
>>> + host_memory_backend_get_private,
>>> host_memory_backend_set_private);
>>> + object_class_property_set_description(oc, "private",
>>> + "Use KVM gmem private memory");
>>> #endif /* CONFIG_LINUX */
>>> /*
>>> * Do not delete/rename option. This option must be considered
>>> stable
>>> diff --git a/include/sysemu/hostmem.h b/include/sysemu/hostmem.h
>>> index 39326f1d4f9c..d88970395618 100644
>>> --- a/include/sysemu/hostmem.h
>>> +++ b/include/sysemu/hostmem.h
>>> @@ -65,7 +65,7 @@ struct HostMemoryBackend {
>>> /* protected */
>>> uint64_t size;
>>> bool merge, dump, use_canonical_path;
>>> - bool prealloc, is_mapped, share, reserve;
>>> + bool prealloc, is_mapped, share, reserve, private;
>>> uint32_t prealloc_threads;
>>> ThreadContext *prealloc_context;
>>> DECLARE_BITMAP(host_nodes, MAX_NODES + 1);
>>> diff --git a/qapi/qom.json b/qapi/qom.json
>>> index 7f92ea43e8e1..e0b2044e3d20 100644
>>> --- a/qapi/qom.json
>>> +++ b/qapi/qom.json
>>> @@ -605,6 +605,9 @@
>>> # @reserve: if true, reserve swap space (or huge pages) if applicable
>>> # (default: true) (since 6.1)
>>> #
>>> +# @private: if true, use KVM gmem private memory
>>> +# (default: false) (since 8.1)
>>> +#
>>
>> But that's not what any of this does.
>>
>> This patch only adds a property and doesn't even explain what it intends
>> to achieve with that.
>>
>> How will it be used from a user? What will it affect internally? What
>> will it modify in regards of the memory backend?
>
> How it will be used is in the next patch, patch 09.
>
> for kvm_x86_sw_protected_vm type VM, it will allocate private gmem with
> KVM ioctl if the memory backend has property "private" on.
It feels wired up the wrong way.
When creating/initializing the memory backend, we should also take care
of allocating the gmem_fd, for example, by doing some gmem allocation
callback, ideally *internally* creating the RAM memory region / RAMBlock.
And we should fail if that is impossible (gmem does not apply to the VM)
or creating the gmem_fd failed for other reason.
Like passing a RAM_GMEM flag to memory_region_init_ram_flags_nomigrate()
in ram_backend_memory_alloc(), to then handle it internally, failing if
there is an error.
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2023-08-02 14:15 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-31 16:21 [RFC PATCH 00/19] QEMU gmem implemention Xiaoyao Li
2023-07-31 16:21 ` [RFC PATCH 01/19] trace/kvm: Split address space and slot id in trace_kvm_set_user_memory() Xiaoyao Li
2023-07-31 16:21 ` [RFC PATCH 02/19] *** HACK *** linux-headers: Update headers to pull in gmem APIs Xiaoyao Li
2023-07-31 16:21 ` [RFC PATCH 03/19] RAMBlock: Support KVM gmemory Xiaoyao Li
2023-08-01 16:33 ` David Hildenbrand
2023-07-31 16:21 ` [RFC PATCH 04/19] memory: Introduce memory_region_can_be_private() Xiaoyao Li
2023-07-31 21:23 ` Peter Xu
2023-07-31 21:33 ` Michael S. Tsirkin
2023-07-31 21:34 ` Sean Christopherson
2023-07-31 21:36 ` Michael S. Tsirkin
2023-08-01 0:21 ` Peter Xu
2023-08-01 16:23 ` Sean Christopherson
2023-08-01 16:48 ` Claudio Fontana
2023-08-01 16:52 ` Claudio Fontana
2023-08-02 8:05 ` Xiaoyao Li
2023-07-31 16:21 ` [RFC PATCH 05/19] kvm: Enable KVM_SET_USER_MEMORY_REGION2 for memslot Xiaoyao Li
2023-08-01 17:10 ` Claudio Fontana
2023-08-03 8:43 ` Xiaoyao Li
2023-07-31 16:21 ` [RFC PATCH 06/19] i386/pc: Drop pc_machine_kvm_type() Xiaoyao Li
2023-08-02 23:00 ` Isaku Yamahata
2023-07-31 16:21 ` [RFC PATCH 07/19] target/i386: Implement mc->kvm_type() to get VM type Xiaoyao Li
2023-07-31 16:21 ` [RFC PATCH 08/19] HostMem: Add private property to indicate to use kvm gmem Xiaoyao Li
2023-07-31 17:22 ` Markus Armbruster
2023-08-01 14:54 ` Xiaoyao Li
2023-08-01 14:57 ` Daniel P. Berrangé
2023-08-02 8:04 ` Xiaoyao Li
2023-08-01 17:21 ` David Hildenbrand
2023-08-02 8:03 ` Xiaoyao Li
2023-08-02 14:14 ` David Hildenbrand [this message]
2023-08-02 22:53 ` Isaku Yamahata
2023-08-03 13:05 ` David Hildenbrand
2023-07-31 16:21 ` [RFC PATCH 09/19] i386/kvm: Create gmem fd for KVM_X86_SW_PROTECTED_VM Xiaoyao Li
2023-07-31 16:21 ` [RFC PATCH 10/19] kvm: Introduce support for memory_attributes Xiaoyao Li
2023-07-31 16:21 ` [RFC PATCH 11/19] kvm/memory: Introduce the infrastructure to set the default shared/private value Xiaoyao Li
2023-07-31 16:21 ` [RFC PATCH 12/19] i386/kvm: Set memory to default private for KVM_X86_SW_PROTECTED_VM Xiaoyao Li
2023-07-31 16:21 ` [RFC PATCH 13/19] physmem: replace function name with __func__ in ram_block_discard_range() Xiaoyao Li
2023-07-31 16:21 ` [RFC PATCH 14/19] physmem: Add ram_block_convert_range Xiaoyao Li
2023-07-31 16:21 ` [RFC PATCH 15/19] kvm: handle KVM_EXIT_MEMORY_FAULT Xiaoyao Li
2023-08-02 22:25 ` Isaku Yamahata
2023-09-13 6:59 ` Xiaoyao Li
2023-08-09 15:02 ` Xu Yilun
2023-09-13 7:00 ` Xiaoyao Li
2023-07-31 16:21 ` [RFC PATCH 16/19] trace/kvm: Add trace for page convertion between shared and private Xiaoyao Li
2023-07-31 16:21 ` [RFC PATCH 17/19] pci-host/q35: Move PAM initialization above SMRAM initialization Xiaoyao Li
2023-07-31 16:22 ` [RFC PATCH 18/19] q35: Introduce smm_ranges property for q35-pci-host Xiaoyao Li
2023-07-31 16:22 ` [RFC PATCH 19/19] i386: Disable SMM mode for X86_SW_PROTECTED_VM Xiaoyao Li
2023-08-02 22:27 ` Isaku Yamahata
2023-07-31 16:51 ` [RFC PATCH 00/19] QEMU gmem implemention Daniel P. Berrangé
2023-08-01 1:45 ` Xiaoyao Li
2023-08-10 15:58 ` Michael Roth via
2023-08-14 21:45 ` Isaku Yamahata
2023-07-31 17:10 ` Isaku Yamahata
2023-08-01 1:55 ` Xiaoyao Li
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=a154c33d-b24d-b713-0dc0-027d54f2340f@redhat.com \
--to=david@redhat.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=chao.p.peng@linux.intel.com \
--cc=eblake@redhat.com \
--cc=imammedo@redhat.com \
--cc=isaku.yamahata@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=marcel.apfelbaum@gmail.com \
--cc=michael.roth@amd.com \
--cc=mst@redhat.com \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=seanjc@google.com \
--cc=xiaoyao.li@intel.com \
/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).