SlideShare a Scribd company logo
Submit Search
Upload
Login
Signup
Linux Memory Management
Report
Anil Kumar Pugalia
Follow
Linux Geek and Open Source Hardware & Software Freak, Corporate Trainer, Entrepreneur in Automation
Oct. 3, 2010
•
0 likes
•
27,535 views
1
of
15
Linux Memory Management
Oct. 3, 2010
•
0 likes
•
27,535 views
Report
Technology
Anil Kumar Pugalia
Follow
Linux Geek and Open Source Hardware & Software Freak, Corporate Trainer, Entrepreneur in Automation
Recommended
Memory management in Linux
Raghu Udiyar
46.1K views
•
27 slides
Memory management in linux
Dr. C.V. Suresh Babu
5.1K views
•
16 slides
Linux kernel
Mahmoud Shiri Varamini
2.5K views
•
46 slides
Linux Memory Management
Suvendu Kumar Dash
2.1K views
•
32 slides
Linux kernel architecture
SHAJANA BASHEER
4.3K views
•
32 slides
Linux Internals - Part II
Emertxe Information Technologies Pvt Ltd
3.9K views
•
76 slides
More Related Content
What's hot
Linux Internals - Interview essentials - 1.0
Emertxe Information Technologies Pvt Ltd
2.6K views
•
11 slides
Kernel (OS)
عطاءالمنعم اثیل شیخ
22.9K views
•
22 slides
Basic Linux Internals
mukul bhardwaj
41.2K views
•
333 slides
Linux
Gouthaman V
1.7K views
•
122 slides
Linux kernel Architecture and Properties
Sadiqur Rahman
2.2K views
•
16 slides
Linux Programming
Emertxe Information Technologies Pvt Ltd
4.5K views
•
136 slides
What's hot
(20)
Linux Internals - Interview essentials - 1.0
Emertxe Information Technologies Pvt Ltd
•
2.6K views
Kernel (OS)
عطاءالمنعم اثیل شیخ
•
22.9K views
Basic Linux Internals
mukul bhardwaj
•
41.2K views
Linux
Gouthaman V
•
1.7K views
Linux kernel Architecture and Properties
Sadiqur Rahman
•
2.2K views
Linux Programming
Emertxe Information Technologies Pvt Ltd
•
4.5K views
Storage Virtualization
rjain51
•
5.7K views
Continguous Memory Allocator in the Linux Kernel
Kernel TLV
•
12.1K views
Processes in unix
miau_max
•
8.4K views
Transparent Hugepages in RHEL 6
Raghu Udiyar
•
19.3K views
Linux Internals - Kernel/Core
Shay Cohen
•
1.4K views
Linux file system
Midaga Mengistu
•
502 views
BusyBox for Embedded Linux
Emertxe Information Technologies Pvt Ltd
•
1.8K views
Linux introduction
Md. Zahid Hossain Shoeb
•
16.2K views
Linux ppt
lincy21
•
40.9K views
operating system structure
Waseem Ud Din Farooqui
•
48.4K views
An Introduction to Linux
anandvaidya
•
24.3K views
Linux Initialization Process (2)
shimosawa
•
6.8K views
Linux file system
Md. Tanvir Hossain
•
8.8K views
Process' Virtual Address Space in GNU/Linux
Varun Mahajan
•
11.1K views
Similar to Linux Memory Management
Linux Kernel Overview
Anil Kumar Pugalia
26.6K views
•
20 slides
File System Modules
Anil Kumar Pugalia
20.7K views
•
37 slides
Block Drivers
Anil Kumar Pugalia
38.2K views
•
21 slides
IT109 Microsoft Windows 7 Operating Systems Unit 01
blusmurfydot1
854 views
•
35 slides
Introduction to Linux
Anil Kumar Pugalia
4K views
•
33 slides
Memory Management in Android
Opersys inc.
937 views
•
30 slides
Similar to Linux Memory Management
(20)
Linux Kernel Overview
Anil Kumar Pugalia
•
26.6K views
File System Modules
Anil Kumar Pugalia
•
20.7K views
Block Drivers
Anil Kumar Pugalia
•
38.2K views
IT109 Microsoft Windows 7 Operating Systems Unit 01
blusmurfydot1
•
854 views
Introduction to Linux
Anil Kumar Pugalia
•
4K views
Memory Management in Android
Opersys inc.
•
937 views
File System Modules
Anil Kumar Pugalia
•
25K views
Introduction to Linux
Anil Kumar Pugalia
•
11.2K views
Operating Systems
We Learn - A Continuous Learning Forum from Welingkar's Distance Learning Program.
•
391 views
Embedded Software Design
Anil Kumar Pugalia
•
6.9K views
Memory Management in Android
Opersys inc.
•
1.3K views
Memory Management in Android
Opersys inc.
•
1.9K views
Oct2009
guest81ab2b4
•
323 views
Evolution of the Windows Kernel Architecture, by Dave Probert
yang
•
3.3K views
2337610
hantfhan
•
411 views
Embedded Linux
Quotient Technology Inc.
•
5.4K views
System Calls
Anil Kumar Pugalia
•
9.7K views
Principles of operating system
Anil Dharmapuri
•
5.7K views
Memory Management in Android
Opersys inc.
•
973 views
Low-level Accesses
Anil Kumar Pugalia
•
25.1K views
More from Anil Kumar Pugalia
Kernel Debugging & Profiling
Anil Kumar Pugalia
5.9K views
•
14 slides
Processes
Anil Kumar Pugalia
7K views
•
33 slides
System Calls
Anil Kumar Pugalia
4.1K views
•
17 slides
Embedded C
Anil Kumar Pugalia
25.6K views
•
20 slides
Playing with R L C Circuits
Anil Kumar Pugalia
2.8K views
•
17 slides
Audio Drivers
Anil Kumar Pugalia
20.6K views
•
11 slides
More from Anil Kumar Pugalia
(20)
Kernel Debugging & Profiling
Anil Kumar Pugalia
•
5.9K views
Processes
Anil Kumar Pugalia
•
7K views
System Calls
Anil Kumar Pugalia
•
4.1K views
Embedded C
Anil Kumar Pugalia
•
25.6K views
Playing with R L C Circuits
Anil Kumar Pugalia
•
2.8K views
Audio Drivers
Anil Kumar Pugalia
•
20.6K views
Video Drivers
Anil Kumar Pugalia
•
23.2K views
Mobile Hacking using Linux Drivers
Anil Kumar Pugalia
•
6K views
Shell Scripting
Anil Kumar Pugalia
•
6.2K views
References
Anil Kumar Pugalia
•
21.7K views
Functional Programming with LISP
Anil Kumar Pugalia
•
6.1K views
Power of vi
Anil Kumar Pugalia
•
3K views
gcc and friends
Anil Kumar Pugalia
•
14.2K views
"make" system
Anil Kumar Pugalia
•
4.2K views
Hardware Design for Software Hackers
Anil Kumar Pugalia
•
1.7K views
RPM Building
Anil Kumar Pugalia
•
4K views
Linux User Space Debugging & Profiling
Anil Kumar Pugalia
•
6.5K views
Linux Network Management
Anil Kumar Pugalia
•
11.2K views
Timers
Anil Kumar Pugalia
•
6.5K views
Threads
Anil Kumar Pugalia
•
10.2K views
Recently uploaded
Future of Skills
Alison B. Lowndes
38 views
•
50 slides
Orchestration, Automation and Virtualisation Maturity Model
CSUC - Consorci de Serveis Universitaris de Catalunya
51 views
•
19 slides
Cloud Composer workshop at Airflow Summit 2023.pdf
Leah Cole
77 views
•
80 slides
Keynote: Two years at the British Library... and counting / Alan Danskin (Bri...
CILIP MDG
24 views
•
33 slides
How to use the Cataloguing Code Ethics at your day job : a hands-on workshop ...
CILIP MDG
34 views
•
13 slides
Safe Community Call #12.pdf
LornyPfeifer
15 views
•
24 slides
Recently uploaded
(20)
Future of Skills
Alison B. Lowndes
•
38 views
Orchestration, Automation and Virtualisation Maturity Model
CSUC - Consorci de Serveis Universitaris de Catalunya
•
51 views
Cloud Composer workshop at Airflow Summit 2023.pdf
Leah Cole
•
77 views
Keynote: Two years at the British Library... and counting / Alan Danskin (Bri...
CILIP MDG
•
24 views
How to use the Cataloguing Code Ethics at your day job : a hands-on workshop ...
CILIP MDG
•
34 views
Safe Community Call #12.pdf
LornyPfeifer
•
15 views
Unleashing Innovation: IoT Project with MicroPython
Vubon Roy
•
25 views
Accelerating Data Science through Feature Platform, Transformers, and GenAI
FeatureByte
•
139 views
BuilderAI Proposal_Malesniak
Michael Lesniak
•
85 views
Demystifying ML/AI
Matthew Reynolds
•
29 views
LLaMA 2.pptx
RkRahul16
•
19 views
Elevate Your Enterprise with FME 23.1
Safe Software
•
277 views
Netwitness RT - Don’t scratch that patch.pptx
Stefano Maccaglia
•
92 views
Framing Few Shot Knowledge Graph Completion with Large Language Models
MODUL Technology GmbH
•
27 views
Mitigating Third-Party Risks: Best Practices for CISOs in Ensuring Robust Sec...
TrustArc
•
42 views
Nymity Framework: Privacy & Data Protection Update in 7 States
TrustArc
•
123 views
Product Listing Presentation_Cathy.pptx
CatarinaTorrenuevaMa
•
62 views
Swiss Re Reinsurance Solutions - Claims Automated Rules Engine – Insurer Inno...
The Digital Insurer
•
19 views
Understanding Wireguard, TLS and Workload Identity
Christian Posta
•
100 views
Common WordPress APIs - Options API
Jonathan Bossenger
•
19 views
Linux Memory Management
1.
© 2010-17 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. Linux Memory Management
2.
2© 2010-17 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. What to Expect? W's of Memory Management? Memory Partitioning Memory Organization Memory Management in Linux Swapping
3.
3© 2010-17 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. Why Memory Management? Transition from Uni-process → Multi-process Every process needs its own memory Memory Division Program loaded to “any” available memory address Relocation Independence / Non-interference between Processes Protection Communication between Processes Sharing Process Memory with Attributes (like read only for code) Logical Organization Executing Programs bigger than available Memory Physical Organization (Overlaying & Reusing)
4.
4© 2010-17 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. What is Memory Management? Key task: Division of Memory Starting from the Division between OS (Kernel) Application (User) Others follow Relocation, Protection, Sharing Logical & Physical Organization May involve movement between primary & secondary
5.
5© 2010-17 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. Memory Partitioning Two traditional division mechanisms Segmentation: Unequal sized Examples: Linear Allocation, Buddy System Paging: Equal sized Examples: 4K-Paged Allocation Examples in Linux User-space malloc(): Segmentation Slab sub-system: Paging
6.
6© 2010-17 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. Pros & Cons Memory Fragmentation External in Segmentation (gets worser) Internal in Paging Space Efficiency Segmentation: More meta but lesser allocation wastage Paging: Negligible meta but significant allocation wastage Time Efficiency Segmentation: Complex search & Storage Algorithm Paging: Simple Algorithms
7.
7© 2010-17 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. Memory Organization All other needs (Relocation, Protection, Sharing, ...) Beautifully achieved by the concept of virtualization That is organizing the memory into Physical & Virtual Address Spaces And then using the virtual addressing for all purposes Both may use either Paging or Segmentation Best to use similar mechanisms Linux uses Paging for both with 4KiB/8KiB page size Virtualization can be achieved Using special hardware called MMU Using software MMU
8.
8© 2010-17 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. Memory Organization ... Linux Kernels (>= 2.5.46) support both Earlier kernels worked only with hardware MMU uClinux used to be the solution for non-MMU processors & controllers Latest Intel, ARM, and most other architectures have in-built MMU Older x86, ARM7, and few such doesn't have a hardware MMU
9.
9© 2010-17 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. Memory (RAM) Working of an MMU 1 1 0 1 Valid Tag Frame Number TLB (in Cache) 1 Page Table (in RAM) 1 1 1 0 1 0 1 1 0 1 Page Number [31:12] Offset [11:0] Virtual Address
10.
10© 2010-17 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. Memory Management in Linux In Linux, all these combined User Space & Kernel Space Memory Page Partitioning Physical & Virtual Address Spaces Device Addresses, Mapping & Access Takes the following form ...
11.
11© 2010-17 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. Memory Organization in Linux An Example assuming 32-bit architecture 4GB Process VA Space 1 User Space 4GB Process VA Space N . . . 3GB Virtual Address for User 1GB VA for Kernel Kernel Space (fixed by kernel) Logical Address (Non-swappable) Virtual Address (Swappable) 0x00000000 0xBFFFFFFF 0xFFFFFFFF 0xC0000000 Upto 3GB Memory (RAM) Addressing Upto 1GB Dev Addressing Physical Address Space (fixed by architecture) 0x00000000 0xBFFFFFFF 0xC0000000 0xFFFFFFFF Bus Address (incl. both h/w memory & registers) Physical Address (incl. only memory)
12.
12© 2010-17 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. Linux Memory Manager Provides Access Control to h/w & memory resources Provides Dynamic Memory to kernel sub-system Drivers File Systems Stacks Provides Virtual Memory to Kernel & User space Kernel & User Processes run in their own virtual address spaces Providing the various features of a Linux system System reliability, Security Communication Program Execution Support
13.
13© 2010-17 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. Swapping Optimizes primary & secondary memory usage Primary memory pages swapped out When running out of memory Secondary memory pages swapped in When needed back Linux maintains Page Cache in Primary Memory for Code: Reloadable Data: Unchanged vs Changed Changed Data: Temporary (Dynamic) vs Persistent (Files) Linux uses Swap (raw) partition on Secondary Memory Related commands: mkswap, swapon/off
14.
14© 2010-17 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. What all have we learnt? W's of Memory Management? Memory Partitioning Segmentation & Paging Memory Organization Physical & Virtual Addressing Working of an MMU Memory Management in Linux Swapping & Swap Partition
15.
15© 2010-17 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. Any Queries?