The kernel supports the fine-tuning of synchronization by means of parameters. These can be set by the administrator to help the kernel assess system usage and loading. The sysctl mechanism described in Chapter 10 is used for this purpose, which means that the proc filesystem is the natural interface to manipulate the parameters — they are located in /proc/sys/vm/. Four parameters can be set, all of which are defined in mm/page-writeback.c3:
□ dirty_background_ratio specifies the percentage of dirty pages at which pdflush starts periodic flushing in the background. The default value is 10 so that the update mechanism kicks in when more than 10 percent of the pages have changed as compared to the backing store.
□ vm_dirty_ratio (the corresponding sysctl is dirty_ratio) specifies the percentage of dirty pages (with respect to non-HIGHMEM memory) at which data flushing will be started. The default value is 40.
Why is high memory excluded from the percentage? Older kernel versions before 2.6.20 did not, in fact, distinguish between high and normal memory. However, if the ratio between high memory and low memory is too large (i.e., if main memory is much more than 4 GiB on 32-bit processors), the default settings for dirty_background_ratio and dirty_ratio were required to be scaled back slightly when the writeback mechanism was initialized.
Retaining the default values would have necessitated an excessively large number of buffer_head instances, and these would have had to be held in valuable low memory. By excluding high memory from the calculation, the kernel does not deal with scaling anymore, which simplifies matters somewhat.
□ The interval between two invocations of the periodic flushing routine is defined in dirty_writeback_interval (the corresponding sysctl is dirty_writeback_centisecs). The interval is specified in hundredths of a second (also called centiseconds in the sources). The default is 500, which equates to an interval of 5 seconds between invocations.
On systems where a very large number of write operations are performed, lowering this value can have a positive effect, but increasing the value on systems with very few write operations delivers only small performance gains.
□ The maximum period during which a page may remain dirty is specified in dirty_expire_ interval (the sysctl is dirty_expire_centisecs). Again, the period is expressed is hundredths of a second. The default value is 3,000, which means that a page may remain dirty for a maximum of 30 seconds before it is written back at the next opportunity.
Continue reading here: Central Control
Was this article helpful?