• how kswapd work & swap parameter & swap demo


    2.2.1 Zone Watermarks

    When available memory in the system is low, the pageout daemon kswapd is woken up to start freeing pages (see Chapter 10). If the pressure is high, the process will free up memory synchronously, sometimes referred to as the direct-reclaim path. The parameters affecting pageout behavior are similar to those used by FreeBSD [McK96] and Solaris [MM01].

    Each zone has three watermarks called pages_low, pages_min and pages_high, which help track how much pressure a zone is under. The relationship between them is illustrated in Figure 2.2. The number of pages for pages_min is calculated in the function free_area_init_core() during memory init and is based on a ratio to the size of the zone in pages. It is calculated initially as ZoneSizeInPages/128. The lowest value it will be is 20 pages (80K on a x86), and the highest possible value is 255 pages (1MiB on a x86).

    Figure 2.2. Zone Watermarks

     

    clip_image001

     

    涉及swap,有三个参数,page_min,page_max,pages_low,

    下文中简称(min,max,low)

     

    当可用页数 available pages)小于min,启动kswapd

     

    当可用页数               其小于low,依然可以分配,只不过只能是fgp_atomic类型。

    问题:图中,从minlow,页消耗率明显降低。但是小于low后,为何页消耗率会又增加?

    在书上的注释说:

     

    pages_min When pages_min is reached, the allocator will do the kswapd work in a synchronous fashion, sometimes referred to as the direct-reclaim path. Solaris does not have a real equivalent, but the closest is the desfree or minfree, which determine how often the pageout scanner is woken up.

    我看完注释,依然不解。

     

    当可用页数 恢复到max,此时kswap休眠。

    期间,从minlow,low high,前个区间回收页面的速率低,我认为前段区间有内存分配器的帮忙,后者只有kswapd工作。不知各位看法。

     

     

     

     

     

    At each watermark a different action is taken to address the memory shortage.

     

    pages_low When the pages_low number of free pages is reached, kswapd is woken up by the buddy allocator to start freeing pages. This is equivalent to when lotsfree is reached in Solaris and freemin in FreeBSD. The value is twice the value of pages_min by default.

     

    pages_min When pages_min is reached, the allocator will do the kswapd work in a synchronous fashion, sometimes referred to as the direct-reclaim path. Solaris does not have a real equivalent, but the closest is the desfree or minfree, which determine how often the pageout scanner is woken up.

     

    pages_high   After kswapd has been woken to start freeing pages, it will not consider the zone to be "balanced" when pages_high pages are free.

     

     After the watermark has been reached, kswapd will go back to sleep. In Solaris, this is called lotsfree, and, in BSD, it is called free_target. The default for pages_high is three times the value of pages_min.

     

     

    Whatever the pageout parameters are called in each operating system, the meaning is the same. It helps determine how hard the pageout daemon or processes work to free up pages.

  • 相关阅读:
    Spark SQL 初步
    Android开展:ADT+Eclipse使用错误:Text editor does not have a document provider
    android 98 MediaPlayer+SurfaceView播放视频
    android97 播放音频 有进度条控制
    android96 内存创建图片副本,画画板
    Android记录6--ViewPage+Fragment的使用例子
    android95 缩放加载大图片
    android94 样式和主题
    android93 进程优先级补充
    android92 aidl远程进程通信
  • 原文地址:https://www.cnblogs.com/titer1/p/2433934.html
Copyright © 2020-2023  润新知