From: Ram Pai <linuxram@us.ibm.com> To: kvm-ppc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Cc: ldufour@linux.ibm.com, linuxram@us.ibm.com, cclaudio@linux.ibm.com, bharata@linux.ibm.com, sathnaga@linux.vnet.ibm.com, aneesh.kumar@linux.ibm.com, sukadev@linux.vnet.ibm.com, bauerman@linux.ibm.com, david@gibson.dropbear.id.au Subject: [PATCH v5 0/7] Migrate non-migrated pages of a SVM. Date: Thu, 23 Jul 2020 13:07:17 -0700 [thread overview] Message-ID: <1595534844-16188-1-git-send-email-linuxram@us.ibm.com> (raw) The time to switch a VM to Secure-VM, increases by the size of the VM. A 100GB VM takes about 7minutes. This is unacceptable. This linear increase is caused by a suboptimal behavior by the Ultravisor and the Hypervisor. The Ultravisor unnecessarily migrates all the GFN of the VM from normal-memory to secure-memory. It has to just migrate the necessary and sufficient GFNs. However when the optimization is incorporated in the Ultravisor, the Hypervisor starts misbehaving. The Hypervisor has a inbuilt assumption that the Ultravisor will explicitly request to migrate, each and every GFN of the VM. If only necessary and sufficient GFNs are requested for migration, the Hypervisor continues to manage the remaining GFNs as normal GFNs. This leads to memory corruption; manifested consistently when the SVM reboots. The same is true, when a memory slot is hotplugged into a SVM. The Hypervisor expects the ultravisor to request migration of all GFNs to secure-GFN. But the hypervisor cannot handle any H_SVM_PAGE_IN requests from the Ultravisor, done in the context of UV_REGISTER_MEM_SLOT ucall. This problem manifests as random errors in the SVM, when a memory-slot is hotplugged. This patch series automatically migrates the non-migrated pages of a SVM, and thus solves the problem. Testing: Passed rigorous testing using various sized SVMs. Changelog: v5: . This patch series includes Laurent's fix for memory hotplug/unplug . drop pages first and then delete the memslot. Otherwise the memslot does not get cleanly deleted, causing problems during reboot. . recreatable through the following set of commands . device_add pc-dimm,id=dimm1,memdev=mem1 . device_del dimm1 . device_add pc-dimm,id=dimm1,memdev=mem1 Further incorporates comments from Bharata: . fix for off-by-one while disabling migration. . code-reorganized to maximize sharing in init_start path and in memory-hotplug path . locking adjustments in mass-page migration during H_SVM_INIT_DONE. . improved recovery on error paths. . additional comments in the code for better understanding. . removed the retry-on-migration-failure code. . re-added the initial patch that adjust some prototype to overcome a git problem, where it messes up the code context. Had accidently dropped the patch in the last version. v4: . Incorported Bharata's comments: - Optimization -- replace write mmap semaphore with read mmap semphore. - disable page-merge during memory hotplug. - rearranged the patches. consolidated the page-migration-retry logic in a single patch. v3: . Optimized the page-migration retry-logic. . Relax and relinquish the cpu regularly while bulk migrating the non-migrated pages. This issue was causing soft-lockups. Fixed it. . Added a new patch, to retry page-migration a couple of times before returning H_BUSY in H_SVM_PAGE_IN. This issue was seen a few times in a 24hour continuous reboot test of the SVMs. v2: . fixed a bug observed by Laurent. The state of the GFN's associated with Secure-VMs were not reset during memslot flush. . Re-organized the code, for easier review. . Better description of the patch series. v1: . fixed a bug observed by Bharata. Pages that where paged-in and later paged-out must also be skipped from migration during H_SVM_INIT_DONE. Laurent Dufour (3): KVM: PPC: Book3S HV: migrate hot plugged memory KVM: PPC: Book3S HV: move kvmppc_svm_page_out up KVM: PPC: Book3S HV: rework secure mem slot dropping Ram Pai (4): KVM: PPC: Book3S HV: Fix function definition in book3s_hv_uvmem.c KVM: PPC: Book3S HV: Disable page merging in H_SVM_INIT_START KVM: PPC: Book3S HV: track the state GFNs associated with secure VMs KVM: PPC: Book3S HV: in H_SVM_INIT_DONE, migrate remaining normal-GFNs to secure-GFNs. Documentation/powerpc/ultravisor.rst | 3 + arch/powerpc/include/asm/kvm_book3s_uvmem.h | 16 + arch/powerpc/kvm/book3s_hv.c | 10 +- arch/powerpc/kvm/book3s_hv_uvmem.c | 690 +++++++++++++++++++++------- 4 files changed, 548 insertions(+), 171 deletions(-) -- 1.8.3.1
WARNING: multiple messages have this Message-ID (diff)
From: Ram Pai <linuxram@us.ibm.com> To: kvm-ppc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Cc: ldufour@linux.ibm.com, linuxram@us.ibm.com, cclaudio@linux.ibm.com, bharata@linux.ibm.com, sathnaga@linux.vnet.ibm.com, aneesh.kumar@linux.ibm.com, sukadev@linux.vnet.ibm.com, bauerman@linux.ibm.com, david@gibson.dropbear.id.au Subject: [PATCH v5 0/7] Migrate non-migrated pages of a SVM. Date: Thu, 23 Jul 2020 20:07:17 +0000 [thread overview] Message-ID: <1595534844-16188-1-git-send-email-linuxram@us.ibm.com> (raw) The time to switch a VM to Secure-VM, increases by the size of the VM. A 100GB VM takes about 7minutes. This is unacceptable. This linear increase is caused by a suboptimal behavior by the Ultravisor and the Hypervisor. The Ultravisor unnecessarily migrates all the GFN of the VM from normal-memory to secure-memory. It has to just migrate the necessary and sufficient GFNs. However when the optimization is incorporated in the Ultravisor, the Hypervisor starts misbehaving. The Hypervisor has a inbuilt assumption that the Ultravisor will explicitly request to migrate, each and every GFN of the VM. If only necessary and sufficient GFNs are requested for migration, the Hypervisor continues to manage the remaining GFNs as normal GFNs. This leads to memory corruption; manifested consistently when the SVM reboots. The same is true, when a memory slot is hotplugged into a SVM. The Hypervisor expects the ultravisor to request migration of all GFNs to secure-GFN. But the hypervisor cannot handle any H_SVM_PAGE_IN requests from the Ultravisor, done in the context of UV_REGISTER_MEM_SLOT ucall. This problem manifests as random errors in the SVM, when a memory-slot is hotplugged. This patch series automatically migrates the non-migrated pages of a SVM, and thus solves the problem. Testing: Passed rigorous testing using various sized SVMs. Changelog: v5: . This patch series includes Laurent's fix for memory hotplug/unplug . drop pages first and then delete the memslot. Otherwise the memslot does not get cleanly deleted, causing problems during reboot. . recreatable through the following set of commands . device_add pc-dimm,id=dimm1,memdev=mem1 . device_del dimm1 . device_add pc-dimm,id=dimm1,memdev=mem1 Further incorporates comments from Bharata: . fix for off-by-one while disabling migration. . code-reorganized to maximize sharing in init_start path and in memory-hotplug path . locking adjustments in mass-page migration during H_SVM_INIT_DONE. . improved recovery on error paths. . additional comments in the code for better understanding. . removed the retry-on-migration-failure code. . re-added the initial patch that adjust some prototype to overcome a git problem, where it messes up the code context. Had accidently dropped the patch in the last version. v4: . Incorported Bharata's comments: - Optimization -- replace write mmap semaphore with read mmap semphore. - disable page-merge during memory hotplug. - rearranged the patches. consolidated the page-migration-retry logic in a single patch. v3: . Optimized the page-migration retry-logic. . Relax and relinquish the cpu regularly while bulk migrating the non-migrated pages. This issue was causing soft-lockups. Fixed it. . Added a new patch, to retry page-migration a couple of times before returning H_BUSY in H_SVM_PAGE_IN. This issue was seen a few times in a 24hour continuous reboot test of the SVMs. v2: . fixed a bug observed by Laurent. The state of the GFN's associated with Secure-VMs were not reset during memslot flush. . Re-organized the code, for easier review. . Better description of the patch series. v1: . fixed a bug observed by Bharata. Pages that where paged-in and later paged-out must also be skipped from migration during H_SVM_INIT_DONE. Laurent Dufour (3): KVM: PPC: Book3S HV: migrate hot plugged memory KVM: PPC: Book3S HV: move kvmppc_svm_page_out up KVM: PPC: Book3S HV: rework secure mem slot dropping Ram Pai (4): KVM: PPC: Book3S HV: Fix function definition in book3s_hv_uvmem.c KVM: PPC: Book3S HV: Disable page merging in H_SVM_INIT_START KVM: PPC: Book3S HV: track the state GFNs associated with secure VMs KVM: PPC: Book3S HV: in H_SVM_INIT_DONE, migrate remaining normal-GFNs to secure-GFNs. Documentation/powerpc/ultravisor.rst | 3 + arch/powerpc/include/asm/kvm_book3s_uvmem.h | 16 + arch/powerpc/kvm/book3s_hv.c | 10 +- arch/powerpc/kvm/book3s_hv_uvmem.c | 690 +++++++++++++++++++++------- 4 files changed, 548 insertions(+), 171 deletions(-) -- 1.8.3.1
next reply other threads:[~2020-07-23 20:10 UTC|newest] Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-07-23 20:07 Ram Pai [this message] 2020-07-23 20:07 ` [PATCH v5 0/7] Migrate non-migrated pages of a SVM Ram Pai 2020-07-23 20:07 ` [PATCH v5 1/7] KVM: PPC: Book3S HV: Fix function definition in book3s_hv_uvmem.c Ram Pai 2020-07-23 20:07 ` Ram Pai 2020-07-23 20:07 ` [PATCH v5 2/7] KVM: PPC: Book3S HV: Disable page merging in H_SVM_INIT_START Ram Pai 2020-07-23 20:07 ` Ram Pai 2020-07-23 20:07 ` [PATCH v5 3/7] KVM: PPC: Book3S HV: track the state GFNs associated with secure VMs Ram Pai 2020-07-23 20:07 ` Ram Pai 2020-07-23 20:07 ` [PATCH v5 4/7] KVM: PPC: Book3S HV: in H_SVM_INIT_DONE, migrate remaining normal-GFNs to secure-GFNs Ram Pai 2020-07-23 20:07 ` Ram Pai 2020-07-24 4:27 ` Bharata B Rao 2020-07-24 4:39 ` [PATCH v5 4/7] KVM: PPC: Book3S HV: in H_SVM_INIT_DONE, migrate remaining normal-GFNs to secure- Bharata B Rao 2020-07-23 20:07 ` [PATCH v5 5/7] KVM: PPC: Book3S HV: migrate hot plugged memory Ram Pai 2020-07-23 20:07 ` Ram Pai 2020-07-27 3:55 ` Bharata B Rao 2020-07-27 3:55 ` Bharata B Rao 2020-07-23 20:07 ` [PATCH v5 6/7] KVM: PPC: Book3S HV: move kvmppc_svm_page_out up Ram Pai 2020-07-23 20:07 ` Ram Pai 2020-07-27 3:49 ` Bharata B Rao 2020-07-27 3:50 ` Bharata B Rao 2020-07-23 20:07 ` [PATCH v5 7/7] KVM: PPC: Book3S HV: rework secure mem slot dropping Ram Pai 2020-07-23 20:07 ` Ram Pai 2020-07-24 3:03 ` Bharata B Rao 2020-07-24 3:15 ` Bharata B Rao 2020-07-24 7:43 ` Laurent Dufour 2020-07-24 7:43 ` Laurent Dufour 2020-07-24 8:35 ` [PATCH] " Laurent Dufour 2020-07-24 8:35 ` Laurent Dufour 2020-07-27 3:49 ` Bharata B Rao 2020-07-27 3:49 ` Bharata B Rao
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=1595534844-16188-1-git-send-email-linuxram@us.ibm.com \ --to=linuxram@us.ibm.com \ --cc=aneesh.kumar@linux.ibm.com \ --cc=bauerman@linux.ibm.com \ --cc=bharata@linux.ibm.com \ --cc=cclaudio@linux.ibm.com \ --cc=david@gibson.dropbear.id.au \ --cc=kvm-ppc@vger.kernel.org \ --cc=ldufour@linux.ibm.com \ --cc=linuxppc-dev@lists.ozlabs.org \ --cc=sathnaga@linux.vnet.ibm.com \ --cc=sukadev@linux.vnet.ibm.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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.