Closed pizhenwei closed 7 years ago
Linux kernel has different RSS counting for zero or non-zero pages, uksm does not break this protocol. ksm.c currently does not have special consideration for zero pages (patches maybe on the way though).
@naixia Linux kernel has different RSS counting for zero or non-zero pages, uksm does not break this protocol. -->BUT, this protocol should be invisible to process. Linux process does't care zore page or not, but really care how much RES usage is in using. 500M pte which point to single none-zero page counts 2G RES usage, but 500M pte which point to single zero page counts 0 RES usage. Orz
@pacepi Please stop spamming this issue. This is really how linux kernel count ptes to VmRSS. You can do more experiments on systems without uksm and see this "buggy behaviour" (from your point of view) in vanilla kernel. e.g. forked() COW shared ptes to non-zero pages.
Linux kernel counts every pte pointing to a non-zero page as RSS no matter if this pte is shared with others or not. If you dont feel comfortable about this. Please goto kernel linux-mm mail list and ask there.
This is NOT a bug, but a logic. You may have many other ways to count your memory usage of your QEMUs. Please stop.
@naixia @dolohow Hi, sirs
I have run a simple test, and i think it may be a problem~ 1, setup host with qemu-kvm and uksm 2, run a clean guest-os(ubuntu1404, 64bit), and qemu uses almost 1G RES memory monitored by top. 3, in guest-os, run a demo process which allocates 2G memory and sets 0xc5. qemu uses almost 3G RES memory. 4, in guest-os, run a demo process which allocates 2G memory and sets 0x00. qemu uses almost 1G RES memory. Although uksm uses different ways to process zero page and none-zero page, should we get the same RES memory usage? I tried to mark "dec_mm_counter(slot->mm, MM_ANONPAGES);" in uksm.c , and got the same RES usage. And I run the same test on upstream KSM, I got a result that both condition 3 and 4 has a same RES memory usage. Waiting for your response~