Wednesday, July 28, 2010

How to stop the flushing of mmaped pages to disk in RHEL5.2 and later?

If your application is mmapping too much memory, resulting in lots of pdflush write activity and thereby by affecting system performance, vm.flush_mmap_pages kernel parameter could be useful.

/proc/sys/vm/flush_mmap_pages is introduced in RHEL5.2 kernel.

Setting /proc/sys/vm/flush_mmap_pages to 0 will stop the flushing of dirty memory-mapped file pages to disk as long as the memory map is active.

All dirty file pages will be asynchronously flushed to disk only as soon as the memory map is deactivated.





Added a new kernel parameter: /proc/sys/vm/flush_mmap_pages. This parameter specifies whether or not memory-mapped file pages should be flushed to disk by kupdate while the memory map is active. Valid values for this parameter are 1 (enable memory mapping by kupdate) and 0 (disable memory mapping by kupdate). The default value for this parameter is 1.

To configure this parameter, use echo [1 or 0] /proc/sys/vm/flush_mmap_pages. Setting this parameter to 0 does the following:

kupdate will not flush dirty memory-mapped file pages as long as the memory map is active.

All dirty file pages will be asynchronously flushed to disk only as soon as the memory map is deactivated.

If you set /proc/sys/vm/flush_mmap_pages to 0, it is advisable that you use another application to manually sync memory-mapped pages to disk.