Hi,
I’m a total newbie to on this forum, so please have mercy.
This is not a driver question, but it is a windows INTERNALS question, so I’m hoping you guys can help me.
I have a 64-bit windows server 2003 system with 8 AMD cpus and 16 gig of RAM. I want to use about 5 gig of RAM for my own evil purposes. To that end I have created 3 shared regions. (memory-mapped files backed by the system page file) 2 of them are 1 gig and one of them is 3 gig in size. This may seem extreme, but if I’ve got 16 gig of RAM, I’m going to make use of it.
I have one application which creates the 3 shared regions and “holds them open”. It is a simple service that does nothing but create the regions and wait to be shut down. It seems to start up and create the regions with no problem. (It starts very quickly, calls SetProcessWorkingSetSize to increase it’s WS to about 6 gig, and calls VirtualLock to lock the region pages in memory). This all happens in a couple of seconds.
Next, I start up my primary application. It has total success in opening the shared regions. I set it’s working set size to about 6 gig to encompass all of the regions, it’s own memory usage, etc. When I attempt to lock the first region (one gig in size) the application freezes. It takes about five minutes (yes, five MINUTES) to lock these pages in memory. When I try to lock the next one gig region, it takes even longer… ten to fifteen minutes. I don’t know how long it would take to lock the 3 gig region, because I don’t have that kind of patience. This is obviously not acceptable behaviour.
What in the world is going on here? I come from 15 years in a VMS background, so go ahead and tell me all about page table entries, page faults, working set sizes and the like…I understand the concepts.
Why is the second process suffering so much when attempting to lock down the pages? Task manager does not show that the process is page faulting. Indeed, it’s physical memory usage grows almost instantaneously. But it just sits there and it is burning a respectable amount of CPU within the VirtualLock routine. AMDs CodeAnalyst shows me inside of ntoskrnl.exe at miLocateWsle very often…what is this? Locate working set locked entry? Just a guess.
Since these are shared memory sections and I’m locking them into physical memory, I assumed that, no matter how many processes mapped these regions, no additional memory would be used up (except for overhead like PTEs and such). Is this an incorrect assumption?
What is the best solution to this problem? Should my first application NOT lock the pages, or perhaps should it be the only one to do so? I want to run a third application to map these regions and work with them as well…what is the best configuration to set up for something like this? Is there a way to “steal” memory from Windows and keep it non-paged? Can it then be shared? That would be ideal.
My “third” application zeros the 3 gig region with memset. This takes an eternity as well. Here is stack for that thread from process explorer:
ntoskrnl.exe!ExAcquireSharedWaitForExclusive+0x115
ntoskrnl.exe!ExAcquireSharedWaitForExclusive+0x545
ntoskrnl.exe!MmProbeAndLockPages+0x5ce
ntoskrnl.exe!KeSynchronizeExecution+0x41c
ntoskrnl.exe!ExfReleasePushLock+0x1f
ntoskrnl.exe!ExfReleasePushLock+0x112
ntoskrnl.exe!KeStackAttachProcess+0x23a
ntoskrnl.exe!NtClose+0x61b
ntoskrnl.exe!PsReturnProcessNonPagedPoolQuota+0x4fd
ntdll.dll+0x315aa
kernel32.dll+0x30596
System is set up for best performance for background services, memory usage is set up for best performance of programs (not system cache) and the page file is being managed by windows itself (system managed size). It is sitting at about 16 gig in size at the moment. Should I configure the system with no page file? I haven’t tried that yet.
Any help whatsoever would be massively appreciated. I’m obviously missing something crucial.
Regards,
Greg