diff --git a/study/kernel/02-memory/04-buddy/04-alloc_page/README.md b/study/kernel/02-memory/04-buddy/04-alloc_page/README.md index ea4217d..fe722d7 100755 --- a/study/kernel/02-memory/04-buddy/04-alloc_page/README.md +++ b/study/kernel/02-memory/04-buddy/04-alloc_page/README.md @@ -511,9 +511,14 @@ for 循环所作的基本上与直觉一致(从高端向低端扫描), for_next_ * 首先, 如果使能了 CPUSET, 且内存分配附带了 ALLOC_CPUSET 标记, 则只能(从 CPUSET 限定的)该进程允许运行 CPU 的所属内存域去分配内存, 通过 `__cpuset_zone_allowed` 来检查. -* `zone_watermark_fast` 检测当前 `ZONE` 的水位情况, 检查是否能够满足当前多个页面的分配请求. 如果水位不足, 则会 `zone_reclaim` 尝试去回收内存. 如果没有正常回收, 或者回收的内存不够, 都将跳过从 ZONE 上分配内存, 回收完成后, 通过 `zone_watermark_ok` 当前 ZONE 是否(回收够了)足够的空闲页. +* `zone_watermark_fast` 检测当前 `ZONE` 的水位情况, 检查是否能够满足当前多个页面的分配请求. 如果水位不足, 则会 `zone_reclaim` 尝试去回收内存. 如果没有正常回收, 或者回收的内存不够, 都将跳过从 ZONE 上分配内存, 回收完成后, 通过 `zone_watermark_ok` 再次检查 ZONE 的水位情况以及是否满足连续大内存块的分配需求. + +* 如果没有足够的空闲页, 或者没有连续内存块可满足分配请求, 则循环进行到备用列表中的下一个内存域, 继续同样的检查. 直到找到一个合适的页面, 再进行 `try_this_node` 进行内存分配. 请注意即使一切检查都成功了, 最终依然可能会分配失败. 这种情况可能是: + + 1. 外碎片化严重, 没有足够的连续内存页 + + 2. 也可能是无法从 ZONE 内其他迁移类型中借用内存出来. -* 如果没有足够的空闲页, 或者没有连续内存块可满足分配请求, 则循环进行到备用列表中的下一个内存域, 作同样的检查. 直到找到一个合适的页面, 再进行 `try_this_node` 进行内存分配. * 如果内存域适用于当前的分配请求, 那么则通过 `rmqueue` 从伙伴系统中分配内存. @@ -674,8 +679,6 @@ try_this_zone: } ``` -其中 zone_watermark_fast 函数检查当前 ZONE 中的水位情况 - ## 3.3 水位控制 ------- @@ -890,3 +893,47 @@ for (o = order; o < MAX_ORDER; o++) { ### 3.3.3 zone_watermark_fast ------- + + +## 3.4 rmqueue +------- + +### 3.4.1 rmqueue 的基本流程 + +![rmqueue 流程](./rmqueue.png) + + +```cpp +// https://elixir.bootlin.com/linux/v5.10/source/mm/page_alloc.c#L3421 +``` + +1. 对于分配分配单页的情况(oder == 0), 则使用 [`rmqueue_pcplist`](https://elixir.bootlin.com/linux/v5.10/source/mm/page_alloc.c#L3396) 直接从冷热页缓存 PCP(Per Cpu Pages)中获取. + +2. 如果设置了 ALLOC_HARDER, 则说明是一次高优先级的分配, 就[从迁移类型为 MIGRATE_HIGHATOMIC 的内存中进行分配](https://elixir.bootlin.com/linux/v5.10/source/mm/page_alloc.c#3458). MIGRATE_HIGHATOMIC 类型的页用常用于于一些紧急情况下的内存分配. + +3. 常规模式下, 一般都是通过 [`__rmqueue`](https://elixir.bootlin.com/linux/v5.10/source/mm/page_alloc.c#L2841) 从伙伴系统中指定迁移类型为 migratetype 的链表中获取. + + 3.1 如果超过一半空闲内存位于 CMA 区域时, 则优先使用 [`__rmqueue_cma_fallback`](https://elixir.bootlin.com/linux/v5.10/source/mm/page_alloc.c#L2348) 从 CMA 中分配 + + 3.2 标准流程就是 [`__rmqueue_smallest`](https://elixir.bootlin.com/linux/v5.10/source/mm/page_alloc.c#L2348) 从 各个 order 的空闲链表中获取, 首先从当前 order 的空闲链表中获取页面, 如果当前 order 页面不足, 则开始向高 order 的链表中切蛋糕. + + 3.3 如果切蛋糕也失败了, 说明空闲的页面已经不足以支撑此次分配, 则从 CMA 区域中预留的内存中进行分配. + + 3.4 如果前面流程都失败了, 那么说明当前 MIGRATE_TYPE 中已经没有足够的连续物理页面, 那么进入 fallback 流程, 尝试从其他 MIGRATE_TYPE 中窃取内存. + + +4. 通过 [`check_new_pages`](https://elixir.bootlin.com/linux/v5.10/source/mm/page_alloc.c#L2253) 检查获取到的内存页是否满足要求. 伙伴系统返回了所获取的的物理页面块第一个页面的 page 结构体, 而 [`check_new_pages`](https://elixir.bootlin.com/linux/v5.10/source/mm/page_alloc.c#L2253) 则需要检查所有的页面. + + +### 3.4.2 rmqueue_pcplist +------- + +### 3.4.3 ` __rmqueue` +------- + + +### 3.4.4 `__rmqueue_smallest` +------- + + +### 3.4.5 __rmqueue_fallback \ No newline at end of file diff --git a/study/kernel/02-memory/04-buddy/04-alloc_page/rmqueue.excalidraw b/study/kernel/02-memory/04-buddy/04-alloc_page/rmqueue.excalidraw new file mode 100644 index 0000000..dd166df --- /dev/null +++ b/study/kernel/02-memory/04-buddy/04-alloc_page/rmqueue.excalidraw @@ -0,0 +1,998 @@ +{ + "type": "excalidraw", + "version": 2, + "source": "https://excalidraw.com", + "elements": [ + { + "type": "rectangle", + "version": 379, + "versionNonce": 164424124, + "isDeleted": false, + "id": "9IvlR6rtK0rzm1TCHDDsP", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 378, + "y": 182, + "strokeColor": "#000000", + "backgroundColor": "#82c91e", + "width": 107.00000000000001, + "height": 37.00000000000002, + "seed": 765837636, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [ + "hC97PmiA9GpSyZPfCGdGv", + "3SxvWp5giaQFb8YaHyiTB", + "QN25t4_XOP7-HRxAuV7Y2", + "DhBK1onobgdtoteMzJ3RY", + "EVuGS3oXm7jYXCy8DsY2V", + "7-zXi5_a33f7uUIc7_j_9", + "OWrGRSWgDTVld8aCb9xUP", + "E-FoU4T3WQM9Nik2oNqPM" + ] + }, + { + "type": "text", + "version": 174, + "versionNonce": 1964810244, + "isDeleted": false, + "id": "Wx-hvImhVXOFGx-oGeA52", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 388, + "y": 185, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "width": 89, + "height": 27, + "seed": 538015428, + "groupIds": [], + "strokeSharpness": "round", + "boundElementIds": [ + "QN25t4_XOP7-HRxAuV7Y2", + "VGI_QGiy6and7H_GNB7Pc", + "nGXxbhYzARGmuHcQu1X-m" + ], + "fontSize": 20, + "fontFamily": 1, + "text": "rmqueue", + "baseline": 20, + "textAlign": "left", + "verticalAlign": "top" + }, + { + "type": "rectangle", + "version": 576, + "versionNonce": 1887457852, + "isDeleted": false, + "id": "TNkLg1TOf37KA0pcVLDMi", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 511.5, + "y": 251.5, + "strokeColor": "#000000", + "backgroundColor": "#15aabf", + "width": 183.00000000000003, + "height": 39.99999999999998, + "seed": 27987780, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [ + "hC97PmiA9GpSyZPfCGdGv", + "3SxvWp5giaQFb8YaHyiTB" + ] + }, + { + "type": "text", + "version": 397, + "versionNonce": 336723844, + "isDeleted": false, + "id": "kxjWlvYgRG_dElXJezNuV", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 522.5, + "y": 254.5, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "width": 162, + "height": 27, + "seed": 230913788, + "groupIds": [], + "strokeSharpness": "round", + "boundElementIds": [ + "EVuGS3oXm7jYXCy8DsY2V", + "_vUFgioABe191JEmcUjY2", + "wNvvkoWG2WSBsLaBj3WJl" + ], + "fontSize": 20, + "fontFamily": 1, + "text": "rmqueue_pcplist", + "baseline": 20, + "textAlign": "left", + "verticalAlign": "top" + }, + { + "type": "text", + "version": 409, + "versionNonce": 2083483396, + "isDeleted": false, + "id": "53NRWV1iZ68BRcjBWbdFg", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 462.5, + "y": 230.5, + "strokeColor": "#000000", + "backgroundColor": "#82c91e", + "width": 344, + "height": 22, + "seed": 1949233604, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [ + "7-zXi5_a33f7uUIc7_j_9" + ], + "fontSize": 16, + "fontFamily": 1, + "text": "order == 0 时,优先从 per_cpu_pages 中分配", + "baseline": 16, + "textAlign": "center", + "verticalAlign": "top" + }, + { + "type": "rectangle", + "version": 685, + "versionNonce": 872805180, + "isDeleted": false, + "id": "yHK4ffpLCd2qf1JulLp3L", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 513.5, + "y": 331.5, + "strokeColor": "#000000", + "backgroundColor": "#15aabf", + "width": 224, + "height": 30.00000000000002, + "seed": 1411783548, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [ + "hC97PmiA9GpSyZPfCGdGv", + "3SxvWp5giaQFb8YaHyiTB" + ] + }, + { + "type": "text", + "version": 261, + "versionNonce": 1844637316, + "isDeleted": false, + "id": "NFXSY2BUtyeHnNHZYlOTW", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 515.5, + "y": 333.5, + "strokeColor": "#000000", + "backgroundColor": "#82c91e", + "width": 199, + "height": 27, + "seed": 1348933628, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [ + "BPvtJ4i7uXdRMiNM_nAFL", + "m2-2gfSFQsgKHJlzp6KqU", + "GVh2TCiCWV9n7anJ5A4CR" + ], + "fontSize": 20, + "fontFamily": 1, + "text": " __rmqueue_smallest", + "baseline": 20, + "textAlign": "center", + "verticalAlign": "middle" + }, + { + "type": "rectangle", + "version": 883, + "versionNonce": 1780121092, + "isDeleted": false, + "id": "-96344qAEjqI8sI6ZWnvc", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 514, + "y": 404.5, + "strokeColor": "#000000", + "backgroundColor": "#15aabf", + "width": 120, + "height": 41.00000000000002, + "seed": 824473156, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [ + "hC97PmiA9GpSyZPfCGdGv", + "3SxvWp5giaQFb8YaHyiTB" + ] + }, + { + "type": "text", + "version": 443, + "versionNonce": 962024508, + "isDeleted": false, + "id": "SGgwcKmTPIqWcsKz4DARv", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 471.8065379991425, + "y": 308.866507744361, + "strokeColor": "#000000", + "backgroundColor": "#82c91e", + "width": 327, + "height": 22, + "seed": 1804539644, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [], + "fontSize": 16, + "fontFamily": 1, + "text": "order > 0 && alloc_flags & ALLOC_HARDER", + "baseline": 16, + "textAlign": "center", + "verticalAlign": "top" + }, + { + "type": "text", + "version": 399, + "versionNonce": 630991364, + "isDeleted": false, + "id": "6p-QriP3xJxuHL1UnmPbx", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 524, + "y": 413, + "strokeColor": "#000000", + "backgroundColor": "#82c91e", + "width": 91, + "height": 22, + "seed": 1330976388, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [ + "8wHI9J5ManjEE62c5Xi8d", + "tJmcF5bSos6g968ybXjGM", + "qgiKz46xXy9aGJWX0h2iq" + ], + "fontSize": 16, + "fontFamily": 1, + "text": " __rmqueue", + "baseline": 16, + "textAlign": "left", + "verticalAlign": "top" + }, + { + "type": "arrow", + "version": 266, + "versionNonce": 1513708548, + "isDeleted": false, + "id": "wNvvkoWG2WSBsLaBj3WJl", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 414, + "y": 272, + "strokeColor": "#000000", + "backgroundColor": "#82c91e", + "width": 100, + "height": 1, + "seed": 252216636, + "groupIds": [], + "strokeSharpness": "round", + "boundElementIds": [], + "startBinding": null, + "endBinding": { + "elementId": "kxjWlvYgRG_dElXJezNuV", + "focus": -0.41194968553459116, + "gap": 8.5 + }, + "points": [ + [ + 0, + 0 + ], + [ + 100, + 1 + ] + ], + "lastCommittedPoint": null, + "startArrowhead": null, + "endArrowhead": "arrow" + }, + { + "type": "arrow", + "version": 378, + "versionNonce": 94197308, + "isDeleted": false, + "id": "GVh2TCiCWV9n7anJ5A4CR", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 418, + "y": 346, + "strokeColor": "#000000", + "backgroundColor": "#82c91e", + "width": 94, + "height": 0, + "seed": 581073468, + "groupIds": [], + "strokeSharpness": "round", + "boundElementIds": [], + "startBinding": null, + "endBinding": { + "elementId": "NFXSY2BUtyeHnNHZYlOTW", + "focus": 0.07407407407407407, + "gap": 3.5 + }, + "points": [ + [ + 0, + 0 + ], + [ + 94, + 0 + ] + ], + "lastCommittedPoint": null, + "startArrowhead": null, + "endArrowhead": "arrow" + }, + { + "type": "arrow", + "version": 213, + "versionNonce": 754530820, + "isDeleted": false, + "id": "AIlar2I208RnY8I97n2lW", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 409, + "y": 396, + "strokeColor": "#000000", + "backgroundColor": "#82c91e", + "width": 0, + "height": 0, + "seed": 1652995900, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [], + "startBinding": null, + "endBinding": null, + "points": [ + [ + 0, + 0 + ], + [ + 0, + 0 + ] + ], + "lastCommittedPoint": null, + "startArrowhead": null, + "endArrowhead": "arrow" + }, + { + "type": "arrow", + "version": 158, + "versionNonce": 424368516, + "isDeleted": false, + "id": "_Z85X20zEigJ9WheVC4TP", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 404, + "y": 301, + "strokeColor": "#000000", + "backgroundColor": "#82c91e", + "width": 0, + "height": 0, + "seed": 66158724, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [], + "startBinding": null, + "endBinding": null, + "points": [ + [ + 0, + 0 + ], + [ + 0, + 0 + ] + ], + "lastCommittedPoint": null, + "startArrowhead": null, + "endArrowhead": "arrow" + }, + { + "type": "arrow", + "version": 473, + "versionNonce": 86870276, + "isDeleted": false, + "id": "tJmcF5bSos6g968ybXjGM", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 424, + "y": 424, + "strokeColor": "#000000", + "backgroundColor": "#82c91e", + "width": 90, + "height": 2, + "seed": 1528135172, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [], + "startBinding": null, + "endBinding": { + "elementId": "6p-QriP3xJxuHL1UnmPbx", + "focus": -0.26919518963922295, + "gap": 10 + }, + "points": [ + [ + 0, + 0 + ], + [ + 90, + 2 + ] + ], + "lastCommittedPoint": null, + "startArrowhead": null, + "endArrowhead": "arrow" + }, + { + "type": "rectangle", + "version": 808, + "versionNonce": 1427011900, + "isDeleted": false, + "id": "cqO9FQx2GWwuZDpygL6jj", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 634.5, + "y": 489.5, + "strokeColor": "#000000", + "backgroundColor": "#7950f2", + "width": 234, + "height": 36.00000000000002, + "seed": 1619192708, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [ + "hC97PmiA9GpSyZPfCGdGv", + "3SxvWp5giaQFb8YaHyiTB" + ] + }, + { + "type": "text", + "version": 338, + "versionNonce": 605931652, + "isDeleted": false, + "id": "-gyoX28x_QgCjD_myhXsm", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 635, + "y": 493, + "strokeColor": "#000000", + "backgroundColor": "#7950f2", + "width": 199, + "height": 27, + "seed": 642194948, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [], + "fontSize": 20, + "fontFamily": 1, + "text": " __rmqueue_smallest", + "baseline": 20, + "textAlign": "left", + "verticalAlign": "top" + }, + { + "type": "rectangle", + "version": 862, + "versionNonce": 199487932, + "isDeleted": false, + "id": "nQtKToI1AW8PUIaD7K9P5", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 634.5, + "y": 568.5, + "strokeColor": "#000000", + "backgroundColor": "#7950f2", + "width": 290, + "height": 34.00000000000002, + "seed": 1300465412, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [ + "hC97PmiA9GpSyZPfCGdGv", + "3SxvWp5giaQFb8YaHyiTB" + ] + }, + { + "type": "text", + "version": 284, + "versionNonce": 165287940, + "isDeleted": false, + "id": "jBsqF_pfLMV9PSeMp8cE_", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 637, + "y": 574, + "strokeColor": "#000000", + "backgroundColor": "#7950f2", + "width": 257, + "height": 27, + "seed": 1555160508, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [ + "nXlvIxuUNjHKjqylw5FL4" + ], + "fontSize": 20, + "fontFamily": 1, + "text": " __rmqueue_cma_fallback", + "baseline": 20, + "textAlign": "left", + "verticalAlign": "top" + }, + { + "type": "rectangle", + "version": 875, + "versionNonce": 195539644, + "isDeleted": false, + "id": "ovD1NEHcIKU_d-EGCW3XX", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 636, + "y": 649.5, + "strokeColor": "#000000", + "backgroundColor": "#7950f2", + "width": 226.00000000000003, + "height": 36.00000000000003, + "seed": 678574780, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [ + "hC97PmiA9GpSyZPfCGdGv", + "3SxvWp5giaQFb8YaHyiTB" + ] + }, + { + "type": "text", + "version": 282, + "versionNonce": 703522564, + "isDeleted": false, + "id": "-ITaOCtyOnAkWh5WOleWH", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 645, + "y": 656, + "strokeColor": "#000000", + "backgroundColor": "#7950f2", + "width": 197, + "height": 27, + "seed": 567462276, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [ + "4mBtcAiw5CUOUe6YluPgy" + ], + "fontSize": 20, + "fontFamily": 1, + "text": "__rmqueue_fallback", + "baseline": 20, + "textAlign": "left", + "verticalAlign": "top" + }, + { + "type": "arrow", + "version": 229, + "versionNonce": 1678335036, + "isDeleted": false, + "id": "mbSPsFQGLabkrdEbOU7v_", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 562, + "y": 508, + "strokeColor": "#000000", + "backgroundColor": "#7950f2", + "width": 75, + "height": 3, + "seed": 1435148932, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [], + "startBinding": null, + "endBinding": null, + "points": [ + [ + 0, + 0 + ], + [ + 75, + 3 + ] + ], + "lastCommittedPoint": null, + "startArrowhead": null, + "endArrowhead": "arrow" + }, + { + "type": "arrow", + "version": 324, + "versionNonce": 1602909372, + "isDeleted": false, + "id": "nXlvIxuUNjHKjqylw5FL4", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 560, + "y": 585, + "strokeColor": "#000000", + "backgroundColor": "#7950f2", + "width": 74, + "height": 4, + "seed": 1953920060, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [], + "startBinding": null, + "endBinding": { + "elementId": "jBsqF_pfLMV9PSeMp8cE_", + "focus": -0.42101784534038333, + "gap": 3 + }, + "points": [ + [ + 0, + 0 + ], + [ + 74, + 4 + ] + ], + "lastCommittedPoint": null, + "startArrowhead": null, + "endArrowhead": "arrow" + }, + { + "type": "arrow", + "version": 288, + "versionNonce": 202458372, + "isDeleted": false, + "id": "4mBtcAiw5CUOUe6YluPgy", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 561, + "y": 670, + "strokeColor": "#000000", + "backgroundColor": "#7950f2", + "width": 80, + "height": 1, + "seed": 308273412, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [], + "startBinding": null, + "endBinding": { + "elementId": "-ITaOCtyOnAkWh5WOleWH", + "focus": 0.12091641917691984, + "gap": 4 + }, + "points": [ + [ + 0, + 0 + ], + [ + 80, + -1 + ] + ], + "lastCommittedPoint": null, + "startArrowhead": null, + "endArrowhead": "arrow" + }, + { + "type": "text", + "version": 291, + "versionNonce": 747484036, + "isDeleted": false, + "id": "CsYKE_3jWF5V3R5y6GBTN", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 584, + "y": 545, + "strokeColor": "#000000", + "backgroundColor": "#7950f2", + "width": 575, + "height": 22, + "seed": 1084431036, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [], + "fontSize": 16, + "fontFamily": 1, + "text": "当超过一半空闲内存位于 CMA 区域时或者前面流程分配失败时,从 CMA 中分配", + "baseline": 16, + "textAlign": "left", + "verticalAlign": "top" + }, + { + "type": "text", + "version": 627, + "versionNonce": 1929131708, + "isDeleted": false, + "id": "zH2Un5WTg9GDD12gJUqMt", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 451.5, + "y": 384, + "strokeColor": "#000000", + "backgroundColor": "#82c91e", + "width": 267, + "height": 22, + "seed": 1744219652, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [], + "fontSize": 16, + "fontFamily": 1, + "text": "常规方式,从伙伴系统 buddy 中分配", + "baseline": 16, + "textAlign": "center", + "verticalAlign": "top" + }, + { + "type": "text", + "version": 320, + "versionNonce": 1930732292, + "isDeleted": false, + "id": "gRR3lNSFA-B-picIH-WJ0", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 591.5, + "y": 460, + "strokeColor": "#000000", + "backgroundColor": "#7950f2", + "width": 209, + "height": 22, + "seed": 1280669572, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [], + "fontSize": 16, + "fontFamily": 1, + "text": "从大的 order 块中开始切蛋糕", + "baseline": 16, + "textAlign": "left", + "verticalAlign": "top" + }, + { + "type": "text", + "version": 497, + "versionNonce": 974234244, + "isDeleted": false, + "id": "4KQ-1ZwrE_V8qtiqt6MFH", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 584.5, + "y": 629, + "strokeColor": "#000000", + "backgroundColor": "#7950f2", + "width": 362, + "height": 22, + "seed": 603635332, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [], + "fontSize": 16, + "fontFamily": 1, + "text": "fallback 流程,从其他 MIGRATE_TYPE 中窃取内存", + "baseline": 16, + "textAlign": "left", + "verticalAlign": "top" + }, + { + "type": "line", + "version": 115, + "versionNonce": 675459588, + "isDeleted": false, + "id": "AYw13fUpU_UoXZ0EYvq9p", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 419, + "y": 219, + "strokeColor": "#000000", + "backgroundColor": "#7950f2", + "width": 4, + "height": 208, + "seed": 73932164, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [], + "startBinding": null, + "endBinding": null, + "points": [ + [ + 0, + 0 + ], + [ + 4, + 208 + ] + ], + "lastCommittedPoint": null, + "startArrowhead": null, + "endArrowhead": null + }, + { + "type": "line", + "version": 74, + "versionNonce": 63576892, + "isDeleted": false, + "id": "ORmEe3CauPujB0KUl7Dd6", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 559.5, + "y": 445.25, + "strokeColor": "#000000", + "backgroundColor": "#7950f2", + "width": 0, + "height": 224, + "seed": 97810692, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [], + "startBinding": null, + "endBinding": null, + "points": [ + [ + 0, + 0 + ], + [ + 0, + 224 + ] + ], + "lastCommittedPoint": null, + "startArrowhead": null, + "endArrowhead": null + } + ], + "appState": { + "gridSize": null, + "viewBackgroundColor": "#ffffff" + } +} \ No newline at end of file diff --git a/study/kernel/02-memory/04-buddy/04-alloc_page/rmqueue.png b/study/kernel/02-memory/04-buddy/04-alloc_page/rmqueue.png new file mode 100644 index 0000000..43155e8 Binary files /dev/null and b/study/kernel/02-memory/04-buddy/04-alloc_page/rmqueue.png differ