memblock_free_all释放page到buddy,前后nr_free的情况

news2024/11/18 7:34:31

https://www.cnblogs.com/tolimit/p/5287801.html

在zone_sizes_init 之后,各个node,zone'的page总数已知。但是此时的每个order的空闲链表是空的,也就是无法通过alloc_page这种接口来分配。此时page还在memblock管控,需要memblock释放。释放的函数是free_low_memory_core_early:

mm_init   //init/main.c
	mem_init(void)   //arch/arm64/mm/init.c
		memblock_free_all();
	
	
void __init memblock_free_all(void)
{
	unsigned long pages;

	free_unused_memmap();
	reset_all_zones_managed_pages();

	pages = free_low_memory_core_early();
	totalram_pages_add(pages);
}


free_low_memory_core_early
	for_each_free_mem_range
		 __free_memory_core(start, end);
			__free_pages_memory(start_pfn, end_pfn);
				memblock_free_pages(pfn_to_page(start), start, order);
					__free_pages_core
						__free_pages_ok
							__free_one_page

在arch/arm64/mm/init.c 增加如下代码调试:

static void show_zone_info(struct zone *zone)
{
        int i;
        struct free_area * area;
        if(!zone || !zone->name)
                return;
        printk("===show_zone_info :\n"
                        "       name : %s\n"
                        "       managed_pages:%llx\n"
                        "       spanned_pages:%llx\n"
                        "       present_pages:%llx\n",zone->name,zone->managed_pages,zone->spanned_pages,zone->present_pages);
        for (i = 0;i<= MAX_ORDER;i++)
        {
                area=&zone->free_area[i];
                printk("        MAX_ORDER %d of order :%d has nr_free %llx\n",MAX_ORDER,i,zone->free_area[i].nr_free);
        }


}
static void show_pgdata_info(struct pglist_data *pgdat)
{
        if (!pgdat)
                return;
        printk("===show_pgdata_info nodeid %d \n",pgdat->node_id);
        struct zone *z;
        for (z = pgdat->node_zones; z < pgdat->node_zones + MAX_NR_ZONES; z++)
                show_zone_info(z);
}
static void show_mem_info(const char *info)
{
        printk("===show_mem_info  %s\n",info);
        struct pglist_data *pgdat;
        for_each_online_pgdat(pgdat)
                show_pgdata_info(pgdat);
}


void __init bootmem_init(void)
{
...
        zone_sizes_init();
        show_mem_info("after zone_sizes_init\n");  //调用
...
}

void __init mem_init(void)
{
        bool swiotlb = max_pfn > PFN_DOWN(arm64_dma_phys_limit);

        if (IS_ENABLED(CONFIG_DMA_BOUNCE_UNALIGNED_KMALLOC))
                swiotlb = true;

        swiotlb_init(swiotlb, SWIOTLB_VERBOSE);

        /* this will put all unused low memory onto the freelists */
        memblock_free_all();
        show_mem_info("after memblock_free_all\n");  //调用

    .....
}

以下日志是基于6.6内核: 

在memblock_free_all之前,各个NUMA的pglist_data的zone下面不同order的nr_free链表数为0:
[    0.000000] ===show_mem_info  after zone_sizes_init

[    0.000000] ===show_pgdata_info nodeid 0 
[    0.000000] ===show_zone_info :
                      name : DMA
                      managed_pages:7a000
                      spanned_pages:80000
                      present_pages:7c000
[    0.000000]  MAX_ORDER 10 of order :0 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :1 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :2 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :3 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :4 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :5 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :6 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :7 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :8 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :9 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :10 has nr_free 0
[    0.000000] ===show_zone_info :
                      name : DMA32
                      managed_pages:0
                      spanned_pages:0
                      present_pages:0
[    0.000000]  MAX_ORDER 10 of order :0 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :1 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :2 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :3 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :4 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :5 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :6 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :7 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :8 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :9 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :10 has nr_free 0
[    0.000000] ===show_zone_info :
                      name : Normal
                      managed_pages:762000
                      spanned_pages:2680000
                      present_pages:780000
[    0.000000]  MAX_ORDER 10 of order :0 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :1 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :2 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :3 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :4 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :5 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :6 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :7 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :8 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :9 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :10 has nr_free 0
[    0.000000] ===show_zone_info :
                      name : Movable
                      managed_pages:0
                      spanned_pages:0
                      present_pages:0
[    0.000000]  MAX_ORDER 10 of order :0 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :1 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :2 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :3 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :4 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :5 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :6 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :7 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :8 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :9 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :10 has nr_free 0

