> For the complete documentation index, see [llms.txt](https://richardweiyang-2.gitbook.io/kernel-exploring/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://richardweiyang-2.gitbook.io/kernel-exploring/nei-cun-guan-li/00-memory_a_bottom_up_view/50-challenge_evolution.md).

# 挑战和进化

在没有深入研究内存子系统之前总是觉得这个子系统应该已经经过了千锤百炼，固若金汤了。

但是当深入研究之后就会发现，随着使用场景、硬件更新，原有内核的实现就暴露出了不同的问题。

在这里我尝试做一点总结。

## 扩展性

内存管理作为系统中最为重要的模块，其处理性能直接影响到整个系统的表现。经过这么多年社区各路大神的打磨，其中有不少值得我们借鉴的地方。

扩展性是一个非常有意思的话题，还希望各路大侠多多指教。

先来看看有那些设计层次的方法值得借鉴。

[扩展性的设计和实现](/kernel-exploring/nei-cun-guan-li/00-memory_a_bottom_up_view/50-challenge_evolution/51-scalability_design_implementation.md)

再来看一个实际的例子。为了加速页的分配和回收，减少多cpu之间对伙伴系统的竞争，内核给每个zone增加了per\_cpu\_pageset。

\[per\_cpu\_pageset]\[7]

## 海量内存

仔细想象海量内存是对扩展性挑战的一个原因，正因为内存容量的增大导致了扩展性的瓶颈。

这一小节和上一小节观察的重点不同。而是主要观察内存控制结构struct page的空间分配和初始化。

首先我们来看空间分配上为了应对海量内存做的一步步演进。

[海量内存](/kernel-exploring/nei-cun-guan-li/00-memory_a_bottom_up_view/50-challenge_evolution/52-where_is_page_struct.md)

其次随着内存容量的增加，需要初始化的page struct也增加。为此内核引入了延迟初始化。

[延迟初始化](/kernel-exploring/nei-cun-guan-li/00-memory_a_bottom_up_view/50-challenge_evolution/54-defer_init.md)

## 内存热插拔

最近有review了相关的patch，发现自己之前竟然没有总结这一块。看来看去不知道放在哪里，就先放在这里吧～

[内存热插拔](/kernel-exploring/nei-cun-guan-li/00-memory_a_bottom_up_view/50-challenge_evolution/53-memory_hotplug.md)

## 连续内存分配器

不少设备需要很大，如10M，的连续内存。现有的page allocator无法满足这样的需求。

所以内核中增加了[连续内存分配器](/kernel-exploring/nei-cun-guan-li/00-memory_a_bottom_up_view/50-challenge_evolution/55-cma.md)。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://richardweiyang-2.gitbook.io/kernel-exploring/nei-cun-guan-li/00-memory_a_bottom_up_view/50-challenge_evolution.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
