ReactOS 0.4.15-dev-8408-g466a198
lookas.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
Include dependency graph for lookas.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

VOID NTAPI ExInitializeSystemLookasideList (IN PGENERAL_LOOKASIDE List, IN POOL_TYPE Type, IN ULONG Size, IN ULONG Tag, IN USHORT MaximumDepth, IN PLIST_ENTRY ListHead)
 
VOID NTAPI ExInitPoolLookasidePointers (VOID)
 
VOID NTAPI ExpInitLookasideLists (VOID)
 
PVOID NTAPI ExiAllocateFromPagedLookasideList (IN PPAGED_LOOKASIDE_LIST Lookaside)
 
VOID NTAPI ExiFreeToPagedLookasideList (IN PPAGED_LOOKASIDE_LIST Lookaside, IN PVOID Entry)
 
VOID NTAPI ExDeleteNPagedLookasideList (IN PNPAGED_LOOKASIDE_LIST Lookaside)
 
VOID NTAPI ExDeletePagedLookasideList (IN PPAGED_LOOKASIDE_LIST Lookaside)
 
VOID NTAPI ExInitializeNPagedLookasideList (IN PNPAGED_LOOKASIDE_LIST Lookaside, IN PALLOCATE_FUNCTION Allocate OPTIONAL, IN PFREE_FUNCTION Free OPTIONAL, IN ULONG Flags, IN SIZE_T Size, IN ULONG Tag, IN USHORT Depth)
 
VOID NTAPI ExInitializePagedLookasideList (IN PPAGED_LOOKASIDE_LIST Lookaside, IN PALLOCATE_FUNCTION Allocate OPTIONAL, IN PFREE_FUNCTION Free OPTIONAL, IN ULONG Flags, IN SIZE_T Size, IN ULONG Tag, IN USHORT Depth)
 

Variables

LIST_ENTRY ExpNonPagedLookasideListHead
 
KSPIN_LOCK ExpNonPagedLookasideListLock
 
LIST_ENTRY ExpPagedLookasideListHead
 
KSPIN_LOCK ExpPagedLookasideListLock
 
LIST_ENTRY ExSystemLookasideListHead
 
LIST_ENTRY ExPoolLookasideListHead
 
GENERAL_LOOKASIDE ExpSmallNPagedPoolLookasideLists [NUMBER_POOL_LOOKASIDE_LISTS]
 
GENERAL_LOOKASIDE ExpSmallPagedPoolLookasideLists [NUMBER_POOL_LOOKASIDE_LISTS]
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file lookas.c.

Function Documentation

◆ ExDeleteNPagedLookasideList()

VOID NTAPI ExDeleteNPagedLookasideList ( IN PNPAGED_LOOKASIDE_LIST  Lookaside)

Definition at line 170 of file lookas.c.

171{
173 PVOID Entry;
174
175 /* Pop all entries off the stack and release their resources */
176 for (;;)
177 {
179 if (!Entry) break;
180 (*Lookaside->L.Free)(Entry);
181 }
182
183 /* Remove from list */
185 RemoveEntryList(&Lookaside->L.ListEntry);
187}
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
KSPIN_LOCK ExpNonPagedLookasideListLock
Definition: lookas.c:18
base of all file and directory entries
Definition: entries.h:83
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ _In_ _Strict_type_match_ POOL_TYPE _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_opt_ ULONG _Out_ WDFLOOKASIDE * Lookaside
Definition: wdfmemory.h:414
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778
#define InterlockedPopEntrySList(SListHead)
Definition: rtlfuncs.h:3392

Referenced by _IRQL_requires_max_(), Ext2DestroyVcb(), Ext2InitializeVcb(), IPShutdown(), kmem_cache_destroy(), KsCreateDefaultAllocatorEx(), mount_vol(), Mx::MxDeleteNPagedLookasideList(), NtfsGetVolumeData(), sys_shutdown(), TCPShutdown(), uninit(), FxDmaEnabler::~FxDmaEnabler(), FxNPagedLookasideList::~FxNPagedLookasideList(), and FxNPagedLookasideListFromPool::~FxNPagedLookasideListFromPool().

◆ ExDeletePagedLookasideList()

VOID NTAPI ExDeletePagedLookasideList ( IN PPAGED_LOOKASIDE_LIST  Lookaside)

Definition at line 194 of file lookas.c.

