Summary of Linux storage management

When it comes to storage management, we have to mention virtual memory technology. Virtual memory technology makes the memory space required by processes competing for limited physical memory in the system to be satisfied. But it doesn't make much sense for the operating system itself to run in virtual memory. It would be a disgusting solution if the OS was forced to maintain its own page tables. The Linux kernel runs directly on the physical address space.

Features: huge addressing space, memory mapping, fair physical memory allocation and shared virtual memory.

Linux uses demand paging to load the executable image into the virtual memory of the process. When the command is executed, the executable command file is opened and its contents are mapped into the virtual memory of the process. These operations are accomplished by modifying the data structures that describe the memory image of the process, a process called memory mapping. However only the initial part of the image is loaded into physical memory, the rest remains on disk. When the image executes, it generates a page fault, so Linux will decide which parts of the disk to bring into memory to continue execution.

Memory swapping. If a process needs to transfer a virtual page into physical memory and there are no free physical pages in the system, the operating system must discard some pages located in physical memory to make room for it. If the pages discarded from physical memory are from executable or data files on disk and have not been modified, there is no need to save those pages. When the process needs this page again, it is read directly from the executable file or data file. But if the page has been modified, the operating system must preserve the contents of the page for revisiting, which is called a dirty page. Page aging algorithm to fairly select pages to be discarded from the system.

Cache, Linux uses a number of cache-related memory management strategies.

Buffer Cache, which contains data buffers used by block device drivers; Page Cache, is used to speed up access to executable image files and data files on the hard disk; Swap Cache, only modified pages are stored in the swap file. As long as these pages are not modified after being written to the swap file, the next time the page is swapped out of memory, there is no need to perform an update write operation, and these pages can simply be discarded. In systems where swapping occurs frequently, SwapCache can save a lot of unnecessary and time-consuming disk operations; Hardware Caches.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327009827&siteId=291194637