Skip to main content

Linux Virtual Memory Introduction

Virtual memory management is one of the most complicated functions of an operating system kernel, and together with process scheduling accounts for the majority of its function and performance. Over a series of posts I intend to break down how Linux manages this highly complicated topic into a format that will be digestible and relevant to both system administrators and program developers.

So What is it? Virtual Memory is at its most basic an abstraction that decouples a process's memory addressing from the system's physical memory addresses. In English, that means that a memory address that a process uses (virtual memory address,) will be translated by the operating system into an address for system RAM (physical memory address.) This abstraction allows for many useful features, most important of which is that multiple processes running simultaneously will each have their own virtual memory space, independent from each other.

The specific implementation details for virtual memory varies by hardware architecture (for instance, x86, ARM, SPARC, Power, etc,) due to differences in their hardware Memory Managment Unit (MMU, the piece that controlls physical memory and the mapping to virtual), but works similar enough that we can consider the theory without need to concern over specifics. For this series I will be looking at the x86-64 architecture specifically since the x86 line is where Linux began, and is what most people will be using at home or at work, and the 64 bit extension first implemented in hardware in 2003 is what systems built after that will be using. I will try and call out when details differ, but for the most part if there exists a difference it will mostly be taken care of in very low level kernel structures that are abstracted away well before the system API layer.

Note that the terms "Physical RAM", "Physical Memory", "Main Memory", "System RAM" and "System Memory" will be used interchangeably. While "Memory" and "RAM" are not technically synonymous, the context in which the terms are used will refer to the same piece of hardware; volatile memory connected to the CPU's MMU.

Next in series : Paging pt.1