Presentation is loading. Please wait.

Presentation is loading. Please wait.

Liu Meihua Chapter 3 Memory management Chapter 3 Memory management —— 3.5 Kernel Memory.

Similar presentations


Presentation on theme: "Liu Meihua Chapter 3 Memory management Chapter 3 Memory management —— 3.5 Kernel Memory."— Presentation transcript:

1 Liu Meihua Chapter 3 Memory management Chapter 3 Memory management —— 3.5 Kernel Memory

2 2 Outline  Kernel virtual memory layout  Kernel memory slab allocator

3 Kernel virtual memory layout  The Kernel uses virtual memory.  The Kernel uses the memory management unit(MMU) to translate its virtual memory addresses into physical pages.  The Kernel has its own address space and corresponding virtual memory layout.  Most of the kernel ’ s memory is nonpageable.  Kernel memory consists of a variety of mappings.  Nonpageable kernel memory is mapped with the segkmem kernel segment driver. Pageable kernel memory is mapped with the segkp segment driver.

4 Kernel virtual memory layout  Kernel Address Space  The Kernel Text and Data Segments  Virtual Memory Data Structures  Loadable kernel Module Text and Data  The Kernel Address Space and Segments

5 5 Kernel Address Space  It contains the following major mappings:  The kernel text and data (mappings of the kernel binary)  The kernel map space (data structures, caches, etc.)  A 32-bit kernel map, for module text and data (64-bit kernels only)  The trap table  Critical virtual memory data structures (TSB, etc.)  A place for mapping the file system cache (segmap)

6 6  Solari s Bit Virtual Addres s Space

7 7  The text segments contain the instructions  The data segments contains the initialized variables from the kernel/unix image file.  They are mapped into the kernel address space by the Open Boot PROM The Kernel Text and Data Segments

8 8 Virtual Memory Data Structures

9 9 Loadable Kernel Module Text and Data

10 10 Loadable Kernel Module Text and Data  Looking at the module load address with the modinfo command

11 11  Solaris does allow some portions of the kernel to be allocated from pageable memory.  Pageable memory is restricted to those structures that are not required by the kernel when the process is swapped out:  Lightweight process stacks  The TNF Trace buffers  Special pages, such as the page of memory that is shared between user and kernel for scheduler preemption control  Pageable memory is allocated and swapped by the seg_kp segment. Loadable Kernel Module Text and Data

12 12 The Kernel Address Space and Segments

13 13 The Kernel Address Space and Segments  The full list of segment drivers the kernel uses to create and manage kernel mappings is shown in following table.

14 14 Outline  Kernel virtual memory layout  Kernel memory slab allocator

15 The Kernel Memory Slab Allocator  Slab Allocator Overview  Object Caching  Slab Allocator Implementation  The CPU Layer  The Depot Layer  The Global (Slab) Layer The slab allocator: the general-purpose memory allocator.

16 16 Slab Allocator Overview  The slab allocator consumes large slabs of memory and then allocates smaller requests with portions of each slab.  Use the slab allocator for memory requests that are:  Smaller than a page size  Not an even multiple of a page size  Frequently going to be allocated and freed, so would otherwise fragment the kernel map

17 17 Slab Allocator Overview  Performance comparison of the slab allocator.

18 18  The slab allocator uses the following terms:  object to describe a single memory allocation unit  cache to refer to a pool of like objects  slab to refer to a group of objects that reside within the cache  Each object type has one cache, which is constructed from one or more slabs. Slab Allocator Overview

19 19  Objects, Caches, Slabs, and Pages of Memory

20 20 Object Caching  The allocator tries to defer most of the real work associated with allocation and deallocation until it is really necessary, by keeping the objects alive until memory needs to be returned to the back end.

21 21 Slab Allocator Implementation

22 22 The CPU Layer  The CPU layer caches groups of objects to minimize the number of times that an allocation will need to go down to the lower layers.

23 23 The Depot Layer  The depot layer assembles groups of objects into magazines. Unlike a slab, a magazine ’ s objects are not necessarily allocated from contiguous memory; rather, a magazine contains a series of pointers to objects within slabs.

24 24 The Global (Slab) Layer  The global slab layer allocates slabs of objects from contiguous pages of physical memory and hands them up to the magazine layer for allocation. The global slab layer is used only when the upper layers need to allocate or deallocate entire slabs of objects to refill their magazines.

25 25 End


Download ppt "Liu Meihua Chapter 3 Memory management Chapter 3 Memory management —— 3.5 Kernel Memory."

Similar presentations


Ads by Google