也就是“export PSALLOC=early”)。这样就保证当进程使 用malloc()调用的同时,在Paging Space中有相应的空间保留给该进程,从而保 证该进程的page out 操作。
这种机制虽然可以保证现有的进程安全,但由于很多被保留的页面空间并没有被用到,造成了非常大的空间浪费。同时,也需要Paging Space的大小比实际内存值要大很多。 EPSA在以前版本操作系统中使用比较多,主要的原因当时的系统物理内存比较少,一般都少于512M,在少内存的情况下EPSA会使系统进程的调度更加安全. (4) 相关命令
?
查看当前系统采用的paging space的机制
# vmo -a |grep defps defps = 1
defps=1表示采用的是DPSA,如果defps=0表示采用的是LPSA.
?
修改paging space的机制,采用LPSA
# vmo -o defps=0
?
查看defps属性
当前值是1,缺省值是1,启动时的值是1, 取值范围是0-1,类型是动态可以修改的. # vmo -L defps
NAME CUR DEF BOOT MIN MAX UNIT TYPE DEPENDENCIES
-------------------------------------------------------------------------------- defps 1 1 1 0 1 boolean D
--------------------------------------------------------------------------------
?
vmo Tips
VMO Man page -L [ Tunable ]
Lists the characteristics of one or all tunables, one per line, using the following format:
NAME CUR DEF BOOT MIN MAX UNIT TYPE DEPENDENCIES -------------------------------------------------------------------------------- memory_frames 128K 128K 4KB pages S --------------------------------------------------------------------------------
maxfree 1088 1088 130 16 200K 4KB pages D minfree memory_frames
--------------------------------------------------------------------------------
minfree 960 960 122 8 200K 4KB pages D maxfree memory_frames -------------------------------------------------------------------------------- ... where:
CUR = current value DEF = default value BOOT = reboot value MIN = minimal value MAX = maximum value UNIT = tunable unit of measure
TYPE = parameter type: D (for Dynamic), S (for Static), R for Reboot), B (for Bosboot), M (for Mount), I (for Incremental), C (for Connect), and d (for Deprecated) DEPENDENCIES = list of dependent tunable parameters, one per line
Paging-space thresholds tuning
如果paging space少到一定的空间,操作系统将会通过先告警进程释放paging space,最后可能会kill进程.相关的两个参数npswarn和npskill: # vmo -a |grep npswarn npswarn = 249856 # vmo -h npswarn
Help for tunable npswarn:
Specifies the number of free paging-space pages at which the operating system begins sending the SIGDANGER signal to processes. Default: MAX (512,4*npskill). 大于0小于系统paging space的数目. Increase the value if you experience processes being killed because of low paging space.
# vmo -a |grep npskill npskill = 62464 # vmo -h npskill Help for tunable npskill:
Specifies the number of free paging-space pages at which the operating system begins killing processes. Default: MAX (64, number_of_paging_space_pages/128). 大于0小于系统paging space的数目.
Paging space garbage collection
AIX 5.3之后可以利用paging space garbage collection机制来free up paging space. 只作用于deferred page space allocation policy.
?
方法一: re-pagein 后的垃圾收集
The method of freeing a paging-space disk block after a page has been read back into memory from paging space is employed by default. 相关参数: npsrpgmin: 停止re-pagein垃圾收集的free paging space blocks数目 npsrpgax: 开始re-pagein垃圾收集的free paging space blocks数目
?
方法二: scrubbing memory
Another method of paging space garbage collection is by scrubbing memory, which is implemented with the psgc kernel process. The psgc kernel process frees up paging space disk blocks for modified memory pages that have not yet been paged out again or for unmodified pages for which a paging space disk block exists. 相关的参数: npsscrubmin 停止scrubbing内存的free paging space blocks数目
npsscrubmax: 开始scrubbing内存的free paging space blocks数目 # vmo -a |grep nps npskill = 62464 npsrpgmax = 499712 npsrpgmin = 374784 npsscrubmax = 499712 npsscrubmin = 374784 npswarn = 249856
Paging Space的创建原则
AIX中Paging Space大小确定的指导原则如下(理论上):
? ? ? ?
系统实际内存小于64MB, paging space= 2 * RAM ;
系统实际内存在 64MB to 256MB 之间, Page Space = RAM size + 16MB ; 系统实际内存大于 256MB , Page Space = 512 + ( RAM - 256 ) * 1.25 ; 当内存超过4GB时,则需要根据实际情况来定,一般可初始3GB, 然后观察paging space的使用情况,如果使用率超过70%, 则需要增加paging space 。
此外在创建Paging Space时还应遵循以下原则以提高性能:
? ? ?
创建的数量应尽可能的多;
每个Paging Space的大小应该相同;
每个Paging Space应尽可能的分配在不同的硬盘上。
工程和维护建议(目前内存和硬盘都比较大,相对比较实用些):
如果硬盘空间不是问题的话,建议可以是内存的两倍.如果内存大于8G或者16G,可以考虑先和内存空间相同. 同时用两块不同的内置盘各分配一半的paging space空间. 对于做了根盘镜像的系统,建议可以不镜像paging space(维护时注意这些特点). 大的swap空间可以避免DPSA可能产生的风险,对于运维来说可能可以减少相关的维护分析工作.
Paging Space命令
AIX中可以通过命令lsps -s查看Paging Space的使用情况。列Total Paging Space给出的是系统总的Paging Space空间大小,Percent Used则表示已被占用的Paging Space的百分比。
# lsps -a
Page Space Physical Volume Volume Group Size %Used Active Auto Type hd6 hdisk1 rootvg 31232MB 1 yes yes lv AIX 性能调优 内存篇之三 内存工作机制 序号 版本号 更改人 日期 备注 1 1.0版 bldmickey 2007-06-18 本章介绍和AIX内存工作机制 部分内容来源:
http://www-900.ibm.com/cn/support/viewdoc/detail?DocId=2611084C28000
AIX 5L v 5.3 Performance management官方文档
虚拟内存管理器(VMM)
VMM services all memory requests from the system. 当内存被申请的时候(Working类型),对于early allocation of paging space policy情况下,在RAM被访问的时候,不管是否还有多少物理剩余空间,都会有paging space被分配,在这种情况下VMM起到了关键的作用.(不过目前系统缺省的paging space的分配原则是DPSA).
虚拟地址空间划分成段。每段的大小是 256 MB,它是虚拟内存地址空间中一个邻接的部分,数据对象可映射到该空间。虚拟内存段划分成固定大小的单元叫做页。缺省页面大小是 4096 字节。段中的每页在需要之前可位于实际内存(RAM)中,或存储在磁盘上。同样,实际内存也可以划分成 4096 字节的page frame。
VMM 的角色是管理分配实际内存页面帧并且解析程序对虚拟内存页面的引用,这些虚拟内存页面当前不在实际内存中或还不存在(例如,当进程第一次引用其数据段的某一页时)。