System Control Parameters

The system control parameters used to check and modify the behavior of the kernel dynamically make up the lion's share of entries in the proc filesystem. However, this interface is not the only way of manipulating data — this can also be done using the sysctl system call. This requires more effort because it is first necessary to write a program to support communication with the kernel via the system call interface. As a result, the numeric sysctl mechanism was tagged as being obsolete during development of 2.5 (the kernel outputs a warning message to this effect each time sysctl is invoked) and was planned to be dropped at some point. Removing the system call has, however, created a controversial discussion, and up to 2.6.25, the call is still in the kernel — although a message warns the user that it is deprecated.

The sysctl system call is not really needed because the /proc interface is a kernel data manipulation option of unrivaled simplicity. The sysctl parameters are managed in a separate subdirectory named /proc/sys, which is split into further subdirectories in line with the various kernel subsystems:

[email protected]> Is -l total 0

dr-xr-xr-x 0 root root 0

dr-xr-xr-x 0 root root 0

dr-xr-xr-x 0 root root 0

dr-xr-xr-x 0 root root 0

dr-xr-xr-x 0 root root 0

dr-xr-xr-x 0 root root 0

dr-xr-xr-x 0 root root 0

/proc/sys

2008-02-15 04:29 abi

2008-02-15 04:29 debug

2008-02-14 22:26 dev

2008-02-14 22:22 fs

2008-02-14 22:22 kernel

2008-02-14 22:22 net

2008-02-14 22:26 vm

The subdirectories contain a series of files that reflect the characteristic data of the associated kernel subsystems. For example, /proc/sys/vm includes the following entries:

[email protected]> ls -l /proc/sys/vm total 0

-rw-r--r-- 1 root root 0 2008-02-17 01:32 block_dump

-rw-r--r-- 1 root root 0 2008-02-16 20:55 dirty_background_ratio

-rw-r--r-- 1 root root 0 2008-02-16 20:55 dirty_expire_centisecs

-rw-r--r-- 1 root root 0 2008-02-16 20:55 dirty_ratio

-rw-r--r-- 1 root root 0 2008-02-16 20:55 dirty_writeback_centisecs

-rw-r--r-- 1 root root 0 2008-02-17 01:32 swappiness -rw-r--r-- 1 root root 0 2008-02-17 01:32 vfs_cache_pressure -rw-r--r-- 1 root root 0 2008-02-17 01:32 zone_reclaim_mode

Unlike the files discussed earlier, the contents of the files in these directories can not only be read, but also supplied with new values by means of normal file operations. For instance, the vm subdirectory includes a swappiness file to indicate how "aggressively" the swapping algorithm goes about its job of swapping out pages. The default value is 60, as shown when the file contents are output using cat:

[email protected]> cat /proc/sys/vm/swappiness 60

However, this value can be modified by issuing the following command (as root user):

[email protected]> echo "80" > /proc/sys/vm/swappiness [email protected]> cat /proc/sys/vm/swappiness 80

As discussed in Chapter 18, the higher the swappiness value the more aggressively will the kernel swap out pages; this can lead to better performance at certain system load levels.

Section 10.1.8 describes in detail the implementation used by the kernel to manipulate parameters in the proc filesystem.

Continue reading here: Data Structures

Was this article helpful?

0 0