Securing-Optimizing-RH-Linux-1_2_69
Comments and suggestions concerning this book should be mailed to gmourani@videotron.ca
© Copyright 1999-2000 Gerhard Mourani and Open Network Architecture ®
69
2. The bdflush parameters
The bdflush file is closely related to the operation of the virtual memory (VM) subsystem of the
Linux kernel and has a little influence on disk usage. This file (/proc/sys/vm/bdflush) controls the
operation of the bdflush kernel daemon. We generally tune this file to improve file system
performance. Be changing some values from the default as show bellow, the system seems more
responsive, e.g. it waits a little more to write to disk and thus avoids some disk access contention.
·
To change the values of bdflush, type the following command on your terminal:
[root@deep /]# echo "100 1200 128 512 15 5000 500 1884 2">/proc/sys/vm/bdflush
In our example above, according to the/usr/src/linux/Documentation/sysctl/vm.txt file, the first
parameter (100 %) governs the maximum number of dirty buffers in the buffer cache. Dirty means
that the contents of the buffer still have to be written to disk (as opposed to a clean buffer, which
can just be forgotten about). Setting this to a high value means that Linux can delay disk writes
for a long time, but it also means that it will have to do a lot of I/O at once when memory becomes
short. A low value will spread out disk I/O more evenly.
The second parameter (1200) (ndirty) gives the maximum number of dirty buffers that bdflush can
write to the disk in one time. A high value will mean delayed, bursty I/O, while a small value can
lead to memory shortage when bdflush isn't woken up often enough...
The third parameter (128) (nrefill) is the number of buffers that bdflush will add to the list of free
buffers when refill_freelist() is called. It is necessary to allocate free buffers beforehand, since the
buffers often are of a different size than memory pages and some bookkeeping needs to be done
beforehand. The higher the number, the more memory will be wasted and the less often
refill_freelist() will need to run.
When refill_freelist() (512) comes across more than nref_dirt dirty buffers, it will wake up bdflush.
Finally, the age_buffer (50*HZ) and age_super parameters (5*HZ) govern the maximum time
Linux waits before writing out a dirty buffer to disk. The value is expressed in jiffies (clockticks),
the number of jiffies per second is 100. Age_buffer is the maximum age for data blocks, while
age_super is for file system metadata.
The fifth (15) and last two parameters (1884 and 2) are unused by the system so we dont need
to change the default ones.
You may add the above commands to the /etc/rc.d/rc.local script file and youll not have to type
it again the next time if you reboot your system. Look at
/usr/src/linux/Documentation/sysctl/vm.txt for more information on how to improve kernel
parameters related to virtual memory.
3. The buffermem parameters
The buffermem file is also closely related to the operation of the virtual memory (VM) subsystem
of the Linux kernel. The value in this file /proc/sys/vm/buffermem controls how much memory
should be used for buffer memory (in percentage). It is important to note that the percentage is
calculated as a percentage of total system memory.
·
To change the values of buffermem, type the following command on your terminal:
[root@deep /]# echo "80 10 60" >/proc/sys/vm/buffermem
In our example above, according to the/usr/src/linux/Documentation/sysctl/vm.txt file, the first
parameter (80 %) means to use a minimum of 80 percent of memory for the buffer cache; the
minimum percentage of memory that should be spent on buffer memory.