Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1362447
  • 博文数量: 343
  • 博客积分: 13098
  • 博客等级: 上将
  • 技术积分: 2862
  • 用 户 组: 普通用户
  • 注册时间: 2005-07-06 00:35
文章存档

2012年(131)

2011年(31)

2010年(53)

2009年(23)

2008年(62)

2007年(2)

2006年(36)

2005年(5)

分类: 虚拟化

2012-09-13 01:04:58

1. KSM的配置文件:

  1. # Configuration file for ksmtuned.
    #DEBUG=1
    # number of seconds ksmtuned should sleep between tuning adjustments
    # Every KSM_MONITOR_INTERVAL seconds ksmtuned adjust how aggressive KSM will
    # search for duplicated pages based on free memory.
    # KSM_MONITOR_INTERVAL=60

    # Millisecond sleep between ksm scans for 16Gb server.
    # Smaller servers sleep more, bigger sleep less.
    # How many Milliseconds to sleep between scans of 16GB of RAM.
    # The actual sleep time is calculated as sleep = KSM_SLEEP_MSEC * 16 / Total GB of RAM
    # The final sleep value will be written to /sys/kernel/mm/ksm/sleep_millisecs
    # KSM_SLEEP_MSEC=100

    # KSM_NPAGES_BOOST: amount to increment the number of pages to scan
    # The number of pages to be scanned will be increased by KSM_NPAGES_BOOST
    # when the amount of free ram < threshold (see KSM_THRES_* below)
    # KSM_NPAGES_BOOST=300

    # KSM_NPAGES_DECAY: amount to decrease the number of pages to scan
    # The number of pages to be scanned will be decreased by KSM_NPAGES_DECAY
    # when the amount of free ram >= threshold (see KSM_THRES_* below)
    # KSM_NPAGES_DECAY=-50

    # KSM_NPAGES_MIN: Minimum number of pages to be scanned at all times
    # KSM_NPAGES_MIN=64

    # KSM_NPAGES_MAX: Maximum number of pages to be scanned at all times
    # KSM_NPAGES_MAX=1250

    # KSM_THRES_COEF: Decimal percentage of free RAM
    # If free memory is less than this percentage KSM will be activated
    # KSM_THRES_COEF=20

    # KSM_THRES_CONST: Bytes
    # If free memory is less than this number KSM will be activated
    # KSM_THRES_CONST=2048

    #NOTE: Only KSM_THRES_CONST or KSM_THRES_COEF is actually used.
    #Whichever results in a larger number wins.

2. KSM运行时的配置

KSM 的管理和监控通过 sysfs(位于根 /sys/kernel/mm/ksm)执行。在这个 sysfs 子目录中,您将发现一些文件,有些用于控制,其他的用于监控。

第一个文件 run 用于启用和禁用 KSM 的页面合并。默认情况下,KSM 被禁用(0),但可以通过将一个 1 写入这个文件来启用 KSM 守护进程(例如,echo 1 > sys/kernel/mm/ksm/run)。通过写入一个 0,可以从运行状态禁用这个守护进程(但是保留合并页面的当前集合)。另外,通过写入一个 2,可以从运行状态(1)停止 KSM 并请求取消合并所有合并页面。

KSM 运行时,可以通过 3 个参数(sysfs 中的文件)来控制它。sleep_millisecs 文件定义执行另一次页面扫描前 ksmd 休眠的毫秒数。max_kernel_pages 文件定义 ksmd 可以使用的最大页面数(默认值是可用内存的 25%,但可以写入一个 0 来指定为无限)。最后,pages_to_scan 文件定义一次给定扫描中可以扫描的页面数。任何用户都可以查看这些文件,但是用户必须拥有根权限才能修改它们。

还有 5 个通过 sysfs 导出的可监控文件(均为只读),它们表明 ksmd 的运行情况和效果。full_scans 文件表明已经执行的全区域扫描的次数。剩下的 4 个文件表明 KSM 的页面级统计数据:

  • pages_shared:KSM 正在使用的不可交换的内核页面的数量。
  • pages_sharing:一个内存存储指示。
  • pages_unshared:为合并而重复检查的惟一页面的数量。
  • pages_volatile:频繁改变的页面的数量。
阅读(2572) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~