在memblock_free_all之后,才有,特别是order为10的情况最多,这是看空闲的组成大的buddy:
[    0.000000] ===free_low_mwmory_core_early return pages 7c4864
[    0.000000] ===show_mem_info  after memblock_free_all

[    0.000000] ===show_pgdata_info nodeid 0
[    0.000000] ===show_zone_info :
                      name : DMA
                      managed_pages:6b9f1
                      spanned_pages:80000
                      present_pages:7c000
[    0.000000]  MAX_ORDER 10 of order :0 has nr_free 5
[    0.000000]  MAX_ORDER 10 of order :1 has nr_free 4
[    0.000000]  MAX_ORDER 10 of order :2 has nr_free 5
[    0.000000]  MAX_ORDER 10 of order :3 has nr_free 4
[    0.000000]  MAX_ORDER 10 of order :4 has nr_free b
[    0.000000]  MAX_ORDER 10 of order :5 has nr_free 4
[    0.000000]  MAX_ORDER 10 of order :6 has nr_free 6
[    0.000000]  MAX_ORDER 10 of order :7 has nr_free 6
[    0.000000]  MAX_ORDER 10 of order :8 has nr_free 6
[    0.000000]  MAX_ORDER 10 of order :9 has nr_free 5
[    0.000000]  MAX_ORDER 10 of order :10 has nr_free 1a9
[    0.000000] ===show_zone_info :
                      name : DMA32
                      managed_pages:0
                      spanned_pages:0
                      present_pages:0
[    0.000000]  MAX_ORDER 10 of order :0 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :1 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :2 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :3 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :4 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :5 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :6 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :7 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :8 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :9 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :10 has nr_free 0
[    0.000000] ===show_zone_info :
                      name : Normal
                      managed_pages:758e73
                      spanned_pages:2680000
                      present_pages:780000
[    0.000000]  MAX_ORDER 10 of order :0 has nr_free 1
[    0.000000]  MAX_ORDER 10 of order :1 has nr_free 1
[    0.000000]  MAX_ORDER 10 of order :2 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :3 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :4 has nr_free 1
[    0.000000]  MAX_ORDER 10 of order :5 has nr_free 1
[    0.000000]  MAX_ORDER 10 of order :6 has nr_free 1
[    0.000000]  MAX_ORDER 10 of order :7 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :8 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :9 has nr_free 1
[    0.000000]  MAX_ORDER 10 of order :10 has nr_free 1d63
[    0.000000] ===show_zone_info :
                      name : Movable
                      managed_pages:0
                      spanned_pages:0
                      present_pages:0
[    0.000000]  MAX_ORDER 10 of order :0 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :1 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :2 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :3 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :4 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :5 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :6 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :7 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :8 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :9 has nr_free 0
[    0.000000]  MAX_ORDER 10 of order :10 has nr_free 0

可以通过/proc/buddyinfo实时观察系统上node中zone的nr_free链表情况:

UMA机器8G内存:

root@wzm-PC:~# cat /proc/buddyinfo 
Node 0, zone      DMA     11      5      5      8     19     14     12     12      7     10    458 
Node 0, zone   Normal    293   1684    583    238     76     34     12      7      2      9   3123

NUMA机器512G:

[root@libvirt-Manage ~]# cat /proc/buddyinfo 
Node 0, zone    DMA32      6      7      7      6     18     14      9     11     10      9    195 
Node 0, zone   Normal   6868   2968   2105   4510   1662    601    181     42     12     10   5322 
Node 1, zone   Normal   2396   3065   3978   4944   1420    401    114     34      4      8   5704 
Node 2, zone   Normal   8218   7366  10003   4542   1319    474    145     25      8      9   6051 
Node 3, zone   Normal   6676   3485   8483   4343   1651    764    239     63     21     16   5984 
Node 4, zone   Normal  10725   1148    469   1924   1224    559    223     90     18     19   5703 
Node 5, zone   Normal   5355   2206   2172   4719   2051    694    192     58     12      9   5867 
Node 6, zone   Normal   5864   2451   4543    550     26      8      7      2      2     31   6198 
Node 7, zone   Normal  13745  13678   9044   3810   1242    345     89     28     21     19   6171 
Node 8, zone   Normal  16210  14686   6900   2919   1467    816    422     54     45     15   5261 
Node 9, zone   Normal  12558   8541   6409    981   1590    593    211     79     13     11   6068 
Node 10, zone   Normal  19467  17940  10715   2690    388     68     17     10      5      3   5713 
Node 11, zone   Normal  17151  19618  10336   2632    165     46     22     10      7      7   5609 
Node 12, zone   Normal  13258  12289  11472   7480   2718    615    241     74     32     18   5689 
Node 13, zone   Normal  16238  18440   9468   3384   1126    431    134     45     22     40   4854 
Node 14, zone   Normal  12328  17060   9764   3654   1404    613    255     95     24     15   5778 
Node 15, zone   Normal  10606  14281   9219   3607   1312    536    167     26      5     12   6144 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1716402.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

