Tuning Your Existing Linux Kernel

 < Day Day Up > 

In the previous section, you downloaded and installed a completely new kernel. We made various selections regarding the functionality of our new kernel in the make xconfig step. You were, however, limited in the amount of customization we could perform to the kernel during installation. Now look at some additional customization that you can perform to the kernel after it's installed.

The first area to investigate is the /proc file system.

/proc File System

An interesting component of the Linux operating system is the /proc file system. /proc doesn't really exist in the sense that it is on the disk like other file systems. The 'files' in /proc are a function of the kernel and/or variables in the kernel. /proc provides a mechanism by which you can view and set parameters in the kernel.

/proc gives us a lot of useful information about the kernel. For instance, you can see a complete rundown of the processor in your system by issuing cat /proc/cpuinfo, as shown in the following example first on our two-processor Integrity server and then on our IA-32 system:

 # cat /proc/cpuinfo                          (On Integrity dual processor) processor  : 0 vendor     : GenuineIntel arch       : IA-64 family     : Itanium 2 model      : 0 revision   : 7 archrev    : 0 features   : branchlong cpu number : 0 cpu regs   : 4 cpu MHz    : 1000.000000 itc MHz    : 1000.000000 BogoMIPS   : 1497.36 processor  : 1 vendor     : GenuineIntel arch       : IA-64 family     : Itanium 2 model      : 0 revision   : 7 archrev    : 0 features   : branchlong cpu number : 0 cpu regs   : 4 cpu MHz    : 1000.000000 itc MHz    : 1000.000000 BogoMIPS   : 1497.36 # cat /proc/cpuinfo                          (On IA-32) processor      : 0 vendor_id      : GenuineIntel cpu family     : 6 model          : 3 model name     : Pentium II (Klamath) stepping       : 3 cpu MHz        : 232.675 cache size     : 512 KB fdiv_bug       : no hlt_bug        : no f00f_bug       : no coma_bug       : no fpu            : yes fpu_exception  : yes cpuid level    : 2 wp             : yes flags          : fpu vme de pse tsc msr pae mce cx8 sep mtrr pge mca cmov mmx bogomips       : 463.66 

The listing first shows two Itanium processors that are running at 1 GHz, which is slower than the 1.5 GHz available at the time of this writing. cpuinfo contains a lot of useful information, such as the 1 GHz rating of the two processors. This is the system running Red Hat Advanced Server 2.1.

The second listing reveals a lot of information about the dinosaur CPU in my Linux system. (One of the great aspects of Linux is that it's efficient so you don't necessarily need the fastest CPU to get some work done.) This is the system running Red Hat 8.x.

You can also see the maximum number of open files the kernel will handle by viewing /proc/sys/fs/file-max. If you don't like the value as it is currently set, you can adjust it by using echo to supply a new value, as shown in the following example: first for our Integrity server and then for our IA-32 system:

 # cat /proc/sys/fs/file-max                          (On Integrity) 207408 # echo "400000" > /proc/sys/fs/file-max # cat /proc/sys/fs/file-max 400000 # # cat /proc/sys/fs/file-max                            (On IA-32) 9830 # echo "1024" > /proc/sys/fs/file-max 

There is a huge difference for the default value of these variables on the two systems. It is no surprise that the Advanced Server value is many times higher than the Red Hat 8.x value.

In the Integrity server example, you changed the value from a default of 207408 to 400000.

On the IA-32 system, you reduced the value. You first saw that file-max was set to 9830, which you changed to 1024. Always be careful when reducing a setting. Going from 9830 to 1024 maximum open files may not be a good idea.

The /proc file system provides an easy way to view and modify kernel parameters. It may be that an application that you're using requires minimum values for some kernel parameters, in which case, you'd use the technique shown to modify them. To see the number of files you currently have open, you can get an idea of how close you are to your limit. You can issue the following command to list the number on either of our two systems.

 # cat /proc/sys/fs/file-nr                              (On Integrity) 1374    950     40000 # cat /proc/sys/fs/file-nr                                 (On IA-32) 1520           134         1024 

