Virtual Memory Management for Linux System Performance Test

  

Virtual Memory Management is the most complex part of the Linux kernel. It may take a whole book to understand this part of the content. VPSee here only introduces two kernel processes related to performance monitoring: kswapd and pdflush.

1, kswapd daemon is used to check pages_high and pages_low. If the available memory is less than pages_low, kswapd starts scanning and tries to release 32 pages, and repeats the process of scanning release until the available memory is greater than pages_high. Check 3 things when scanning: 1) If the page is not modified, put the page into the available memory list; 2) If the page is modified by the file system, write the page content to disk; 3) If the page is modified, but Not modified by the file system, write the page to the swap space.

2, pdflush daemon is used to synchronize the memory page related to the file, and synchronize the memory page to the hard disk in time. For example, open a file, the file is imported into the memory, after the file is modified and saved, the kernel does not immediately save the file to the hard disk, pdflush decides when to write the corresponding page to the hard disk, which is a kernel parameter vm. Dirty_background_ratio to control, for example, the following parameters show that dirty pages (dirty pages) start writing to the hard disk when 10% of all memory pages are reached. # /sbin/sysctl -n vm.dirty_background_ratio

10

vmstat

Continue vmstat Introduction to some parameters, previous Linux performance monitoring: CPU introduced part of vmstat Parameters, here are the other parts. The following data comes from a 256MB RAM of VPSee, Xen VPS of 512MB SWAP:

# vmstat 1

procs ———–memory———- —swap– —–io—- –system– —–cpu——

rb swpd free buff cache si so bi bo in cs us sy id wa st

0 3 252696 2432 268 7148 3604 2368 3608 2372 288 288 0 0 21 78 1

0 2 253484 2216 228 7104 5368 2976 5372 3036 930 519 0 0 0 100 0

0 1 259252 2616 128 6148 19784 18712 19784 18712 3821 1853 0 1 3 95 1

1 2 260008 2188 144 6824 11824 2584 12664 2584 1347 1174 14 0 0 86 0

2 1 262140 2964 128 5852 24912 17304 24952 17304 4737 2341 86 10 0 0 4

swpd, the size of the SWAP space used, in KB; free, the available physical memory size, in KB; buff, the physical memory used to buffer the buffer size of the read and write operations , KB is the unit; cache, the size of the cache used by the physical memory to cache the process address space, in kilobytes; si, the data is read from the SWAP to the RAM. The size of swap in), in kilobytes; so, the size of data written from RAM to SWAP (swap out), in KB; bi, the size of disk blocks read from file system or SWAP to RAM (blocks in), block The unit; bo, the size of the disk block written from RAM to the file system or SWAP (blocks out), block is the unit; above is an example of frequent read and write swap areas, you can observe the following:

1, physical free memory free basically no significant changes, swapd gradually increased, indicating that the minimum available memory is always maintained at 256MB X 10% = 2.56MB or so, when the dirty page reaches 10% (vm.dirty_background_ratio = 10), a large number Use swap; 2, buff steadily reduce the description system knows that the memory is not enough, kwapd is borrowing part of the memory from the buff; 3, kswapd continues to write dirty pages to the swap area (so), and it is clear from the increase in swapd. According to the above. The three things that kswapd checks when scanning, if the page is modified, but not modified by the file system, write the page to swap, so swapd continues to increase here.

Copyright © Windows knowledge All Rights Reserved