A stub for bug 45667 has been sitting in staging for a while. It is sufficient for League of Legends, but it is not correct by any definition.
The challenge with MemoryWorkingSetExInformation is that it requires information that is not exposed by the Linux kernel. One option was to allocate valloc memory with PROT_NONE, then handle the faults in virtual_handle_fault and keep our own statistics. This implies a SIGSEGV signal for *every* VirtualAlloc page, which sounded slow.
This patchset implements an optimized version of this by using /proc/pid/pagemap to handle demand-zero pages, which would have been the most common complicated case. The remaining complicated cases (e.g. VirtualProtect from PAGE_NOACCESS to PAGE_READONLY, ...) are handled by deferring changing the page protection until virtual_handle_fault.
It is possible that this patchset will introduce a performance regression if an application heavily uses PAGE_NOACCESS or PAGE_GUARD protections. Also, this patch reverts to the staging stub's behavior if pagemaps is not available.
If someone has an alternative approach, or there is appetite using the staging stub in upstream Wine, that would be very welcome feedback.
Andrew Wesie (3): ntdll: Implement NtQueryVirtualMemory(MemoryWorkingSetExInformation). kernel32: QueryWorkingSetEx should use MemoryWorkingSetExInformation. psapi/tests: Test QueryWorkingSetEx.
dlls/kernel32/process.c | 2 +- dlls/ntdll/virtual.c | 78 +++++++++++++++++++++++++++++--- dlls/psapi/tests/psapi_main.c | 84 +++++++++++++++++++++++++++++++++++ include/psapi.h | 18 ++++++++ include/winternl.h | 21 ++++++++- 5 files changed, 196 insertions(+), 7 deletions(-)