linux 1. What is SWAP$ swapon -s Filename Type Size Used Priority /swap.img file 2097148 0 -2 Functionally, the swap partition is mainly used to swap part of the data in the memory to the swap space when the memory is insufficient, so that the system will not cause OOM or more fatal situations due to insufficient memory. Therefore, when there is pressure on memory usage and memory recycling begins to be triggered, swap space may be used. 2. What does swappiness adjust? The file $ cat /proc/sys/vm/swappiness 60 $ sysctl -q vm.swappiness vm.swappiness = 60 $ sysctl vm.swappiness=10 $ sysctl -q vm.swappiness vm.swappiness = 10 Persistent Operations $ vim /etc/sysctl.conf vm.swappiness=10 #To the last line, restart is required to take effect Defines how aggressively the kernel uses swap:
3. When will the swap operation be performed?There are two memory recycling mechanisms: kswapd cycle checking and direct memory recycling. When the requested memory is greater than the remaining memory, direct recycling will be triggered. So what are the conditions that trigger recycling during the kswapd process periodic check? From a design perspective, the kswapd process needs to periodically check the memory and start memory recycling when a certain threshold is reached. This so-called threshold can be understood as the current memory usage pressure. That is, although we still have remaining memory, when the remaining memory is relatively small, that is, when the memory pressure is high, we should start trying to reclaim some memory. This can ensure that the system has enough memory as much as possible for sudden memory requests. Kswapd decides whether to start reclaiming memory based on the memory water level mark. If the mark reaches low, it starts reclaiming until the remaining memory reaches high. View the current system memory watermark 4. Priority of swap partitionYou can use the -p parameter to specify the priority of the swap space. The larger the value, the higher the priority. The range of numbers that can be specified is from -1 to 32767. $ swapoff /dev/sdc1; swapon -p 0 /dev/sdc1 $ swapon -s Filename Type Size Used Priority /dev/sdc1 file 2097148 0 0 $ cat /proc/swaps Filename Type Size Used Priority /dev/sdc1 file 2097148 0 0 Put an entry in /dev/sdc1 swap swap pri=0 0 0 5. Start and stop swap$ swapoff -a stop $ swapon -a start 6. Create swap spaceCreate swap file dd if=/dev/sda3 of=./swapfile bs=1M count=1G mkswap ./swapfile Enable swap file $ swapon swapfile $ swapon -s Filename Type Size Used Priority /swap.img file 2097148 3340 0 /mnt/swapfile file 6388156 0 -2 Turn off swap space $ swapoff swapfile $ swapon -s Filename Type Size Used Priority /swap.img file 2097148 3156 0 The above is the detailed content of Linux swap partition (detailed explanation). For more information about Linux swap partition, please pay attention to other related articles on 123WORDPRESS.COM! , I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Div picture marquee seamless connection implementation code
>>: Solve the matching problem in CSS
MultiTail is a software used to monitor multiple ...
1. Slow query due to lack of index or invalid ind...
Table of contents Preface 1. The effect is as sho...
1. What is floating? Floating, as the name sugges...
Table of contents join algorithm The difference b...
History always repeats itself surprisingly well. ...
Table of contents Preface 1. 404 Page 1. Causes 2...
This article shares the specific code of js to im...
Table of contents Makefile Makefile naming and ru...
Introduction to border properties border property...
Preface: When we are making web pages, we often n...
Table of contents 1. Add packaging command 2. Run...
B-tree is a common data structure. Along with him...
1 Download and prepare First, we need to download...
Nginx's shared memory is one of the main reas...