This output shows the number of allocated, used, and maximum file handles. On the IA-32 system, the 1024 that you earlier set is shown as the maximum but there are 1520 allocated, which is already above our maximum. You can see that we have only 134 open files and that you are no where near the maximum number of open files at this time, but we reduced our maximum to a number below the current number allocated. Again, be careful when reducing the value of settings. The file /proc/sys/fs/file-nr is read-only because it shows the number of open files.

You can also get useful information about your swap device(s) in /proc. The following output shows the status of swap:

 # cat /proc/swaps                                   (On Integrity) Filename     Type          Size      Used    Priority /dev/sda2    partition     2040208   0       -1 # cat /proc/swaps                                    (On IA-32) Filename     Type         Size      Used     Priority /dev/hda7    partition    192740    656     -1 

You are using no swap of the two GB allocated on the Integrity server in the first output. On our IA-32 system, in the second output, you use a lot of available swap space. If the system were heavily used and swap was nearly all consumed, this would be an indication that you may need to increase swap space on the system.

The sysctl Command

The sysctl command is also used to work with kernel settings. sysctl is used to view and set settings in /proc/sys. Issuing sysctl -a produces an overview of configurable settings in /proc/sys as shown in the following abbreviated listings. The first listing shows the output on the Integrity server and the second listing the output on our IA-32 system.

 # sysctl -a                                                  (On Integrity) abi.fake_utsname = 0 abi.trace = 0 dev.raid.speed_limit_max = 10000 dev.raid.speed_limit_min = 100 dev.cdrom.check_media = 0 dev.cdrom.lock = 1 dev.cdrom.debug = 0 dev.cdrom.autoeject = 0 dev.cdrom.autoclose = 1 dev.cdrom.info = CD-ROM information, Id: cdrom.c 3.12 2000/10/18 dev.cdrom.info = dev.cdrom.info = drive name:            hda dev.cdrom.info = drive speed:           24 dev.cdrom.info = drive # of slots:      1 dev.cdrom.info = Can close tray:                1 dev.cdrom.info = Can open tray:         1 dev.cdrom.info = Can lock tray:         1 dev.cdrom.info = Can change speed:      1 dev.cdrom.info = Can select disk:       0 dev.cdrom.info = Can read multisession: 1 dev.cdrom.info = Can read MCN:          1 dev.cdrom.info = Reports media changed: 1 dev.cdrom.info = Can play audio:                1 dev.cdrom.info = Can write CD-R:                0 dev.cdrom.info = Can write CD-RW:       0 dev.cdrom.info = Can read DVD:          1 dev.cdrom.info = Can write DVD-R:       0 dev.cdrom.info = Can write DVD-RAM:     0 dev.cdrom.info = dev.cdrom.info = debug.rpmarch = debug.kerneltype = net.unix.max_dgram_qlen = 10 net.ipv4.conf.eth0.arp_filter = 0 net.ipv4.conf.eth0.tag = 0 net.ipv4.conf.eth0.log_martians = 0 net.ipv4.conf.eth0.bootp_relay = 0                    .                    .                    . net.core.divert_version = 0.46 net.core.hot_list_length = 128 net.core.optmem_max = 20480 net.core.message_burst = 50 net.core.message_cost = 5 net.core.mod_cong = 290 net.core.lo_cong = 100 net.core.no_cong = 20 net.core.no_cong_thresh = 20 net.core.netdev_max_backlog = 300 net.core.dev_weight = 64 net.core.rmem_default = 65535 net.core.wmem_default = 65535 net.core.rmem_max = 65535 net.core.wmem_max = 65535 vm.max-readahead = 127 vm.min-readahead = 3 vm.max_map_count = 65536 vm.page-cluster = 3 vm.pagetable_cache = 25 562 vm.kswapd = 512 32      8 vm.overcommit_memory = 0 vm.bdflush = 30 500     0       0       5120    30720   60      20      0 kernel.perfmon.fastctxsw = 0 kernel.perfmon.debug_ovfl = 0 kernel.perfmon.debug = 0 kernel.overflowgid = 65534 kernel.overflowuid = 65534 kernel.random.uuid = d6b7b7be-0286-4832-958b-945708388754 kernel.random.boot_id = 7d4a2307-b24f-4b35-b833-3dde320bda4c kernel.random.write_wakeup_threshold = 128 kernel.random.read_wakeup_threshold = 8 kernel.random.entropy_avail = 4096 kernel.random.poolsize = 512 kernel.threads-max = 8101 kernel.cad_pid = 1 kernel.sysrq = 0 kernel.sem = 250        32000   32      128 kernel.msgmnb = 16384 kernel.msgmni = 16 kernel.msgmax = 8192 kernel.shmmni = 4096 kernel.shmall = 524288 kernel.shmmax = 33554432 kernel.rtsig-max = 1024 kernel.rtsig-nr = 1 kernel.acct = 4 2       30 kernel.hotplug = /sbin/hotplug kernel.modprobe = /sbin/modprobe kernel.printk = 3       4       1       7 kernel.ctrl-alt-del = 0 kernel.real-root-dev = 256 kernel.cap-bound = -257 kernel.tainted = 0 kernel.core_uses_pid = 0 kernel.panic = 0 kernel.domainname = (none) kernel.hostname = m4415mxp kernel.version = #1 SMP Thu Oct 17 15:13:01 EDT 2002 kernel.osrelease = 2.4.18-e.12smp kernel.ostype = Linux fs.lease-break-time = 45 fs.dir-notify-enable = 1 fs.leases-enable = 1 fs.overflowgid = 65534 fs.overflowuid = 65534 fs.dentry-state = 9166  8491    45      0       0       0 fs.dquot-nr = 0 0 fs.file-max = 400000 fs.file-nr = 1374       960     400000 fs.inode-state = 5165   31      0       0       0       0       0 fs.inode-nr = 5165      31 # sysctl -a                                              (On IA-32) abi.fake_utsname = 0 abi.trace = 0 abi.defhandler_libcso = 68157441 abi.defhandler_lcall7 = 68157441 abi.defhandler_elf = 0 abi.defhandler_coff = 117440515 dev.cdrom.check_media = 0 dev.cdrom.lock = 1 dev.cdrom.debug = 0 dev.cdrom.autoeject = 0 dev.cdrom.autoclose = 1 dev.cdrom.info = CD-ROM information, Id: cdrom.c 3.12 2000/10/18 dev.cdrom.info = dev.cdrom.info = drive name: hdc dev.cdrom.info = drive speed: 32 dev.cdrom.info = drive # of slots: 1 dev.cdrom.info = Can close tray: 1 dev.cdrom.info = Can open tray: 1 dev.cdrom.info = Can lock tray: 1 dev.cdrom.info = Can change speed: 1 dev.cdrom.info = Can select disk: 0 dev.cdrom.info = Can read multisession: 1 dev.cdrom.info = Can read MCN: 1 dev.cdrom.info = Reports media changed: 1 dev.cdrom.info = Can play audio: 1 dev.cdrom.info = Can write CD-R: 0 dev.cdrom.info = Can write CD-RW: 0 dev.cdrom.info = Can read DVD: 0 dev.cdrom.info = Can write DVD-R: 0 dev.cdrom.info = Can write DVD-RAM: 0 dev.cdrom.info = dev.cdrom.info = dev.raid.speed_limit_max = 100000 dev.raid.speed_limit_min = 100 dev.rtc.max-user-freq = 64 debug.rpmarch = debug.kerneltype = net.unix.max_dgram_qlen = 10 net.token-ring.rif_timeout = 60000 net.ipv4.conf.eth0.arp_filter = 0 net.ipv4.conf.eth0.tag = 0 net.ipv4.conf.eth0.log_martians = 0 net.ipv4.conf.eth0.bootp_relay = 0 net.ipv4.conf.eth0.proxy_arp = 0 net.ipv4.conf.eth0.accept_source_route = 1 net.ipv4.conf.eth0.send_redirects = 1 net.ipv4.conf.eth0.rp_filter = 1                   .                   .                   . net.core.rmem_max = 65535 net.core.wmem_max = 65535 vm.max-readahead = 127 vm.min-readahead = 3 vm.max_map_count = 65536 vm.page-cluster = 3 vm.pagetable_cache = 2550 vm.kswapd = 512    328 vm.overcommit_memory = 0 vm.bdflush = 40    00050030006000 vm.freepages = 192 384576 kernel.overflowgid = 65534 kernel.overflowuid = 65534 kernel.random.uuid = 807f6e0c-dda4-475c-8130-d7821ba24069 kernel.random.boot_id = 20e67c64-b181-4d3e-af23-bbe84dececdb kernel.random.write_wakeup_threshold = 128 kernel.random.read_wakeup_threshold = 8 kernel.random.entropy_avail = 4096 kernel.random.poolsize = 512 kernel.threads-max = 1536 kernel.cad_pid = 1 kernel.sysrq = 0 kernel.sem = 250 3200032128 kernel.msgmnb = 16384 kernel.msgmni = 16 kernel.msgmax = 8192 kernel.shmmni = 4096 kernel.shmall = 2097152 kernel.shmmax = 33554432 kernel.rtsig-max = 1024 kernel.rtsig-nr = 2 kernel.acct = 4   230 kernel.hotplug = /sbin/hotplug kernel.modprobe = /sbin/modprobe kernel.printk = 6  417 kernel.ctrl-alt-del = 0 kernel.real-root-dev = 256 kernel.cap-bound = -257 kernel.tainted = 0 kernel.core_uses_pid = 1 kernel.panic = 0 kernel.domainname = (none) kernel.hostname = linuxdev kernel.version = #1 Thu Apr 18 07:37:53 EDT 2002 kernel.osrelease = 2.4.18-3 kernel.ostype = Linux fs.lease-break-time = 45 fs.dir-notify-enable = 1 fs.leases-enable = 1 fs.overflowgid = 65534 fs.overflowuid = 65534 fs.dentry-state = 2749197245000 fs.dquot-nr = 0   0 fs.file-max = 1024 fs.file-nr = 1520 1471024 fs.inode-state = 2180693700000 fs.inode-nr = 2180 6937 

