[摘要]Pushing the Limits of Windows: Paged and Nonpaged Pool From Mark Russinovich's blog

This an abstract to Russinovich's blog:
Pushing the Limits of Windows: Paged and Nonpaged Pool(http://blogs.technet.com/markrussinovich/archive/2009/03/26/3211216.aspx)
学习其精华,留下我的糟粕在这里

1.当内核在执行ISR(interrupt service routines),DPC(deferred procedure calls)或者请求一个spin lock等诸多无法处理page faults的情况下,就需要使用nonpaged pool去存储所需要访问的数据和运行的代码。否则,就会产生一个BSOD错误IRQL_NOT_LESS_OR_EQUAL。所以很多核心的数据结构都是存放在nonpaged pool中。

2.相对于nonpaged pool中的内容永远存在于物理内存中,paged pool中的内容就可以被page out到paging file中。注册表就是典型的存放在page pool中的,所以访问注册表的函数都有小于DIRQL的要求。
3.ExAllocatePoolWithTag可以用在kernel mode中从两个pool中分配内存。
4.有三个数值反映pool的使用,以及对应于!vm命令的输出。
    Pool nonpaged bytes        :对应于NonPagedPool Usage,直接反映于物理内存中有多少内存
    Pool paged bytes (virtual size of paged pool – some may be paged out)     :对应于PagedPool Usage,包括被page out的部分
    Pool paged resident bytes (physical size of paged pool)                           :对应于PagedPool Commit,也就是说存在于物理内存中的部分。
5.对于32位的os,Vista以前,Windows在boot阶段根据实际物理内存的大小计算nonpaged pool的大小。Vista以后,包括Win7, 是动态的给不同的pool分配地址空间,当然对于nonpaged pool依然存在一个上限,物理内存75%高一点的值和2G之间的最小值。
6.对于64位的os,由于有足够的地址空间,所以pool的地址空间都是静态分配的。
32-bit 64-bit
XP, Server 2003 up to 1.2GB RAM: 32-256 MB 
> 1.2GB RAM: 256MB
min( ~400K/MB of RAM, 128GB)
Vista, Server 2008,
Windows 7, Server 2008 R2
min( ~75% of RAM, 2GB) min(~75% of RAM, 128GB)
    
7.Paged pool limits are therefore primarily dictated by the amount of system address space the memory manager assigns to paged pool, as well as the system commit limit.(system commit limit似乎并不是等同于paged pool)
8.32位系统,Vista以前也是paged pool也是静态分配的.不同的OS的上限不一样。vista以后上限是2G,取决于何时kernerl address space用完或者达到了system commit limit。
9.64位系统,...XXX
  32-bit 64-bit
XP, Server 2003 XP: up to 491MB
Server 2003: up to 650MB
min( 4 * nonpaged pool limit, 128GB)
Vista, Server 2008,
Windows 7, Server 2008 R2
min( system commit limit, 2GB) min( system commit limit, 128GB)
10.一些简单的例子来记录pool泄漏,属于已掌握的知识,略过。
原文地址:https://www.cnblogs.com/aoaoblogs/p/1609096.html