很多DBA對nonpage pool 和 paged pool 搞不太清楚干嘛用的,看perfmon中的說明也看得稀里糊塗。找到一個資料就翻譯一下。
From:http://blogs.technet.com/b/markrussinovich/archive/2009/03/26/3211216.aspx
Nonpaged Pool(非分頁池)
The kernel and device drivers use nonpaged pool to store data that might be accessed when the system can’t handle page faults. The kernel enters such a state when it executes interrupt service routines (ISRs) and deferred procedure calls (DPCs), which are functions related to hardware interrupts. Page faults are also illegal when the kernel or a device driver acquires a spin lock, which, because they are the only type of lock that can be used within ISRs and DPCs, must be used to protect data structures that are accessed from within ISRs or DPCs and either other ISRs or DPCs or code executing on kernel threads. Failure by a driver to honor these rules results in the most common crash code, IRQL_NOT_LESS_OR_EQUAL.
內核或者設備驅動使用非分頁池來保存可能訪問的數據,但是在訪問的時候又不能出現也錯誤。當內核執行中斷服務程序並且延遲調用過程的時候就會進入這種狀態,這個狀態和硬件中斷相關聯。當內核或者設備驅動在這個狀態后,獲取了一個自旋鎖,頁錯誤也是不被允許的,自旋鎖是唯一能在延遲調用或者中斷服務程序中能用的鎖類型,用來保護被延遲過程調用和中斷服務程序訪問的數據,可能來自於延遲過程調用和中斷服務程序,也可能來自其他的延遲過程調用和中斷服務程序,或者其他的內核線程。如果驅動程序在執行整個規則的時候出錯會得到一個 IRQL_NOT_LESS_OR_EQUAL 的崩潰代碼
Nonpaged pool is therefore always kept present in physical memory and nonpaged pool virtual memory is assigned physical memory. Common system data structures stored in nonpaged pool include the kernel and objects that represent processes and threads, synchronization objects like mutexes, semaphores and events, references to files, which are represented as file objects, and I/O request packets (IRPs), which represent I/O operations.
非分頁池因此總是報錯在內存中,非分頁池的虛擬地址被物理地址分配。通用的系統數據結構被保存在非分頁池中包含內核和代表進程和線程的對象,互斥對象,同步信號量,引用文件(代表文件對象),和I/O請求包(代表I/O操作)
Paged Pool(分頁池)
Paged pool, on the other hand, gets its name from the fact that Windows can write the data it stores to the paging file, allowing the physical memory it occupies to be repurposed. Just as for user-mode virtual memory, when a driver or the system references paged pool memory that’s in the paging file, an operation called a page fault occurs, and the memory manager reads the data back into physical memory. The largest consumer of paged pool, at least on Windows Vista and later, is typically the Registry, since references to registry keys and other registry data structures are stored in paged pool. The data structures that represent memory mapped files, called sections internally, are also stored in paged pool.
分頁池,從字面意思來說,也就是可以存到系統的分頁文件中,允許物理內存重定向。如用戶模式的虛擬內存,當驅動或者系統引用分頁池內存在分頁文件中,那么一個操作就會調用頁錯誤,內存管理系統把數據從分頁文件中讀取到物理內存。在windows vista和之后的版本,分頁池最大的使用者是注冊表,引用的注冊鍵值和其他注冊表數據都是存儲在分頁池中。內存映射文件(內部叫做內存對象[Sections])也存在分頁池中。
Device drivers use the ExAllocatePoolWithTag API to allocate nonpaged and paged pool, specifying the type of pool desired as one of the parameters. Another parameter is a 4-byte Tag, which drivers are supposed to use to uniquely identify the memory they allocate, and that can be a useful key for tracking down drivers that leak pool, as I’ll show later.
設備驅動可以使用ExAllocatePoolWithTag API來申請非分頁池和分頁池,可以使用參數來指定在那個類型的池中申請。另外一個參數是4個字節的tag,用來唯一標示分配內存的驅動程序,並且在跟蹤驅動程序是否缺少池十分有用。
