Fundamentals 11 min read

Understanding Linux Memory Architecture: Physical, Virtual, and Management

This article explains Linux's memory architecture, covering physical and virtual memory differences between 32‑bit and 64‑bit systems, memory zones, the buddy allocator, page reclamation, and swap handling, providing essential knowledge for performance tuning and system optimization.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Understanding Linux Memory Architecture: Physical, Virtual, and Management

1.2 Linux Memory Architecture

To run a process, the Linux kernel allocates a memory region that the process uses as its workspace, similar to assigning a desk for paperwork, but the kernel must manage memory dynamically because the number of processes can reach tens of thousands while physical memory is limited.

1.2.1 Physical and Virtual Memory

Choosing between 32‑bit and 64‑bit systems matters for enterprise customers because only 64‑bit kernels can address memory beyond 4 GB. Understanding how the Linux kernel maps physical memory to virtual addresses is crucial for performance.

On 32‑bit architectures such as IA‑32, the kernel can directly access only the first 1 GB of physical memory (about 896 MB usable). Memory above ZONE_NORMAL must be mapped into the high‑memory area ( ZONE_HIGHMEM ), which is transparent to applications but incurs a slight performance penalty.

On 64‑bit architectures like x86‑64 (x64) or IA‑64, ZONE_HIGHMEM can extend to 64 GB or 128 GB respectively, eliminating the mapping overhead between high‑memory and normal zones.

Virtual Memory Address Layout

Figure 1‑11 shows the virtual address layout for 32‑bit and 64‑bit architectures. In a 32‑bit system, a process can access up to 4 GB of address space, typically split into 3 GB user space and 1 GB kernel space. In 64‑bit systems, this limitation disappears, giving each process a vastly larger address space.

1.2.2 Virtual Memory Management

The physical memory architecture is invisible to applications because the OS maps all physical memory into virtual memory. When a process requests memory, it receives a virtual mapping that may be backed by RAM, cache, or swap on disk.

Figure 1‑12 illustrates that applications usually write to cache or buffers; the kernel thread pdflush writes this data to disk when the buffer is full or the thread is idle.

Linux allocates all free memory as disk cache, so systems with large RAM often show very little free memory. Swap usage does not necessarily indicate a memory bottleneck; it demonstrates Linux's efficient resource management.

Page Frame Allocation

A page is a contiguous block of physical or virtual memory, typically 4 KB. The kernel allocates pages to processes on demand; if insufficient free pages exist, it reclaims pages from other processes or the page cache.

Buddy System

The kernel uses the buddy system to manage free pages, trying to keep memory regions contiguous and avoid fragmentation. When page allocation fails, the page reclamation process is triggered.

You can inspect the buddy system via /proc/buddyinfo.

Page Frame Reclamation

When a process requests pages that are not immediately available, the kernel attempts to free pages that are no longer in active use. The kswapd thread and the function try_to_free_page() handle this reclamation.

Use vmstat -a to see which pages are active or inactive.

kswapd follows a least‑recently‑used (LRU) algorithm, moving pages from the active list to the inactive list before freeing them. It prefers to reclaim page cache rather than paging out process memory.

Page Out vs. Swap Out

"Page out" moves individual pages to the swap area, while "swap out" moves an entire address space. The two terms are sometimes used interchangeably.

Performance impact depends on which pages are reclaimed; you can tune the behavior with /proc/sys/vm/swappiness.

Swap

When a reclaimed page belongs to a process address space, it is moved to swap. This does not indicate a problem; Linux efficiently uses swap space, and seeing 50 % swap usage on a well‑configured system is normal.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Memory Managementperformance tuningLinuxVirtual MemoryOperating System
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.