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
In the previous article, we learned about the pas...
Table of contents 1. Introduction to platform bus...
When I first taught myself web development, there...
Anyone who has used Windows Remote Desktop to con...
concept If the index contains all the data that m...
1. Introduction to TypeScript The previous articl...
The powerful tool cgroup in the kernel can not on...
This article uses examples to describe common bas...
In the Linux system, there is a kind of file call...
Preface When scroll events such as scroll and res...
Without further ado, let's take a look at the...
How to shorten the page rendering time on the bro...
This article shares the specific code for JavaScr...
React Native can develop iOS and Android native a...