HDTune和CrystalDiskInfo硬盘检测S.M.A.R.T.参数当前值最差值阈值

高亮颜色说明&#xff1a;突出重点 个人觉得&#xff0c;&#xff1a;待核准个人观点是否有误 高亮颜色超链接 文章目录 S.M.A.R.T.监控技术磁盘健康状态监测,硬盘检测硬盘检测工具 HD Tune硬盘检测工具 CrystalDiskInfo 当前值最差值阈值原始值的含义二级标题待补充待补充 开头…

IPV4地址介绍

4.1IP地址简介 目前的全球因特网所采用的协议族是TCP/IP协议族。IP是TCP/IP协议族中网络层的协议&#xff0c;是TCP/IP协议族的核心协议。IP协议定义了一种地址编码&#xff0c;称为IP地址&#xff0c;它是网络中网络段、网络设备接口、主机的编码&#xff0c;它并不是一种物理…

Pag格式在vue3中的简单使用方法

目前前端使用pag格式的方法比较少&#xff0c; 在这里我来简单实现一下pag格式在vue3中的使用方式。 第一步 先下载啦 npm i libpag 来对pag文件安装依赖 其次我们在自己想要引入的vue页面进行引入 <script setup> import { ref, computed, watchEffect, nextTick …

应用案例|精密制造中使用复合机器人得到显著提升

精密制造行业对设备的精度、稳定性和效率要求极高&#xff0c;而复合机器人凭借其多功能性、高度灵活性和精准控制能力&#xff0c;正逐渐成为该领域的新宠。以下是一个富唯智能复合机器人在精密制造中的应用案例。 案例背景 某知名汽车零部件制造企业&#xff0c;专注于生产…

光纤现网与接入网概念对应

OLT 一般在机房 一级分光可能在机房也可能在光交交接箱 路边的光交交接箱功能有分光或者光纤汇聚转换一下 二级分光在分光光纤箱里&#xff0c;楼道里面挂着的那种 ONU是家里的光猫

go语言的使用方法

