Udemy
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Memory Management in Linux Kernel
Rating: 4.3 out of 5(367 ratings)
2,915 students

Memory Management in Linux Kernel

Linux Kernel Programming - Memory Management in Deep
Created byLinux Trainer
Last updated 10/2020
English

What you'll learn

  • Knowledge of Memory management in Linux Kernel

Course content

3 sections44 lectures1h 57m total length
  • What is Physical Address Space2:06

    Define physical address space as the processor-accessible range of memory addresses, and show how 32-bit four gigabytes and 64-bit systems share this space with memory devices and peripherals.

  • How to view memory map/physical address space in Linux - /proc/iomem1:24
  • Running 32-bit Buildroot image in QEMU3:16

    Run a 32-bit buildroot image in qemu to examine physical memory and address space, and understand how devices, bios, and addresses are mapped in 64-bit emulation.

  • View/Change RAM Size in QEMU - /proc/meminfo, free -m1:38

    Discover how to view and adjust the RAM size in QEMU using /proc/meminfo and the free -m command, enabling accurate memory management for virtual machines.

  • Virtual Address Space for 32-bit processors3:58
  • Why kernel shares its address space for all processes1:46

    The kernel shares its address space across all processes to avoid costly memory context switches. User space remains per-process, while system calls map memory into each process.

  • 64-bit Memory Map0:42

    Examine the 64-bit memory map and the layout of userspace memory, and reference the documentation for details.

  • Converting Virtual address to physical address and vice versa5:12

    Learn how to convert virtual addresses to physical addresses in the Linux kernel, using documented format specifiers, and print actual versus unmodified addresses with BTX and kernel guidelines.

  • Pages - PAGE_SIZE macro3:17

    Explore how the linux kernel memory management divides virtual space into 4096-byte pages and maps them to physical frames via the memory management unit using page tables.

  • struct page1:26

    Examine how memory pages are represented in the Linux kernel using struct page, including page frames, references, and virtual addresses. Note that each page is 64 bytes.

  • Page Fault4:27

    explain how the Linux kernel uses paging and lazy userspace allocation, keeps kernel memory resident, and handles page faults, including minor and major faults.

  • Page Faults when memory is 4 KB1:11
  • User space virtual address space1:50

    Explore the user space virtual address space, including the text and data segments, heap, stack, and environment variables, with process maps to reveal memory layout.

  • Kernel Virtual address space - low mem and high mem3:11

    Explain how the kernel virtual address space splits into low memory and high memory and how page tables map physical memory.

  • Low Memory2:37

    Explain how the Linux kernel maps physical memory into virtual space at boot, including a direct 896 MB mapping and the DMA and normal memory zones.

  • How can i find out how much is my low mem and high mem3:36

    Learn to determine how much low mem and high mem you have, view total memory, and understand how ramp and off ramp settings affect memory allocation.

  • High Memory2:18
  • Memory Allocation Mechanism2:14

    Explore how the Linux kernel allocates memory, from page level to the slab allocator, detailing four kilobyte pages and how slabs subdivide into 8, 16, and 32 byte chunks.

  • kmalloc and kfree2:48

    Explore kmalloc and kfree in the Linux kernel, explaining contiguous physical and virtual memory allocation, slab allocator usage, and GFP flag behavior, including memory leaks and proper freeing practices.

  • Linux Kernel Module example of kmalloc and kfree1:36

Requirements

  • Should be able to write/compile/load/unload Hello World Linux Kernel Modules

Description

This course offers a deep dive into the memory management of a Linux kernel, equipping you with practical knowledge and skills. You will first grasp the fundamental concepts of both physical and virtual address spaces for a processor and learn how to inspect them in a Linux environment. A key focus will be on the division of the virtual address space into distinct kernel and user spaces.

You'll gain an understanding of how the operating system handles memory in units called pages, and what triggers a page fault. The course will then detail the crucial process of converting a virtual address to a physical address, including the proper format specifiers for printing addresses.

Furthermore, you will explore the concepts of Low Memory and High Memory and the kernel's efficient Buddy Allocator for managing memory. You'll learn how to use the /proc/buddyinfo file to monitor memory zones. The course also covers dynamic memory allocation in the kernel using essential APIs like kmalloc and vmalloc, clarifying the differences between them and the various flags they use, such as GFP_KERNEL and GFP_ATOMIC. The course also addresses what happens when you attempt to allocate zero-sized memory. Lastly, you will examine the structure of the kernel stack and use the qemu-system-x86 command for practical exercises.

Who this course is for:

  • Developers curious about learning memory management in Linux Kernel