Skip to content
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

Is there any way to temporarily hang zero-page thread in windows When Deflate balloon? #1160

Closed
yangni2017 opened this issue Sep 29, 2024 · 9 comments

Comments

@yangni2017
Copy link

Hi~ Recently I wanted to reclaim windows memory through virtio balloon.When Deflate balloon, i want to emporarily hang zero-page thread to avoid writing memory to zero, if Deflate over, zero-page thread need recovery.Is there any better way?

Whether this method can solve the problem that the memory usage of the host and virtual machine is inconsistent, i want to test it,but i have not idea to hang zero-page thread.

@YanVugenfirer
Copy link
Collaborator

@yangni2017 please don’ download or use unidentified binaries!!!

@virtio-win virtio-win deleted a comment Sep 29, 2024
@virtio-win virtio-win deleted a comment from yangni2017 Sep 29, 2024
@yangni2017
Copy link
Author

@yangni2017 please don’ download or use unidentified binaries!!!

thank you remind me. Doesn't seem to have any way to disable or hang zero-page thread. So is there any way to avoid to the memory be set to zero after Deflate the balloon?Whether the flag can be set when Deflate the balloon?

@YanVugenfirer
Copy link
Collaborator

I am not sure what it will achieve. Can you please explain?

On the contrary - if you want to use more advance memory over commit and not just a ballon, that will hurt KSM work https://en.wikipedia.org/wiki/Kernel_same-page_merging

@yangni2017
Copy link
Author

yangni2017 commented Sep 30, 2024

I am not sure what it will achieve. Can you please explain?

On the contrary - if you want to use more advance memory over commit and not just a ballon, that will hurt KSM work https://en.wikipedia.org/wiki/Kernel_same-page_merging

I am trying to release memory by Deflate balloon. If do not set 0, maybe can let the host see this release of memory. Just like linux, the memory used by the virtual machine is consistent with the qemu rss that the host sees at the top.
It was discussed by this issue: issue-556

@YanVugenfirer
Copy link
Collaborator

I am sorry - I don't understand why it matters.

So Linux is misreporting the memory used by the guest (deflated memory belongs to the guest, even if the guest does not use it. It is not a "free" memory of the host in any way).

Why do you want to emulate Linux's bad behavior?

Again - the moment you deflated the ballon, this is a FREE memory of the GUEST, but it is USED memory of the HOST.
If you want it to be free memory on the host, you need to use KSM.

@yangni2017
Copy link
Author

I am sorry - I don't understand why it matters.

So Linux is misreporting the memory used by the guest (deflated memory belongs to the guest, even if the guest does not use it. It is not a "free" memory of the host in any way).

Why do you want to emulate Linux's bad behavior?

Again - the moment you deflated the ballon, this is a FREE memory of the GUEST, but it is USED memory of the HOST. If you want it to be free memory on the host, you need to use KSM.

thanks. but I don't think it's a bad behavior.Because it can reclaim some not import vm's memory quickly when the host memory is tight,i thinck the ksm efficiency is relatively low.

@YanVugenfirer
Copy link
Collaborator

What will happen when any process on Windows will use the memory?

@yangni2017
Copy link
Author

yangni2017 commented Sep 30, 2024

What will happen when any process on Windows will use the memory?

i think this part of memory is only not set to zero,not indicates that the memory does not belong to the VM.If process need to use it can use it. for example, If we hibernate the vm of windows, after vm resume , the memory will be reorganized(Free memory is not be set to zero), then it can get the same behavior, process on Windows also can use the memory. So if we can let the zero-page thread to not set zero of the memory we deflated from balloon , I think we can achieve the same effect of linux.

@vrozenfe
Copy link
Collaborator

vrozenfe commented Oct 2, 2024

@yangni2017
Out of curiosity, even if it was technically possible, what is the point in disabling zero-page thread. Some sort of memory scan application to read and analyse host and other VMs previously owned memory?

Best,
Vadim.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants