Memory Management Lca2006
Memory Management Lca2006
Linux.conf.au 2006
2005IBMCorporation
IBMLinuxTechnologyCenter
Outline
Current Linux/K42 memory management Fragmentation problems Proposed system K42 Architecture/Implementation Experiment results Future work
2005IBMCorporation
IBMLinuxTechnologyCenter
4Kbytes
2005IBMCorporation
IBMLinuxTechnologyCenter
Virtual memory
Virtual to physical mapping must be very fast
Hardware
support
TLB
2005IBMCorporation
IBMLinuxTechnologyCenter
Causes of fragmentation
Page allocation
Memory
2005IBMCorporation
IBMLinuxTechnologyCenter
Fragmentation
Process B starts
Process C starts
2005IBMCorporation
IBMLinuxTechnologyCenter
Fragmentation
Process B exits
Minimal fragmentation
2005IBMCorporation
IBMLinuxTechnologyCenter
One solution
Reserved
Fixed size
Balancing pools
2005IBMCorporation
IBMLinuxTechnologyCenter
zones
user reclaimable kernel reclaimable kernel non reclaimable
Fall-back Copy
fragmented
IBMLinuxTechnologyCenter
Proposed system
Allocation of memory in chunks
Chunks
allocation for process done from chunk when exhausted another chunk allocated
Chunks
2005IBMCorporation
IBMLinuxTechnologyCenter
Chunk allocation
2005IBMCorporation
IBMLinuxTechnologyCenter
Chunk Allocation
2005IBMCorporation
IBMLinuxTechnologyCenter
Chunk Allocation
2005IBMCorporation
IBMLinuxTechnologyCenter
Chunk Allocation
2005IBMCorporation
IBMLinuxTechnologyCenter
Chunk Allocation
2005IBMCorporation
IBMLinuxTechnologyCenter
Chunk Allocation
2005IBMCorporation
IBMLinuxTechnologyCenter
Chunk Allocation
2005IBMCorporation
IBMLinuxTechnologyCenter
Chunk Allocation
2005IBMCorporation
IBMLinuxTechnologyCenter
Chunk Allocation
2005IBMCorporation
IBMLinuxTechnologyCenter
Pros/Cons
Advantages
Naturally Naturally Cache No Operate Increase don't
Disadvantages
maybe doesn't matter on PPC (dcbz)
2005IBMCorporation
IBMLinuxTechnologyCenter
What is K42
Open source research kernel (64 bit, cache coherent
systems)
Focus on performance, scalability, customizability, Supports Linux API/ABI Uses Linux device drivers, filesystems, ... Userspace servers (NFS, socket, pipe server)
Application
maintainability
level libraries
2005IBMCorporation
IBMLinuxTechnologyCenter
Why K42?
Designed for experimentation/prototyping
OO
design easy to add alternative implementations Linux API/ABI (64-bit PowerPC) occurs through per process object
Supports Has
Allocation
2005IBMCorporation
IBMLinuxTechnologyCenter
2005IBMCorporation
IBMLinuxTechnologyCenter
allocations page allocator, root rep, pmleaf freeing through same places doesn't have to be from original object
2005IBMCorporation
IBMLinuxTechnologyCenter
Implementation in K42
Page Descriptor Array (PDA) Header
Page
Bitmap
PDA header and chunk allocated separately allocPage returns address and pointer to PDA
Page
descriptors have a field added to store PDA pointer removed frees done directly to PDA
deallocPage
IBMLinuxTechnologyCenter
2005IBMCorporation
IBMLinuxTechnologyCenter
Experimental results
Very preliminary
Implementation Still
debugging/optimising
2005IBMCorporation
IBMLinuxTechnologyCenter
Performance results
Performance
SDET
some
2005IBMCorporation
IBMLinuxTechnologyCenter
Fragmentation definition
Definition of fragmentation
Measure For For
a given page size, calculate number of pages that you a given page size, calculate number of pages you can
2005IBMCorporation
IBMLinuxTechnologyCenter
Example
3 x 8kb pages
2 x 8kb pages
fragmentation
2005IBMCorporation
IBMLinuxTechnologyCenter
Fragmentation results
Test load
Long
lived processes
small allocations/deallocations
Simple simulation of web server Modified kernel to dump bitmap of all pages in memory
marking free/used state
2005IBMCorporation
IBMLinuxTechnologyCenter
Fragmentation results
Table of fragmentation vs page size Reduced fragmentation for page size <= chunk size Increased fragmentation for page size > chunk size
PageSize(kb) 4 8 16 32 64 128 256 512 Fragmentation% Normal 0 1.3 3.5 7.3 11.8 16.1 17 17.3 Fragmentation PDA(256kb) 0 0.4 1 1.3 1.6 2.1 2.9 64
2005IBMCorporation
IBMLinuxTechnologyCenter
Future work #1
Further debugging/optimisations
SMP
2005IBMCorporation
IBMLinuxTechnologyCenter
Future work #2
Variable sized chunks
tailor
PDAs passed through to FCMs File allocations grouped (PMLeaf equivalent) Reverse mapping in PDAs to point to FCMs
paging/defragmentation
2005IBMCorporation
IBMLinuxTechnologyCenter
Legal Statement
This work represents the view of the author and does not necessarily represent the view of IBM. PowerPC is a registered trademarks of International Business Machines Corporation in the United States, other countries, or both.
Linux is a registered trademark of Linus Torvalds. Other company, product and service names may be trademarks or service marks of others.
2005IBMCorporation