195{
197 PVOID Entry;
198
199 /* Pop all entries off the stack and release their resources */
200 for (;;)
201 {
203 if (!Entry) break;
204 (*Lookaside->L.Free)(Entry);
205 }
206
207 /* Remove from list */
209 RemoveEntryList(&Lookaside->L.ListEntry);
211}
KSPIN_LOCK ExpPagedLookasideListLock
Definition: lookas.c:20

Referenced by KsCreateDefaultAllocatorEx(), mount_vol(), Mx::MxDeletePagedLookasideList(), and uninit().

◆ ExiAllocateFromPagedLookasideList()

PVOID NTAPI ExiAllocateFromPagedLookasideList ( IN PPAGED_LOOKASIDE_LIST  Lookaside)

Definition at line 129 of file lookas.c.

130{
131 PVOID Entry;
132
133 Lookaside->L.TotalAllocates++;
135 if (!Entry)
136 {
137 Lookaside->L.AllocateMisses++;
138 Entry = (Lookaside->L.Allocate)(Lookaside->L.Type,
139 Lookaside->L.Size,
140 Lookaside->L.Tag);
141 }
142 return Entry;
143}

◆ ExiFreeToPagedLookasideList()

VOID NTAPI ExiFreeToPagedLookasideList ( IN PPAGED_LOOKASIDE_LIST  Lookaside,
IN PVOID  Entry 
)

Definition at line 150 of file lookas.c.

152{
153 Lookaside->L.TotalFrees++;
154 if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth)
155 {
156 Lookaside->L.FreeMisses++;
157 (Lookaside->L.Free)(Entry);
158 }
159 else
160 {
162 }
163}
FORCEINLINE USHORT ExQueryDepthSList(_In_ PSLIST_HEADER SListHead)
Definition: exfuncs.h:153
#define InterlockedPushEntrySList(SListHead, SListEntry)
Definition: rtlfuncs.h:3389
#define PSLIST_ENTRY
Definition: rtltypes.h:134

◆ ExInitializeNPagedLookasideList()

VOID NTAPI ExInitializeNPagedLookasideList ( IN PNPAGED_LOOKASIDE_LIST  Lookaside,
IN PALLOCATE_FUNCTION Allocate  OPTIONAL,
IN PFREE_FUNCTION Free  OPTIONAL,
IN ULONG  Flags,
IN SIZE_T  Size,
IN ULONG  Tag,
IN USHORT  Depth 
)

Definition at line 218 of file lookas.c.

225{
226 /* Initialize the Header */
227 ExInitializeSListHead(&Lookaside->L.ListHead);
228 Lookaside->L.TotalAllocates = 0;
229 Lookaside->L.AllocateMisses = 0;
230 Lookaside->L.TotalFrees = 0;
231 Lookaside->L.FreeMisses = 0;
232 Lookaside->L.Type = NonPagedPool | Flags;
233 Lookaside->L.Tag = Tag;
234 Lookaside->L.Size = (ULONG)Size;
235 Lookaside->L.Depth = 4;
236 Lookaside->L.MaximumDepth = 256;
237 Lookaside->L.LastTotalAllocates = 0;
238 Lookaside->L.LastAllocateMisses = 0;
239
240 /* Set the Allocate/Free Routines */
241 if (Allocate)
242 {
243 Lookaside->L.Allocate = Allocate;
244 }
245 else
246 {
247 Lookaside->L.Allocate = ExAllocatePoolWithTag;
248 }
249
250 if (Free)
251 {
252 Lookaside->L.Free = Free;
253 }
254 else
255 {
256 Lookaside->L.Free = ExFreePool;
257 }
258
259 /* Insert it into the list */
261 &Lookaside->L.ListEntry,
263}
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define NonPagedPool
Definition: env_spec_w32.h:307
PLIST_ENTRY NTAPI ExInterlockedInsertTailList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:140
LIST_ENTRY ExpNonPagedLookasideListHead
Definition: lookas.c:17
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4065
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_In_opt_ PALLOCATE_FUNCTION Allocate
Definition: exfuncs.h:814
#define ExInitializeSListHead
_In_opt_ PALLOCATE_FUNCTION _In_opt_ PFREE_FUNCTION Free
Definition: exfuncs.h:815

Referenced by CcInitializeCacheManager(), CcInitView(), FxDmaEnabler::ConfigureBusMasterAdapters(), DriverEntry(), Ext2InitializeVcb(), FsRtlInitializeLargeMcbs(), FxNPagedLookasideList::Initialize(), FxNPagedLookasideListFromPool::Initialize(), IPStartup(), kmem_cache_create(), KsCreateDefaultAllocatorEx(), MmInitializeRmapList(), mount_vol(), Mx::MxInitializeNPagedLookasideList(), NtfsGetVolumeData(), RxDriverEntry(), sys_init(), and TCPStartup().

