Linux memory management
2013-11-29 09:38
351 查看
The first covers the implementation of the mmap system call, which allows the
mapping of device memory directly into a user process’s address space. Not all
devices require mmap support, but, for some, mapping device memory can yield
significant performance improvements.
We then look at crossing the boundary from the other direction with a discussion
of direct access to user-space pages. Relatively few drivers need this capability;
in many cases, the kernel performs this sort of mapping without the driver
even being aware of it. But an awareness of how to map user-space memory into
the kernel (with get_user_pages) can be useful.
The final section covers direct memory access (DMA) I/O operations, which provide
peripherals with direct access to system memory.
Of course, all of these techniques require an understanding of how Linux memory
management works, so we start with an overview of that subsystem.
Kernel logical addresses
These make up the normal address space of the kernel. These addresses map
some portion (perhaps all) of main memory and are often treated as if they were
physical addresses. On most architectures, logical addresses and their associated
physical addresses differ only by a constant offset. Logical addresses use the
hardware’s native pointer size and, therefore, may be unable to address all of
physical memory on heavily equipped 32-bit systems. Logical addresses are usually
stored in variables of type unsigned long or void *. Memory returned from
kmalloc has a kernel logical address.
Kernel virtual addresses
Kernel virtual addresses are similar to logical addresses in that they are a mapping
from a kernel-space address to a physical address. Kernel virtual addresses
do not necessarily have the linear, one-to-one mapping to physical addresses that
characterize the logical address space, however. All logical addresses are kernel
virtual addresses, but many kernel virtual addresses are not logical addresses.
For example, memory allocated by vmalloc has a virtual address (but no direct
physical mapping). The kmap function (described later in this chapter) also
returns virtual addresses. Virtual addresses are usually stored in pointer variables.
If you have a logical address, the macro __pa( ) (defined in <asm/page.h>) returns its
associated physical address. Physical addresses can be mapped back to logical
addresses with __va( ), but only for low-memory pages.
mapping of device memory directly into a user process’s address space. Not all
devices require mmap support, but, for some, mapping device memory can yield
significant performance improvements.
We then look at crossing the boundary from the other direction with a discussion
of direct access to user-space pages. Relatively few drivers need this capability;
in many cases, the kernel performs this sort of mapping without the driver
even being aware of it. But an awareness of how to map user-space memory into
the kernel (with get_user_pages) can be useful.
The final section covers direct memory access (DMA) I/O operations, which provide
peripherals with direct access to system memory.
Of course, all of these techniques require an understanding of how Linux memory
management works, so we start with an overview of that subsystem.
Kernel logical addresses
These make up the normal address space of the kernel. These addresses map
some portion (perhaps all) of main memory and are often treated as if they were
physical addresses. On most architectures, logical addresses and their associated
physical addresses differ only by a constant offset. Logical addresses use the
hardware’s native pointer size and, therefore, may be unable to address all of
physical memory on heavily equipped 32-bit systems. Logical addresses are usually
stored in variables of type unsigned long or void *. Memory returned from
kmalloc has a kernel logical address.
Kernel virtual addresses
Kernel virtual addresses are similar to logical addresses in that they are a mapping
from a kernel-space address to a physical address. Kernel virtual addresses
do not necessarily have the linear, one-to-one mapping to physical addresses that
characterize the logical address space, however. All logical addresses are kernel
virtual addresses, but many kernel virtual addresses are not logical addresses.
For example, memory allocated by vmalloc has a virtual address (but no direct
physical mapping). The kmap function (described later in this chapter) also
returns virtual addresses. Virtual addresses are usually stored in pointer variables.
If you have a logical address, the macro __pa( ) (defined in <asm/page.h>) returns its
associated physical address. Physical addresses can be mapped back to logical
addresses with __va( ), but only for low-memory pages.
相关文章推荐
- 【简记】Operating System—— memory management in Linux(暂)
- Linux Kernel Memory Management (1)
- understanding the linux virtual memory management 图序
- Linux Memory Management Notes
- Good material for understanding linux memory management
- linux-kernel-map,linux-memory-management,Linux-storage-stack三幅很好的图
- Linux memory management,内核高端内存及各Zone介绍
- Optimizing Linux Memory Management for Low-latency / High-throughput Databases
- User-Level Memory Management in Linux Programming转
- Linux Kernel Memory Management (2)
- Linux Memory Management – Virtual Memory and Demand Paging
- Linux kernel memory management (ARM)
- FAQ Linux Memory Management
- Memory Management Links
- Virtual memory management
- MIT:Introduction to C Memory Management and C++ Object-Oriented Programming
- Automatic Memory Management
- Linux System Management and Package Management
- Linux Device Drivers 3rd Edition Allocating Memory
- linux cpu/memory检测