From: Chenyi Qiang <chenyi.qiang@intel.com>
To: "Paolo Bonzini" <pbonzini@redhat.com>,
"David Hildenbrand" <david@redhat.com>,
"Peter Xu" <peterx@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Michael Roth" <michael.roth@amd.com>
Cc: Chenyi Qiang <chenyi.qiang@intel.com>,
qemu-devel@nongnu.org, kvm@vger.kernel.org,
Williams Dan J <dan.j.williams@intel.com>,
Edgecombe Rick P <rick.p.edgecombe@intel.com>,
Wang Wei W <wei.w.wang@intel.com>,
Peng Chao P <chao.p.peng@intel.com>,
Gao Chao <chao.gao@intel.com>, Wu Hao <hao.wu@intel.com>,
Xu Yilun <yilun.xu@intel.com>
Subject: [RFC PATCH 3/6] KVM: Notify the state change via RamDiscardManager helper during shared/private conversion
Date: Thu, 25 Jul 2024 03:21:12 -0400 [thread overview]
Message-ID: <20240725072118.358923-4-chenyi.qiang@intel.com> (raw)
In-Reply-To: <20240725072118.358923-1-chenyi.qiang@intel.com>
Once exit to userspace to convert the page from private to shared or
vice versa at runtime, notify the state change via the
guest_memfd_state_change() helper so that other registered subsystems
like VFIO can be notified.
Signed-off-by: Chenyi Qiang <chenyi.qiang@intel.com>
---
accel/kvm/kvm-all.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 854cb86b22..94bbbbd2de 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -48,6 +48,7 @@
#include "kvm-cpus.h"
#include "sysemu/dirtylimit.h"
#include "qemu/range.h"
+#include "sysemu/guest-memfd-manager.h"
#include "hw/boards.h"
#include "sysemu/stats.h"
@@ -2852,6 +2853,7 @@ int kvm_convert_memory(hwaddr start, hwaddr size, bool to_private)
RAMBlock *rb;
void *addr;
int ret = -1;
+ GuestMemfdManager *gmm;
trace_kvm_convert_memory(start, size, to_private ? "shared_to_private" : "private_to_shared");
@@ -2914,6 +2916,11 @@ int kvm_convert_memory(hwaddr start, hwaddr size, bool to_private)
addr = memory_region_get_ram_ptr(mr) + section.offset_within_region;
rb = qemu_ram_block_from_host(addr, false, &offset);
+ gmm = GUEST_MEMFD_MANAGER(mr->rdm);
+ if (gmm) {
+ guest_memfd_state_change(gmm, offset, size, to_private);
+ }
+
if (to_private) {
if (rb->page_size != qemu_real_host_page_size()) {
/*
--
2.43.5
next prev parent reply other threads:[~2024-07-25 7:24 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-25 7:21 [RFC PATCH 0/6] Enable shared device assignment Chenyi Qiang
2024-07-25 7:21 ` [RFC PATCH 1/6] guest_memfd: Introduce an object to manage the guest-memfd with RamDiscardManager Chenyi Qiang
2024-07-25 7:21 ` [RFC PATCH 2/6] guest_memfd: Introduce a helper to notify the shared/private state change Chenyi Qiang
2024-07-25 7:21 ` Chenyi Qiang [this message]
2024-07-25 7:21 ` [RFC PATCH 4/6] memory: Register the RamDiscardManager instance upon guest_memfd creation Chenyi Qiang
2024-07-25 7:21 ` [RFC PATCH 5/6] guest-memfd: Default to discarded (private) in guest_memfd_manager Chenyi Qiang
2024-07-25 7:21 ` [RFC PATCH 6/6] RAMBlock: make guest_memfd require coordinate discard Chenyi Qiang
2024-07-25 14:04 ` [RFC PATCH 0/6] Enable shared device assignment David Hildenbrand
2024-07-26 5:02 ` Tian, Kevin
2024-07-26 7:08 ` David Hildenbrand
2024-07-31 7:12 ` Xu Yilun
2024-07-31 11:05 ` David Hildenbrand
2024-07-26 6:20 ` Chenyi Qiang
2024-07-26 7:20 ` David Hildenbrand
2024-07-26 10:56 ` Chenyi Qiang
2024-07-31 11:18 ` David Hildenbrand
2024-08-02 7:00 ` Chenyi Qiang
2024-08-01 7:32 ` Yin, Fengwei
2024-08-16 3:02 ` Chenyi Qiang
2024-10-08 8:59 ` Chenyi Qiang
2024-11-15 16:47 ` Rob Nertney
2024-11-15 17:20 ` 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=20240725072118.358923-4-chenyi.qiang@intel.com \
--to=chenyi.qiang@intel.com \
--cc=chao.gao@intel.com \
--cc=chao.p.peng@intel.com \
--cc=dan.j.williams@intel.com \
--cc=david@redhat.com \
--cc=hao.wu@intel.com \
--cc=kvm@vger.kernel.org \
--cc=michael.roth@amd.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=rick.p.edgecombe@intel.com \
--cc=wei.w.wang@intel.com \
--cc=yilun.xu@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).