◆ ExInitializePagedLookasideList()

VOID NTAPI ExInitializePagedLookasideList ( IN PPAGED_LOOKASIDE_LIST  Lookaside,
IN PALLOCATE_FUNCTION Allocate  OPTIONAL,
IN PFREE_FUNCTION Free  OPTIONAL,
IN ULONG  Flags,
IN SIZE_T  Size,
IN ULONG  Tag,
IN USHORT  Depth 
)

Definition at line 270 of file lookas.c.

277{
278 /* Initialize the Header */
279 ExInitializeSListHead(&Lookaside->L.ListHead);
280 Lookaside->L.TotalAllocates = 0;
281 Lookaside->L.AllocateMisses = 0;
282 Lookaside->L.TotalFrees = 0;
283 Lookaside->L.FreeMisses = 0;
284 Lookaside->L.Type = PagedPool | Flags;
285 Lookaside->L.Tag = Tag;
286 Lookaside->L.Size = (ULONG)Size;
287 Lookaside->L.Depth = 4;
288 Lookaside->L.MaximumDepth = 256;
289 Lookaside->L.LastTotalAllocates = 0;
290 Lookaside->L.LastAllocateMisses = 0;
291
292 /* Set the Allocate/Free Routines */
293 if (Allocate)
294 {
295 Lookaside->L.Allocate = Allocate;
296 }
297 else
298 {
299 Lookaside->L.Allocate = ExAllocatePoolWithTag;
300 }
301
302 if (Free)
303 {
304 Lookaside->L.Free = Free;
305 }
306 else
307 {
308 Lookaside->L.Free = ExFreePool;
309 }
310
311 /* Insert it into the list */
313 &Lookaside->L.ListEntry,
315}
#define PagedPool
Definition: env_spec_w32.h:308
LIST_ENTRY ExpPagedLookasideListHead
Definition: lookas.c:19

Referenced by DriverEntry(), FsRtlInitializeLargeMcbs(), FsRtlInitializeTunnels(), FsRtlInitSystem(), InitLookasideList(), KsCreateDefaultAllocatorEx(), LpcInitSystem(), mount_vol(), MsqInitializeImpl(), Mx::MxInitializePagedLookasideList(), and RtlInitializeRangeListPackage().

◆ ExInitializeSystemLookasideList()

VOID NTAPI ExInitializeSystemLookasideList ( IN PGENERAL_LOOKASIDE  List,
IN POOL_TYPE  Type,
IN ULONG  Size,
IN ULONG  Tag,
IN USHORT  MaximumDepth,
IN PLIST_ENTRY  ListHead 
)

Definition at line 31 of file lookas.c.

37{
38 /* Initialize the list */
39 List->Tag = Tag;
40 List->Type = Type;
41 List->Size = Size;
42 InsertHeadList(ListHead, &List->ListEntry);
43 List->MaximumDepth = MaximumDepth;
44 List->Depth = 2;
45 List->Allocate = ExAllocatePoolWithTag;
46 List->Free = ExFreePool;
47 InitializeSListHead(&List->ListHead);
48 List->TotalAllocates = 0;
49 List->AllocateHits = 0;
50 List->TotalFrees = 0;
51 List->FreeHits = 0;
52 List->LastTotalAllocates = 0;
53 List->LastAllocateHits = 0;
54}
Type
Definition: Type.h:7
#define InsertHeadList(ListHead, Entry)
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
FORCEINLINE VOID InitializeSListHead(_Out_ PSLIST_HEADER SListHead)
Definition: rtlfuncs.h:3351

Referenced by ExpInitLookasideLists(), IopInitLookasideLists(), ObInit2(), and ObInitSystem().

◆ ExInitPoolLookasidePointers()

VOID NTAPI ExInitPoolLookasidePointers ( VOID  )

Definition at line 59 of file lookas.c.

