VOID
ExInitializeNPagedLookasideList(
IN PNPAGED_LOOKASIDE_LIST Lookaside,
IN PALLOCATE_FUNCTION Allocate, /*
optional */
IN PFREE_FUNCTION Free, /*
optional */
IN ULONG Flags,
IN ULONG Size,
IN ULONG Tag,
IN USHORT Depth
);
ExInitializeNPagedLookasideList initializes a lookaside list of nonpaged memory. After a successful initialization, fixed-size blocks can be allocated from and freed to the lookaside list.
typedef struct _NPAGED_LOOKASIDE_LIST { SLIST_HEADER ListHead; USHORT Depth; USHORT Pad; ULONG TotalAllocates; ULONG AllocateMisses; ULONG TotalFrees; ULONG FreeMisses; POOL_TYPE Type; ULONG Tag; ULONG Size; PALLOCATE_FUNCTION Allocate; PFREE_FUNCTION Free; LIST_ENTRY ListEntry; KSPIN_LOCK Lock; } NPAGED_LOOKASIDE_LIST, *PNPAGED_LOOKASIDE_LIST;
None.
ExInitializeNPagedLookasideList does the following:
ExInitializeNPagedLookasideList initializes the caller-supplied list header but does not allocate memory for list entries. The initial entries are allocated on an as-needed basis by the Lookaside.Allocate routine. The list becomes populated as entries are freed back to the list. Entries collect on the list until Lookaside.Depth is reached. Once Depth entries are on the list, any additional entries that are freed are returned to nonpaged pool using the Lookaside.Free routine. If the list becomes empty, allocate requests are satisfied by the Lookaside.Allocate routine.
The OS maintains a list of all the nonpaged lookaside lists in use on the system.
For optimal performance, the OS uses an 8-byte compare exchange operation to synchronize access to the lookaside list if such an instruction is available. On platforms where such an instruction is not available, the spin lock is used.
Owners of a nonpaged lookaside list should choose the Depth of the list carefully. The entries on the list consume nonpaged memory, making that memory unavailable to other components on the system. The list Depth should provide a good hit rate on allocations without consuming excessive memory.
If the POOL_ALLOCATE_RAISE_IF_FAILURE flag is set, the system raises an exception instead of returning NULL if an allocate fails.
Callers of ExInitializeNPagedLookasideList must be running at IRQL <= DISPATCH_LEVEL, but are usually running at PASSIVE_LEVEL.
ExAllocateFromNPagedLookasideList, ExAllocatePool, ExAllocatePoolWithTag, ExDeleteNPagedLookasideList, ExFreeToNPagedLookasideList, ExFreePool, ExInitializePagedLookasideList