These abbreviated listings have more settings than what are shown. sysctl can be used to both view and modify kernel settings. For more information about sysctl, see the sysctl and sysctl.conf man pages.

Changing IP Forwarding

Now that you have two ways to modify settings (using echo and sysctl), let's modify a parameter using both techniques. If you want to perform IP forwarding, you would set /proc/sys/net/ipv4/ip_forward to a 1 and if you don't you would set it to a 0. The following example uses cat to see what ip_forward is set to; using sysctl to set it to 0, and then using echo to set it back to 1:

 # cat /proc/sys/net/ipv4/ip_forward 1 # sysctl -w net.ipv4.ip_forward="0" net.ipv4.ip_forward = 0 # echo "1" > /proc/sys/net/ipv4/ip_forward # cat /proc/sys/net/ipv4/ip_forward 1 

This procedure is identical on both our Integrity and IA-32 systems.

There are far too many /proc entries to list in this book; however, Table 5-1 is a list of a few kernel parameters of interest. The table is divided between directories in which categories of configuration options.

Table 5-1. Sample of /proc Entries

File

Function

/proc

Process information for the virtual file system.

 

cpuinfo

Provides information about CPUs in the system.

 

modules

Provides information about modules in the system (same as lsmod).

 

version

Provides the current version number of the kernel and other detailed information.

/proc/sys/fs

Contains file system information.

 

file-max

Defines the maximum number of open files per process.

 

inode-max

Present number of inodes.

/proc/sys/kernel

Contains kernel information.

 

shmmax

Defines the maximum shared memory size.

 

shmmni

Defines the maximum number of shared memory segments system wide.

 

hostname

System hostname.

 

ctrl-alt-del

Specifies whether system will reboot on ctrl-alt-del key sequence.

/proc/sys/net/ipv4

Contains network information.

 

ip_forward

Defines whether or not packets will be forwarded between network interfaces.

 

icmp_echo_ignore_all

Defines whether or not ICMP pints are ignored.

 

ip_local_port_range

Defines range of ports used when originating a connection.


     < Day Day Up > 


    Linux on HP Integrity Servers. A System Administrator's Guide
    Linux on HP Integrity Servers: A System Administrators Guide
    ISBN: 0131400002
    EAN: 2147483647
    Year: 2004
    Pages: 100

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net