-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory performance drop on the latest SNP kernel #225
Comments
I found this text in the REAMDE
I think this explains the boot time increase? But still, the latency and memory bandwidth performance drop seems too big to me |
I found the 6.8 kernel to test. This seems sane. 6.8 kernel
|
The snp-latest/snp-host-latest branches have an in-development patch to enable support for 2MB THP pages. This patch is still in development and not yet upstream in 6.11-rc1. So you're essentially comparing 4K guest performance to 2MB guest performance, which I think will explain much of the performance delta. Hopefully with 6.12 the THP support will be upstream as well. You can try applying the following patch on top of 6.11-rc1 to confirm whether or not this accounts for the differences you are seeing versus earlier versions of snp-host-latest kernel used by this repo: mdroth/linux@d641eb8 Additionally, the QEMU patches that went upstream now default to setting all guest memory private via the KVM_SET_MEMORY_ATTRIBUTES KVM ioctl. This allows optimizations for avoiding lots of KVM_SET_MEMORY_ATTRIBUTES calls during guest run-time. The downside is that initializing that data structure that tracks the state of all those pages will take a long time for a larger guest. This has already been discussed with maintainers and we have plans on optimizing that data structure to reduce the guest startup time for these cases. It's less clear when this optimization will be implemented since it potentially overlaps with other developments, but that's also tentatively aimed at 6.12. It's great to have some analysis of the upstream code, but for the above reasons we'd recommend sticking with snp-host-latest branch for any sort of performance comparisons until these other bits are upstream. |
I forgot to mention with that THP patch applied, guests will still default to 4K as they would with current upstream. To enable THP you need to set a KVM module parameter beforehand:
This is mainly to allow for easier performance comparisons and testing while the support is still in-development. In the future that module parameter will likely no longer be needed. |
@mdroth
Could you point me to the discussion thread if you know? I was wondering what is the reason behind of the design.
btw, just to make sure, I observe this performance issue on the current snp-latest (6.9.0-rc7) but not for the previous 6.8. |
Even with current 6.9-based snp-host-latest, you still need to explicitly enable 2MB hugepage support:
This was done so it matches upstream behavior by default, but can still have THP enabled as an experimental performance option. Most of the original discussion behind temporarily-backing out the THP support happened in this thread: https://lore.kernel.org/kvm/[email protected]/#r The THP patch I mentioned (mdroth/linux@d641eb8) addresses some of the issues brought up in that discussion. I'm not aware of any other discussions around THP other than ones we've had during the weekly PUCK (Periodic Upstream Call for KVM) call with the KVM maintainers. The KVM maintainers are aware of the approach we are taking in that patch, and that we will be pushing to get something similar upstream. |
I applied the patch (https://github.com/mdroth/linux/commit/d641eb88f61b57fe9a4522ea8eb1865fcb727d6e.patch) to the current kvm-next (332d2c1d7), and enabled Now I get a similar performance as the previous.
Enabling gmem_2m_enabled also seems to reduce the boottime. |
Hi @mdroth Thank you very much for the pointer to the thread. This is really useful.
Do you also know a discussion thread regarding this? Also, I was wondering how much having many KVM_SET_MEMORY_ATTRIBUTES calls affects the performance during runtime. |
QEMU/OVMF update for 6.9 kernel Note that the host kernel should enable `/sys/module/kvm/parameters/gmem_2m_enabled`, otherwise see the performance drop: AMDESE/AMDSEV#225
I found that the latest kernel (or OVMF?) has some performance issues compared to the 6.6 kernel. For example, on a SNP guest, (1) Intel MLC reports ~40ns longer latency, and (2) RamSpeed (Integer add) only shows 64% performance compared to the previous. A normal VM does not have this issue.
I use the same guest (Linux 6.8) for the test and a VM has 8vCPU, 64GB memory. I also find that the latest host kernel and qemu version take much more time to boot a SNP guest, especially preallocation case. I'm not sure that is related to the issue.
6.10-rc7 (kvm-next commit 332d2c1d7)
I use the current snp-latest branch of qemu and ovmf.
I also see a similar performance on the 6.9 kernel (the current snp-host-latest). I could not find the 6.8 kernel to test.
6.6 kernel
Environment
The text was updated successfully, but these errors were encountered: