ReactOS  0.4.13-dev-241-g63286c6
balance.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS kernel
4  * FILE: ntoskrnl/mm/balance.c
5  * PURPOSE: kernel memory managment functions
6  *
7  * PROGRAMMERS: David Welch (welch@cwcom.net)
8  * Cameron Gutman (cameron.gutman@reactos.org)
9  */
10 
11 /* INCLUDES *****************************************************************/
12 
13 #include <ntoskrnl.h>
14 #define NDEBUG
15 #include <debug.h>
16 
17 #include "ARM3/miarm.h"
18 
19 #if defined (ALLOC_PRAGMA)
20 #pragma alloc_text(INIT, MmInitializeBalancer)
21 #pragma alloc_text(INIT, MmInitializeMemoryConsumer)
22 #pragma alloc_text(INIT, MiInitBalancerThread)
23 #endif
24 
25 
26 /* TYPES ********************************************************************/
27 typedef struct _MM_ALLOCATION_REQUEST
28 {
32 }
34 /* GLOBALS ******************************************************************/
35 
42 
47 
48 /* FUNCTIONS ****************************************************************/
49 
50 VOID
51 INIT_FUNCTION
52 NTAPI
53 MmInitializeBalancer(ULONG NrAvailablePages, ULONG NrSystemPages)
54 {
58 
59  MiNrTotalPages = NrAvailablePages;
60 
61  /* Set up targets. */
64  if ((NrAvailablePages + NrSystemPages) >= 8192)
65  {
66  MiMemoryConsumers[MC_CACHE].PagesTarget = NrAvailablePages / 4 * 3;
67  }
68  else if ((NrAvailablePages + NrSystemPages) >= 4096)
69  {
70  MiMemoryConsumers[MC_CACHE].PagesTarget = NrAvailablePages / 3 * 2;
71  }
72  else
73  {
74  MiMemoryConsumers[MC_CACHE].PagesTarget = NrAvailablePages / 8;
75  }
77 }
78 
79 VOID
80 INIT_FUNCTION
81 NTAPI
83  ULONG Consumer,
84  NTSTATUS (*Trim)(ULONG Target, ULONG Priority, PULONG NrFreed))
85 {
86  MiMemoryConsumers[Consumer].Trim = Trim;
87 }
88 
89 VOID
90 NTAPI
92  IN PFN_NUMBER PageFrameIndex
93 );
94 
96 NTAPI
98 {
99  if (Page == 0)
100  {
101  DPRINT1("Tried to release page zero.\n");
102  KeBugCheck(MEMORY_MANAGEMENT);
103  }
104 
105  if (MmGetReferenceCountPage(Page) == 1)
106  {
107  if(Consumer == MC_USER) MmRemoveLRUUserPage(Page);
108  (void)InterlockedDecrementUL(&MiMemoryConsumers[Consumer].PagesUsed);
109  }
110 
111  MmDereferencePage(Page);
112 
113  return(STATUS_SUCCESS);
114 }
115 
116 ULONG
117 NTAPI
118 MiTrimMemoryConsumer(ULONG Consumer, ULONG InitialTarget)
119 {
120  ULONG Target = InitialTarget;
121  ULONG NrFreedPages = 0;
123 
124  /* Make sure we can trim this consumer */
125  if (!MiMemoryConsumers[Consumer].Trim)
126  {
127  /* Return the unmodified initial target */
128  return InitialTarget;
129  }
130 
131  if (MiMemoryConsumers[Consumer].PagesUsed > MiMemoryConsumers[Consumer].PagesTarget)
132  {
133  /* Consumer page limit exceeded */
134  Target = max(Target, MiMemoryConsumers[Consumer].PagesUsed - MiMemoryConsumers[Consumer].PagesTarget);
135  }
137  {
138  /* Global page limit exceeded */
140  }
141 
142  if (Target)
143  {
144  if (!InitialTarget)
145  {
146  /* If there was no initial target,
147  * swap at least MiMinimumPagesPerRun */
149  }
150 
151  /* Now swap the pages out */
152  Status = MiMemoryConsumers[Consumer].Trim(Target, 0, &NrFreedPages);
153 
154  DPRINT("Trimming consumer %lu: Freed %lu pages with a target of %lu pages\n", Consumer, NrFreedPages, Target);
155 
156  if (!NT_SUCCESS(Status))
157  {
158  KeBugCheck(MEMORY_MANAGEMENT);
159  }
160 
161  /* Update the target */
162  if (NrFreedPages < Target)
163  Target -= NrFreedPages;
164  else
165  Target = 0;
166 
167  /* Return the remaining pages needed to meet the target */
168  return Target;
169  }
170  else
171  {
172  /* Initial target is zero and we don't have anything else to add */
173  return 0;
174  }
175 }
176 
177 NTSTATUS
179 {
180  PFN_NUMBER CurrentPage;
183 
184  (*NrFreedPages) = 0;
185 
186  CurrentPage = MmGetLRUFirstUserPage();
187  while (CurrentPage != 0 && Target > 0)
188  {
189  Status = MmPageOutPhysicalAddress(CurrentPage);
190  if (NT_SUCCESS(Status))
191  {
192  DPRINT("Succeeded\n");
193  Target--;
194  (*NrFreedPages)++;
195  }
196 
197  NextPage = MmGetLRUNextUserPage(CurrentPage);
198  if (NextPage <= CurrentPage)
199  {
200  /* We wrapped around, so we're done */
201  break;
202  }
203  CurrentPage = NextPage;
204  }
205 
206  return STATUS_SUCCESS;
207 }
208 
209 static BOOLEAN
211 {
212  return (MiBalancerThreadHandle != NULL) &&
214 }
215 
216 VOID
217 NTAPI
219 {
220  if (MiBalancerThreadHandle != NULL &&
222  {
224  }
225 }
226 
227 NTSTATUS
228 NTAPI
230  PPFN_NUMBER AllocatedPage)
231 {
232  ULONG PagesUsed;
233  PFN_NUMBER Page;
234 
235  /*
236  * Make sure we don't exceed our individual target.
237  */
238  PagesUsed = InterlockedIncrementUL(&MiMemoryConsumers[Consumer].PagesUsed);
239  if (PagesUsed > MiMemoryConsumers[Consumer].PagesTarget &&
241  {
243  }
244 
245  /*
246  * Allocate always memory for the non paged pool and for the pager thread.
247  */
248  if ((Consumer == MC_SYSTEM) /* || MiIsBalancerThread() */)
249  {
250  Page = MmAllocPage(Consumer);
251  if (Page == 0)
252  {
253  KeBugCheck(NO_PAGES_AVAILABLE);
254  }
255  if (Consumer == MC_USER) MmInsertLRULastUserPage(Page);
256  *AllocatedPage = Page;
259  return(STATUS_SUCCESS);
260  }
261 
262  /*
263  * Make sure we don't exceed global targets.
264  */
267  {
269 
270  if (!CanWait)
271  {
272  (void)InterlockedDecrementUL(&MiMemoryConsumers[Consumer].PagesUsed);
274  return(STATUS_NO_MEMORY);
275  }
276 
277  /* Insert an allocation request. */
278  Request.Page = 0;
280 
283 
285  0,
286  KernelMode,
287  FALSE,
288  NULL);
289 
290  Page = Request.Page;
291  if (Page == 0)
292  {
293  KeBugCheck(NO_PAGES_AVAILABLE);
294  }
295 
296  if(Consumer == MC_USER) MmInsertLRULastUserPage(Page);
297  *AllocatedPage = Page;
298 
300  {
302  }
303 
304  return(STATUS_SUCCESS);
305  }
306 
307  /*
308  * Actually allocate the page.
309  */
310  Page = MmAllocPage(Consumer);
311  if (Page == 0)
312  {
313  KeBugCheck(NO_PAGES_AVAILABLE);
314  }
315  if(Consumer == MC_USER) MmInsertLRULastUserPage(Page);
316  *AllocatedPage = Page;
317 
319  {
321  }
322 
323  return(STATUS_SUCCESS);
324 }
325 
326 
327 VOID NTAPI
329 {
330  PVOID WaitObjects[2];
332  ULONG i;
333 
334  WaitObjects[0] = &MiBalancerEvent;
335  WaitObjects[1] = &MiBalancerTimer;
336 
337  while (1)
338  {
340  WaitObjects,
341  WaitAny,
342  Executive,
343  KernelMode,
344  FALSE,
345  NULL,
346  NULL);
347 
349  {
350  ULONG InitialTarget = 0;
351 
352 #if (_MI_PAGING_LEVELS == 2)
353  if (!MiIsBalancerThread())
354  {
355  /* Clean up the unused PDEs */
358 
359  /* Acquire PFN lock */
361  PMMPDE pointerPde;
364  Address += (PAGE_SIZE * PTE_COUNT))
365  {
367  {
368  pointerPde = MiAddressToPde(Address);
369  if (pointerPde->u.Hard.Valid)
370  MiDeletePte(pointerPde, MiPdeToPte(pointerPde), Process, NULL);
371  ASSERT(pointerPde->u.Hard.Valid == 0);
372  }
373  }
374  /* Release lock */
376  }
377 #endif
378  do
379  {
380  ULONG OldTarget = InitialTarget;
381 
382  /* Trim each consumer */
383  for (i = 0; i < MC_MAXIMUM; i++)
384  {
385  InitialTarget = MiTrimMemoryConsumer(i, InitialTarget);
386  }
387 
388  /* No pages left to swap! */
389  if (InitialTarget != 0 &&
390  InitialTarget == OldTarget)
391  {
392  /* Game over */
393  KeBugCheck(NO_PAGES_AVAILABLE);
394  }
395  }
396  while (InitialTarget != 0);
397  }
398  else
399  {
400  DPRINT1("KeWaitForMultipleObjects failed, status = %x\n", Status);
401  KeBugCheck(MEMORY_MANAGEMENT);
402  }
403  }
404 }
405 
407 {
410  PMMPFN Pfn1;
411 
412  /* Make sure the PFN lock is held */
414 
416  {
417  /* Dirty way to know if we were initialized. */
418  return FALSE;
419  }
420 
422  if (!Entry)
423  return FALSE;
424 
426  MiZeroPhysicalPage(Page);
427  Request->Page = Page;
428 
429  Pfn1 = MiGetPfnEntry(Page);
430  ASSERT(Pfn1->u3.e2.ReferenceCount == 0);
431  Pfn1->u3.e2.ReferenceCount = 1;
433 
434  /* This marks the PFN as a ReactOS PFN */
435  Pfn1->u4.AweAllocation = TRUE;
436 
437  /* Allocate the extra ReactOS Data and zero it out */
438  Pfn1->u1.SwapEntry = 0;
439  Pfn1->RmapListHead = NULL;
440 
442 
443  return TRUE;
444 }
445 
446 VOID
447 INIT_FUNCTION
448 NTAPI
450 {
453 #if !defined(__GNUC__)
454 
455  LARGE_INTEGER dummyJunkNeeded;
456  dummyJunkNeeded.QuadPart = -20000000; /* 2 sec */
457  ;
458 #endif
459 
460 
464 #if defined(__GNUC__)
465  (LARGE_INTEGER)(LONGLONG)-20000000LL, /* 2 sec */
466 #else
467  dummyJunkNeeded,
468 #endif
469  2000, /* 2 sec */
470  NULL);
471 
474  NULL,
475  NULL,
478  NULL);
479  if (!NT_SUCCESS(Status))
480  {
481  KeBugCheck(MEMORY_MANAGEMENT);
482  }
483 
487  &Priority,
488  sizeof(Priority));
489 
490 }
491 
492 
493 /* EOF */
VOID NTAPI MmDereferencePage(PFN_NUMBER Page)
Definition: freelist.c:537
VOID NTAPI MmRebalanceMemoryConsumers(VOID)
Definition: balance.c:218
PFN_NUMBER Page
Definition: balance.c:29
static LIST_ENTRY AllocationListHead
Definition: balance.c:39
_Must_inspect_result_ typedef _In_ PVOID Unused
Definition: iotypes.h:1128
#define IN
Definition: typedefs.h:38
#define max(a, b)
Definition: svc.c:63
#define THREAD_ALL_ACCESS
Definition: nt_native.h:1339
#define TRUE
Definition: types.h:120
#define LL
Definition: tui.h:72
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
VOID INIT_FUNCTION NTAPI MiInitBalancerThread(VOID)
Definition: balance.c:449
#define MI_ASSERT_PFN_LOCK_HELD()
Definition: mm.h:936
#define MiAddressToPde(x)
Definition: mmx86.c:20
static ULONG MiMinimumPagesPerRun
Definition: balance.c:41
struct _Entry Entry
Definition: kefuncs.h:640
VOID NTAPI MiBalancerThread(PVOID Unused)
Definition: balance.c:328
union _MMPTE::@2227 u
#define __GNUC__
Definition: _icc.h:38
#define MC_USER
Definition: mm.h:94
#define MI_LOWEST_VAD_ADDRESS
Definition: miarm.h:11
ULONG_PTR AweAllocation
Definition: mm.h:353
ULONG PagesTarget
Definition: mm.h:386
LIST_ENTRY ListEntry
Definition: balance.c:30
PLIST_ENTRY NTAPI ExInterlockedInsertTailList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:140
PMM_RMAP_ENTRY RmapListHead
Definition: mm.h:343
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN MmRosNotifyAvailablePage(PFN_NUMBER Page)
Definition: balance.c:406
struct _MM_ALLOCATION_REQUEST MM_ALLOCATION_REQUEST
_In_ KPRIORITY Priority
Definition: kefuncs.h:516
FORCEINLINE KIRQL MiAcquirePfnLock(VOID)
Definition: mm.h:901
FORCEINLINE USHORT MiQueryPageTableReferences(IN PVOID Address)
Definition: miarm.h:1696
#define LOW_REALTIME_PRIORITY
union _MMPFN::@1721 u3
paddr_t NextPage
Definition: mmuobject.c:64
#define MC_SYSTEM
Definition: mm.h:95
BOOLEAN NTAPI KeSetTimerEx(IN OUT PKTIMER Timer, IN LARGE_INTEGER DueTime, IN LONG Period, IN PKDPC Dpc OPTIONAL)
Definition: timerobj.c:294
PFN_NUMBER MmAvailablePages
Definition: freelist.c:26
union _MMPFN::@1719 u1
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
FORCEINLINE VOID MiReleasePfnLock(_In_ KIRQL OldIrql)
Definition: mm.h:908
LONG KPRIORITY
Definition: compat.h:454
USHORT PageLocation
Definition: mm.h:297
VOID NTAPI MiDeletePte(IN PMMPTE PointerPte, IN PVOID VirtualAddress, IN PEPROCESS CurrentProcess, IN PMMPTE PrototypePte)
Definition: virtual.c:391
uint32_t ULONG_PTR
Definition: typedefs.h:63
struct _MMPFN::@1721::@1727 e2
_In_ NDIS_HANDLE _In_ PNDIS_REQUEST Request
Definition: ndis.h:5173
static KEVENT MiBalancerEvent
Definition: balance.c:45
UCHAR KIRQL
Definition: env_spec_w32.h:591
MMPFNENTRY e1
Definition: mm.h:329
#define STATUS_WAIT_1
Definition: ntstatus.h:71
ULONG * PPFN_NUMBER
Definition: ke.h:8
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define STATUS_WAIT_0
Definition: ntstatus.h:223
#define MC_MAXIMUM
Definition: mm.h:96
ULONG PFN_NUMBER
Definition: ke.h:8
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
static CLIENT_ID MiBalancerThreadId
Definition: balance.c:43
#define PsGetCurrentProcess
Definition: psfuncs.h:17
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:251
PLIST_ENTRY NTAPI ExInterlockedRemoveHeadList(IN OUT PLIST_ENTRY ListHead, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:166
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
struct _MM_ALLOCATION_REQUEST * PMM_ALLOCATION_REQUEST
static WCHAR Address[46]
Definition: ping.c:68
void DPRINT(...)
Definition: polytest.cpp:61
NTSTATUS NTAPI MmPageOutPhysicalAddress(PFN_NUMBER Page)
Definition: rmap.c:57
VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1469
VOID INIT_FUNCTION NTAPI MmInitializeMemoryConsumer(ULONG Consumer, NTSTATUS(*Trim)(ULONG Target, ULONG Priority, PULONG NrFreed))
Definition: balance.c:82
PsGetCurrentThreadId
Definition: CrNtStubs.h:7
NTSTATUS NTAPI NtSetInformationThread(IN HANDLE ThreadHandle, IN THREADINFOCLASS ThreadInformationClass, IN PVOID ThreadInformation, IN ULONG ThreadInformationLength)
Definition: query.c:1967
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
int64_t LONGLONG
Definition: typedefs.h:66
ULONG NTAPI MiTrimMemoryConsumer(ULONG Consumer, ULONG InitialTarget)
Definition: balance.c:118
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS(* Trim)(ULONG Target, ULONG Priority, PULONG NrFreed)
Definition: mm.h:387
ULONG64 Valid
Definition: mmtypes.h:150
NTSTATUS NTAPI MmRequestPageMemoryConsumer(ULONG Consumer, BOOLEAN CanWait, PPFN_NUMBER AllocatedPage)
Definition: balance.c:229
PFN_NUMBER NTAPI MmAllocPage(ULONG Consumer)
Definition: freelist.c:569
_Must_inspect_result_ typedef _In_ ULONG _In_ BOOLEAN Target
Definition: iotypes.h:1067
#define PTE_COUNT
Definition: miarm.h:33
NTSTATUS NTAPI KeWaitForMultipleObjects(IN ULONG Count, IN PVOID Object[], IN WAIT_TYPE WaitType, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL, OUT PKWAIT_BLOCK WaitBlockArray OPTIONAL)
Definition: wait.c:586
ULONG NTAPI MmGetReferenceCountPage(PFN_NUMBER Page)
Definition: freelist.c:509
HANDLE UniqueThread
Definition: compat.h:475
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static ULONG MiNrTotalPages
Definition: balance.c:38
static KSPIN_LOCK AllocationListLock
Definition: balance.c:40
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
VOID NTAPI MmRemoveLRUUserPage(PFN_NUMBER Page)
Definition: freelist.c:116
MM_MEMORY_CONSUMER MiMemoryConsumers[MC_MAXIMUM]
Definition: balance.c:36
Definition: mm.h:305
#define InterlockedDecrementUL(Addend)
Definition: ex.h:1510
static BOOLEAN MiIsBalancerThread(VOID)
Definition: balance.c:210
#define PAGE_SIZE
Definition: env_spec_w32.h:49
Definition: typedefs.h:117
PFN_NUMBER NTAPI MmGetLRUFirstUserPage(VOID)
Definition: freelist.c:63
union _MMPFN::@1724 u4
FORCEINLINE PMMPFN MiGetPfnEntry(IN PFN_NUMBER Pfn)
Definition: mm.h:940
PFN_NUMBER NTAPI MmGetLRUNextUserPage(PFN_NUMBER PreviousPage)
Definition: freelist.c:97
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI MmReleasePageMemoryConsumer(ULONG Consumer, PFN_NUMBER Page)
Definition: balance.c:97
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
#define MiPdeToPte(_Pde)
Definition: mm.h:232
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
VOID INIT_FUNCTION NTAPI MmInitializeBalancer(ULONG NrAvailablePages, ULONG NrSystemPages)
Definition: balance.c:53
#define InterlockedIncrementUL(Addend)
Definition: ex.h:1513
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
NTSTATUS NTAPI PsCreateSystemThread(OUT PHANDLE ThreadHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN HANDLE ProcessHandle, IN PCLIENT_ID ClientId, IN PKSTART_ROUTINE StartRoutine, IN PVOID StartContext)
Definition: thread.c:602
unsigned int * PULONG
Definition: retypes.h:1
SWAPENTRY SwapEntry
Definition: mm.h:316
#define DPRINT1
Definition: precomp.h:8
#define MM_HIGHEST_VAD_ADDRESS
Definition: mm.h:43
VOID NTAPI MiZeroPhysicalPage(IN PFN_NUMBER PageFrameIndex)
Definition: pfnlist.c:122
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
#define MC_CACHE
Definition: mm.h:93
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:565
#define ULONG_PTR
Definition: config.h:101
static HANDLE MiBalancerThreadHandle
Definition: balance.c:44
static ULONG MiMinimumAvailablePages
Definition: balance.c:37
return STATUS_SUCCESS
Definition: btrfs.c:2745
#define memset(x, y, z)
Definition: compat.h:39
VOID NTAPI MmInsertLRULastUserPage(PFN_NUMBER Page)
Definition: freelist.c:82
NTSTATUS MmTrimUserMemory(ULONG Target, ULONG Priority, PULONG NrFreedPages)
Definition: balance.c:178
base of all file and directory entries
Definition: entries.h:82
VOID NTAPI KeInitializeTimerEx(OUT PKTIMER Timer, IN TIMER_TYPE Type)
Definition: timerobj.c:244
LONGLONG QuadPart
Definition: typedefs.h:112
static KTIMER MiBalancerTimer
Definition: balance.c:46