
内存管理
文章平均质量分 89
HugoVus
这个作者很懒,什么都没留下…
展开
-
/PROC/MEMINFO之谜
/proc/meminfo是了解Linux系统内存使用状况的主要接口,我们最常用的”free”、”vmstat”等命令就是通过它获取数据的 ,/proc/meminfo所包含的信息比”free”等命令要丰富得多,然而真正理解它并不容易,比如我们知道”Cached”统计的是文件缓存页,manpage上说是“In-memory cache for files read from the disk (the pagecache)”,那为什么它不等于[Active(file)+Inactive(file)]...转载 2021-10-09 15:48:10 · 404 阅读 · 0 评论 -
(十六)Linux内存管理之CMA
背景Read the fucking source code!--By 鲁迅 A picture is worth a thousand words.--By 高尔基说明:Kernel版本:4.14 ARM64处理器,Contex-A53,双核 使用工具:Source Insight 3.5, Visio1. 概述Contiguous Memory Allocator, CMA,连续内存分配器,用于分配连续的大块内存。CMA分配器,会Reserve一片物理内存区域:设备驱动不用..转载 2021-08-18 11:34:34 · 1777 阅读 · 0 评论 -
(十五)Linux内存管理之RMAP
背景Read the fucking source code!--By 鲁迅 A picture is worth a thousand words.--By 高尔基说明:Kernel版本:4.14 ARM64处理器,Contex-A53,双核 使用工具:Source Insight 3.5, Visio1. 概述RMAP反向映射是一种物理地址反向映射虚拟地址的方法。 映射 页表用于虚拟地址到物理地址映射,其中的PTE页表项记录了映射关系,同时struct page结构体中..转载 2021-08-18 11:33:40 · 358 阅读 · 0 评论 -
(十四)Linux内存管理之page fault处理
背景Read the fucking source code!--By 鲁迅 A picture is worth a thousand words.--By 高尔基说明:Kernel版本:4.14 ARM64处理器,Contex-A53,双核 使用工具:Source Insight 3.5, Visio1. 概述上篇文章分析到malloc/mmap函数中,内核实现只是在进程的地址空间建立好了vma区域,并没有实际的虚拟地址到物理地址的映射操作。这部分就是在Page Fault异常..转载 2021-08-18 11:18:48 · 849 阅读 · 0 评论 -
(十三)Linux内存管理之vma/malloc/mmap
背景Read the fucking source code!--By 鲁迅 A picture is worth a thousand words.--By 高尔基说明:Kernel版本:4.14 ARM64处理器,Contex-A53,双核 使用工具:Source Insight 3.5, Visio1. 概述这篇文章,让我们来看看用户态进程的地址空间情况,主要会包括以下:vma; malloc; mmap;进程地址空间中,我们常见的代码段,数据段,bss段等,实际上..转载 2021-08-18 11:16:58 · 480 阅读 · 0 评论 -
(十二)Linux内存管理之vmap与vmalloc
背景Read the fucking source code!--By 鲁迅 A picture is worth a thousand words.--By 高尔基说明:Kernel版本:4.14 ARM64处理器,Contex-A53,双核 使用工具:Source Insight 3.5, Visio1. 概述在之前的系列文章中,分析到了Buddy System的页框分配,Slub分配器的小块内存对象分配,这些分配的地址都是物理内存连续的。当内存碎片后,连续物理内存的分配就会变..转载 2021-08-11 15:39:15 · 1923 阅读 · 0 评论 -
(十一)Linux内存管理slub分配器
背景Read the fucking source code!--By 鲁迅 A picture is worth a thousand words.--By 高尔基说明:Kernel版本:4.14 ARM64处理器,Contex-A53,双核 使用工具:Source Insight 3.5, Visio1. 概述之前的文章分析的都是基于页面的内存分配,而小块内存的分配和管理是通过块分配器来实现的。目前内核中,有三种方式来实现小块内存分配:slab, slub, slob,最先有s..转载 2021-08-11 15:38:12 · 324 阅读 · 0 评论 -
(十)Linux内存管理 - zoned page frame allocator - 5
背景Read the fucking source code!--By 鲁迅 A picture is worth a thousand words.--By 高尔基说明:Kernel版本:4.14 ARM64处理器,Contex-A53,双核 使用工具:Source Insight 3.5, Visio1. 概述本文将讨论memory reclaim内存回收这个话题。在内存分配出现不足时,可以通过唤醒kswapd内核线程来异步回收,或者通过direct reclaim直接回收..转载 2021-08-11 15:36:24 · 311 阅读 · 0 评论 -
(九)Linux内存管理 - zoned page frame allocator - 4
背景Read the fucking source code!--By 鲁迅 A picture is worth a thousand words.--By 高尔基说明:Kernel版本:4.14 ARM64处理器,Contex-A53,双核 使用工具:Source Insight 3.5, Visio1. 概述本文将描述memory compaction,内存碎片整理技术。内存碎片分为内碎片和外碎片:内碎片:内存页里边的碎片; 外碎片:内存页之间的碎片,可能会造成连续物..转载 2021-08-10 15:09:28 · 226 阅读 · 0 评论 -
(八)Linux内存管理 - zoned page frame allocator - 3
背景Read the fucking source code!--By 鲁迅 A picture is worth a thousand words.--By 高尔基说明:Kernel版本:4.14 ARM64处理器,Contex-A53,双核 使用工具:Source Insight 3.5, Visio1. 概述本文将分析watermark。简单来说,在使用zoned page frame allocator分配页面时,会将可用的free pages与zone的watermar..转载 2021-08-10 15:08:38 · 329 阅读 · 0 评论 -
(七)Linux内存管理 - zoned page frame allocator - 2
背景Read the fucking source code!--By 鲁迅 A picture is worth a thousand words.--By 高尔基说明:Kernel版本:4.14 ARM64处理器,Contex-A53,双核 使用工具:Source Insight 3.5, Visio1. 概述本文将分析Buddy System。Buddy System伙伴系统,是通过将物理内存划分为页面来进行管理的系统,支持连续的物理页面分配和释放。此外,使用与碎片相关的算法..转载 2021-08-10 11:44:06 · 303 阅读 · 0 评论 -
(六)Linux内存管理 - zoned page frame allocator - 1
背景Read the fucking source code!--By 鲁迅 A picture is worth a thousand words.--By 高尔基说明:Kernel版本:4.14 ARM64处理器,Contex-A53,双核 使用工具:Source Insight 3.5, Visio1. 介绍之前的系列内存管理文章基本上描述的是物理页面的初始化过程,以及虚拟页面到物理页面的映射建立过程,从这篇文章开始,真正要涉及到页面的分配了。接下来的文章会围绕着分区页框分配..转载 2021-08-10 11:40:32 · 289 阅读 · 0 评论 -
(五)Linux内存管理zone_sizes_init
背景Read the fucking source code!--By 鲁迅 A picture is worth a thousand words.--By 高尔基说明:Kernel版本:4.14 ARM64处理器,Contex-A53,双核 使用工具:Source Insight 3.5, Visio1. 介绍在(四)Linux内存模型之Sparse Memory Model中,我们分析了bootmem_init函数的上半部分,这次让我们来到下半部分吧,下半部分主要是围绕zon..转载 2021-08-10 11:39:46 · 425 阅读 · 0 评论 -
(四)Linux内存模型之Sparse Memory Model
背景Read the fucking source code!--By 鲁迅 A picture is worth a thousand words.--By 高尔基说明:Kernel版本:4.14 ARM64处理器,Contex-A53,双核 使用工具:Source Insight 3.5, Visio1. 介绍顺着之前的分析,我们来到了bootmem_init()函数了,本以为一篇文章能搞定,大概扫了一遍代码之后,我默默的把它拆成了两部分。bootmem_init()函数代码如..转载 2021-08-10 11:37:25 · 619 阅读 · 0 评论 -
(三)Linux paging_init解析
背景Read the fucking source code!--By 鲁迅 A picture is worth a thousand words.--By 高尔基说明:Kernel版本:4.14 ARM64处理器,Contex-A53,双核 使用工具:Source Insight 3.5, Visio1. 介绍从(二)Linux物理内存初始化中,可知在paging_init调用之前,存放Kernel Image和DTB的两段物理内存区域可以访问了(相应的页表已经建立好)。尽管物..转载 2021-08-10 11:36:24 · 434 阅读 · 0 评论 -
(二)Linux物理内存初始化
背景Read the fucking source code!--By 鲁迅 A picture is worth a thousand words.--By 高尔基说明:Kernel版本:4.14 ARM64处理器,Contex-A53,双核 使用工具:Source Insight 3.5, Visio1. 介绍让我们思考几个朴素的问题?系统是怎么知道物理内存的? 在内存管理真正初始化之前,内核的代码执行需要分配内存该怎么处理?我们先来尝试回答第一个问题,看过dts文件的..转载 2021-08-10 11:34:18 · 364 阅读 · 0 评论 -
(一)ARMv8 MMU及Linux页表映射
背景Read the fucking source code!--By 鲁迅 A picture is worth a thousand words.--By 高尔基说明:Kernel版本:4.14 ARM64处理器,Contex-A53,双核 使用工具:Source Insight 3.5, Visio1. 介绍要想理解好Linux的页表映射,MMU的机制是需要去熟悉的,因此将这两个模块放到一起介绍。关于ARMv8 MMU的相关内容,主要参考文档:《ARM Cortex-A S..转载 2021-08-10 11:32:50 · 670 阅读 · 0 评论 -
__zone_watermark_ok分析
__zone_watermark_ok分析最近在学习linux 内存管理这一块。看到了函数__zone_watermark_ok。想起来之前也曾经见过该函数,当时是在分析init.rc的内存,最终也看到了这个函数,不过当时对其并不是很理解。最近又遇到了它,结合积攒的一点知识,总算对其有了个大致了解。先概述一下其用途。从名称来看,zone, watermaker, 还有ok。直观上来看,就是在某个zone上分配内存时,检查是否满足给定的watermark的要求。zone就是memory zo转载 2021-08-10 11:13:07 · 558 阅读 · 1 评论 -
arm的2级页表在Linux内核创建过程解析
系统DDR的基地址为0x0,内存为1GB,所以TTB的基地址为0x4000。下面要创建虚拟地址0xfe700000到物理地址0xffff0000之间的映射,映射大小为64KB,即16页。由于物理地址不是1MB字节对齐,所以必须创建两级映射。 用户空间/内核空间划分为2G/2G。create_mapping:pgd = 0x80007f98, addr = 0xfe700000, phys =0xffff0000, next = 0xfe710000pte =0x3fffd000, pmdva.转载 2021-07-30 16:44:25 · 912 阅读 · 0 评论