60{
61 ULONG i;
62 PKPRCB Prcb = KeGetCurrentPrcb();
64
65 /* Loop for all pool lists */
66 for (i = 0; i < NUMBER_POOL_LOOKASIDE_LISTS; i++)
67 {
68 /* Initialize the non-paged list */
70 InitializeSListHead(&Entry->ListHead);
71
72 /* Bind to PRCB */
73 Prcb->PPNPagedLookasideList[i].P = Entry;
74 Prcb->PPNPagedLookasideList[i].L = Entry;
75
76 /* Initialize the paged list */
78 InitializeSListHead(&Entry->ListHead);
79
80 /* Bind to PRCB */
81 Prcb->PPPagedLookasideList[i].P = Entry;
82 Prcb->PPPagedLookasideList[i].L = Entry;
83 }
84}
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
GENERAL_LOOKASIDE ExpSmallNPagedPoolLookasideLists[NUMBER_POOL_LOOKASIDE_LISTS]
Definition: lookas.c:23
GENERAL_LOOKASIDE ExpSmallPagedPoolLookasideLists[NUMBER_POOL_LOOKASIDE_LISTS]
Definition: lookas.c:24
#define NUMBER_POOL_LOOKASIDE_LISTS
Definition: ketypes.h:371
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1161
GENERAL_LOOKASIDE_POOL PPNPagedLookasideList[NUMBER_POOL_LOOKASIDE_LISTS]
Definition: ketypes.h:709
GENERAL_LOOKASIDE_POOL PPPagedLookasideList[NUMBER_POOL_LOOKASIDE_LISTS]
Definition: ketypes.h:710
struct LOOKASIDE_ALIGN _GENERAL_LOOKASIDE * PGENERAL_LOOKASIDE

Referenced by ExpInitializeExecutive(), and KiSystemStartupBootStack().

◆ ExpInitLookasideLists()

VOID NTAPI ExpInitLookasideLists ( VOID  )

Definition at line 89 of file lookas.c.

90{
91 ULONG i;
92
93 /* Initialize locks and lists */
100
101 /* Initialize the system lookaside lists */
102 for (i = 0; i < NUMBER_POOL_LOOKASIDE_LISTS; i++)
103 {
104 /* Initialize the non-paged list */
107 (i + 1) * 8,
108 'looP',
109 256,
111
112 /* Initialize the paged list */
114 PagedPool,
115 (i + 1) * 8,
116 'looP',
117 256,
119 }
120}
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define KeInitializeSpinLock(sl)
Definition: env_spec_w32.h:604
VOID NTAPI ExInitializeSystemLookasideList(IN PGENERAL_LOOKASIDE List, IN POOL_TYPE Type, IN ULONG Size, IN ULONG Tag, IN USHORT MaximumDepth, IN PLIST_ENTRY ListHead)
Definition: lookas.c:31
LIST_ENTRY ExPoolLookasideListHead
Definition: lookas.c:22
LIST_ENTRY ExSystemLookasideListHead
Definition: lookas.c:21

Variable Documentation

◆ ExpNonPagedLookasideListHead

LIST_ENTRY ExpNonPagedLookasideListHead

Definition at line 17 of file lookas.c.

Referenced by ExInitializeNPagedLookasideList(), ExpInitLookasideLists(), and QSI_DEF().

◆ ExpNonPagedLookasideListLock

KSPIN_LOCK ExpNonPagedLookasideListLock

◆ ExPoolLookasideListHead

LIST_ENTRY ExPoolLookasideListHead

Definition at line 22 of file lookas.c.

Referenced by ExpInitLookasideLists(), ExQueryPoolUsage(), and QSI_DEF().

◆ ExpPagedLookasideListHead

LIST_ENTRY ExpPagedLookasideListHead

Definition at line 19 of file lookas.c.

Referenced by ExInitializePagedLookasideList(), ExpInitLookasideLists(), and QSI_DEF().

◆ ExpPagedLookasideListLock

KSPIN_LOCK ExpPagedLookasideListLock

◆ ExpSmallNPagedPoolLookasideLists

GENERAL_LOOKASIDE ExpSmallNPagedPoolLookasideLists[NUMBER_POOL_LOOKASIDE_LISTS]

Definition at line 23 of file lookas.c.

Referenced by ExInitPoolLookasidePointers(), and ExpInitLookasideLists().

◆ ExpSmallPagedPoolLookasideLists

GENERAL_LOOKASIDE ExpSmallPagedPoolLookasideLists[NUMBER_POOL_LOOKASIDE_LISTS]

Definition at line 24 of file lookas.c.

Referenced by ExInitPoolLookasidePointers(), and ExpInitLookasideLists().

◆ ExSystemLookasideListHead

LIST_ENTRY ExSystemLookasideListHead

Definition at line 21 of file lookas.c.

Referenced by ExpInitLookasideLists(), IopInitLookasideLists(), ObInit2(), ObInitSystem(), and QSI_DEF().