一.go语言的介绍 1.简介 2.应用领域 3.使用go语言的公司 4.go语言开发工具介绍 5.go语言开发环境搭建 【1】搭建Go开发环境-安装和配置SDK 基本介绍: 1).SDK的全称(Software Development Kit软件开发工具包&#xff09;2).SDK是提供给开发人员使用的&#xff0c;其中包含了…

STM32实验之USART串口发送+接受数据(二进制/HEX/文本)

涉及三个实验&#xff1a; 1.USART串口发送和接收数据 我们使用的是将串口封装成为一个Serial.c模块.其中包含了 void Serial_Init(void);//串口初始化 void Serial_SendByte(uint8_t Byte);//串口发送一个字节 void Serial_SendArray(uint8_t *Array,uint16_t Length);//…

第一讲:单片机STC89C52+RA8889驱动控制彩屏(源码公开)

51单片机驱动控制彩屏系列讲座 第一讲&#xff1a;单片机STC89C52RA8889驱动控制彩屏&#xff08;源码公开&#xff09; 单片机通过SPI与RA8889进行通信&#xff0c;由于单片机是5V&#xff0c;RA8889是3.3V,故需要进行电平转换&#xff0c;有现成的模组TXS0108E等可以采用。…

VRTK4教程 一:资源导入、Unity设置、连接头盔

文章目录 VRTK4的分包导入VRTK4的资源包unity设置连接头盔 VRTK4的分包 vrtk4的资源包和旧版不同&#xff0c;采用了分包导入的思想&#xff0c;我们要用什么功能&#xff0c;就导入什么包&#xff0c;可以有效减小程序体积 如下图&#xff0c;已经导入的vrtk包会显示在Packag…

CentOS下安装SVN客户端及使用方法

一、前言 Subversion&#xff08;SVN&#xff09;是一款开源的版本控制系统&#xff0c;它可以帮助开发者追踪和管理代码、文档或其他文件的更改历史。在Linux系统中&#xff0c;特别是在CentOS环境下&#xff0c;安装和使用SVN客户端是日常工作中常见的任务。本文将介绍如何在…

【错误记录】HarmonyOS 运行报错 ( Failure INSTALL_PARSE_FAILED_USESDK_ERROR )

文章目录 一、报错信息二、问题分析三、解决方案 一、报错信息 在 DevEco Studio 中 , 使用 远程设备 , 向 P40 Failure[INSTALL_PARSE_FAILED_USESDK_ERROR] compileSdkVersion and releaseType of the app do not match the apiVersion and releaseType on the device. 二、…

在outlook的邮件中插入HTML;HTML模板获取;页面组态手动生成HTML

本文介绍如何在outlook发送邮件时&#xff0c;在邮件中插入HTML&#xff0c;此HTML可以从获取模板自行进行修改。 文章目录 一、下载HTML模板&#xff08;或自己制作好HTML文件&#xff09;二、outlook新增宏三、新建邮件&#xff0c;插入HTML四、通过图像化页面组态手动生成HT…

[C#]使用C#部署yolov8-cls的图像分类的tensorrt模型

【测试通过环境】 win10 x64 vs2019 cuda11.7cudnn8.8.0 TensorRT-8.6.1.6 opencvsharp4.9.0 .NET Framework4.7.2 NVIDIA GeForce RTX 2070 Super 版本和上述环境版本不一样的需要重新编译TensorRtExtern.dll&#xff0c;TensorRtExtern源码地址&#xff1a;TensorRT-CShar…

汇舟问卷:国外问卷调一天900

大家好&#xff0c;我是汇舟问卷&#xff0c;专注于国外问卷调查互联网项目。夏天已经来临&#xff0c;您是否在三伏天顶着大太阳上班&#xff0c;汗水浸湿了衣襟&#xff0c;却依然要面对繁琐的工作和无尽的压力&#xff1f; 在这个炎热的季节里&#xff0c;我们都渴望找到一…

失落的方舟 命运方舟台服账号怎么注册 游戏账号最全图文注册教程

探索奇幻大陆阿克拉西亚的奥秘&#xff0c;加入《失落的方舟》&#xff08;Lost Ark&#xff09;这场史诗般的冒险。这是一款由Smilegate精心雕琢的MMORPG巨作&#xff0c;它融合了激烈动作战斗与深邃故事叙述&#xff0c;引领玩家步入一个因恶魔侵袭而四分五裂的世界。作为勇敢…

教学基本功包括什么技能有哪些

教师的工作不仅仅是传授知识&#xff0c;更多是引导学生探索&#xff0c;激发他们的创造力。要做到这一点&#xff0c;需要具备一些基本技能。 扎实的专业知识。这是教师的根基&#xff0c;如果教师自己对所教的科目都不熟悉&#xff0c;那么教学就会失去方向。不断学习更新自己…

29-ESP32-S3-WIFI篇-00 STA模式扫描全部 AP

ESP32-S3 WIFI_Driver 引言 ESP32-S3是一款集成了Wi-Fi和蓝牙功能的芯片。关于WIFI的部分&#xff0c;其实内容比我想象的要多得多。所以通常来说&#xff0c;如果你想要编写自己的Wi-Fi应用程序&#xff0c;最快捷的方法就是先找一个类似的示例应用&#xff0c;然后将它的相…

SC8205LA 20VN沟道增强型MOS(Mos)场效应管

特点 ❥专有的先进平面技术 ❥高密度超低电阻设计 ❥大功率、大电流应用 ❥理想的锂电池应用 ❥封装形式:SOT23-6

计算成像技术在信息复原及增强中的研究进展

​欢迎关注GZH《光场视觉》 摘要&#xff1a;计算成像是融合了光学设计、光学传感和图像处理的新兴技术领域&#xff0c;突破了传统成像技术获取信息的深度和广度限制&#xff0c;成为国际研究热点&#xff0c;是先进光学成像技术的重要发展方向。综合国内外文献和相关报道&am…

20240529瑞芯微官方Toybrick TB-RK3588开发板的Debian11下使用SCP拷贝文件

20240529瑞芯微官方Toybrick TB-RK3588开发板的Debian11下使用SCP拷贝文件 2024/5/29 20:48 1、ADB链接异常。 2、BT打开之后找不到设备&#xff1f; 不清楚&#xff1a;是我拿到的开发板的问题&#xff0c;还是Toybrick/Rockchip官方没有做好。 3、现在最新版本的WINSCP&…