mirror of
https://github.com/gatieme/LDD-LinuxDeviceDrivers.git
synced 2026-09-26 07:24:00 +08:00
description/memory: HugeTLB pool
This commit is contained in:
@@ -2447,11 +2447,26 @@ HugeTLBFS 则用于向用户提供一套基于文件系统的巨页使用界面,
|
||||
|
||||
其次看 HugeTLBFS 模块:
|
||||
|
||||
### 7.1.2 HugeTLB pool
|
||||
### 7.1.2 HugeTLB Pool
|
||||
-------
|
||||
|
||||
commit [b45b5bd65f66 ("hugepage: Strict page reservation for hugepage inodes")](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b45b5bd65f668a665db40d093e4e1fe563533608)
|
||||
|
||||
|
||||
commit [a43a8c39bbb4 ("tightening hugetlb strict accounting")](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a43a8c39bbb493c9e93f6764b350de2e33e18e92)
|
||||
|
||||
|
||||
|
||||
随后 v2.6.24 HugeTLB 又引入了 pool 和 overcommit.
|
||||
|
||||
|
||||
|
||||
|
||||
由于匿名映射 MAP_PRIVATE 不使用保留的大面内存, 因此分配可能由于 HugeTLB 池太小而失败. commit [7893d1d505d5 ("hugetlb: Try to grow hugetlb pool for MAP_PRIVATE mappings")](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7893d1d505d59db9d4f35165c8b6d3c6dff40a32) 引入动态扩展 HugeTLB 页面池的的机制.<br>1. 尝试通过 `alloc_buddy_huge_page()` 从 buddy 分配器中获取一个剩余的大页.<br>2. 通过 surplus_huge_pages 和 surplus_huge_pages_node 来记录动态扩展的页面.<br>3. 那么这种情况下如果通过 nr_hugepages sysctl 动态修改 HugeTLB 页面的数量, 则通过 `set_max_huge_pages()-=>adjust_pool_surplus()` 来完成动态扩展.
|
||||
|
||||
commit [e4e574b767ba ("hugetlb: Try to grow hugetlb pool for MAP_SHARED mappings")](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e4e574b767ba63101cfda2b42d72f38546319297)
|
||||
|
||||
|
||||
| 时间 | 作者 | 特性 | 描述 | 是否合入主线 | 链接 |
|
||||
|:----:|:----:|:---:|:----:|:---------:|:----:|
|
||||
| 2007/10/16 | Adam Litke <agl@us.ibm.com> | [hugetlb_dynamic_pool](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/?id=af767cbdd78f293485c294113885d95e7f1da123) | 引入 dynamic_pool. | v1 ☑ [2.6.24-rc1](https://lwn.net/Articles/255649) | [HISTORY COMMIT 0/6](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/?id=af767cbdd78f293485c294113885d95e7f1da123) |
|
||||
@@ -2488,6 +2503,13 @@ HugeTLBFS 则用于向用户提供一套基于文件系统的巨页使用界面,
|
||||
### 7.1.4 More huge page sizes
|
||||
-------
|
||||
|
||||
在 2.6.25 版本的时候, 通过 commit [4ec161cf73bc ("Add hugepagesz boot-time parameter")](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=4ec161cf73bc0b4e5c36843638ef9171896fc0b9) 添加了一个启动参数 hugepagesz, 可以指定预留的 HugeTLB 大页的 pagesize.
|
||||
|
||||
|
||||
| 时间 | 作者 | 特性 | 描述 | 是否合入主线 | 链接 |
|
||||
|:----:|:----:|:---:|:----:|:---------:|:----:|
|
||||
| 2008/05/26 | Andi Kleen <ak@suse.de>/Nick Piggin <npiggin@suse.de> | [multi size, giant hugetlb support, 1GB for x86, 16GB for powerpc](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/?id=0d9ea75443dc7e37843e656b8ebc947a6d16d618) | 多种 hugepage sizes 的 HugeTLB 的支持. 引入了 [struct hstate](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a5516438959d90b071ff0a484ce4f3f523dc3152) 来管理不同 page size 的 HugeTLB. 每个 pagesize 的页面由 [hstate 自己的链表](https://elixir.bootlin.com/linux/v2.6.27/source/mm/hugetlb.c#L384)管理.<br>引入了 [PUD 级别](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ceb868796181dc95ea01a110e123afd391639873) 和 [巨页(> MAX_ORDER)](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=aa888a74977a8f2120ae9332376e179c39a6b07d) 的 Huge Page. 随后对 [x86_64](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=39c11e6c05b7fedbf7ed4df3908b25f622d56204) 以及 [POWERPC](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0d9ea75443dc7e37843e656b8ebc947a6d16d618) 等架构做了支持. POWERPC 更是支持了 [16GB 级别的巨页](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ec4b2c0c8312d1118c2acd00c89988ecf955d5cc). 可以通过启动参数 hugepagesz 参数指定大页的大小. | v1 ☑ 2.6.27-rc1 | [LKML 00/23](https://lore.kernel.org/all/20080525142317.965503000@nick.local0.net) |
|
||||
|
||||
|
||||
huge page 最开始只支持 PMD 级别(基础页 4K, 则 PMD 级别为 2MB)的大页, 自 3.8 版本加入这个 [commit 42d7395feb56 ("mm: support more pagesizes for MAP_HUGETLB/SHM_HUGETLB")](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=42d7395feb56f0655cd8b68e06fc6063823449f8) 之后, 利用 shmget()/mmap() 的 flag 参数中未使用的 bits, 可以支持其他的 huge page 大小(比如 1GB).
|
||||
|
||||
|
||||
@@ -806,6 +806,9 @@ NUMA 机器一个重要特性就是不同 node 之间的内存访问速度有差
|
||||
| 2021/10/27 | Gang Li <ligang.bdlg@bytedance.com> | [sched/numa: add per-process numa_balancing](https://lkml.org/lkml/2021/10/27/517) | 这个补丁在 prctl 中添加了一个新的 api PR_NUMA_BALANCING 来控制当个进程参与和禁止 numa_balancing. 在执行 numa_balancing 时, 大量的页面错误会导致性能损失. 因此, 那些关心最坏情况下性能的进程需要禁用 numa_balancing. 相反, 另一些则允许暂时的性能损失以换取更高的平均性能, 因此启用 numa 平衡对它们来说更好. 但是当前 numa balancing 只能由 `/proc/sys/kernel/numa_balancing` 全局控制. 因此这个特性希望禁用/启用每个进程的 numa_balancing. 在 mm_struct 下添加 numa_balancing. 然后在 task_tick_numa 中使用来控制. mm ->numa_balancing 仅在全局 numa_balancing 启用时有效. 当全局 numa_balancing 被禁用时, mm->numa_blancing 不会改变, 当你想要获得进程 numa_balancing 状态时, 你总是会得到 0, 并且当你使用 prctl set 它时, 内核将返回 err. | v1 ☐ | [LKML](https://lkml.org/lkml/2021/10/27/517) |
|
||||
| 2014/05/14 | Rik van Riel <riel@redhat.com> | [sched/numa: Allow task switch if load imbalance improves](https://linuxplumbersconf.org/event/4/contributions/480) | 目前 NUMA 平衡代码只允许在 NUMA 节点上的负载处于平衡状态时在 NUMA 节点之间移动任务. 当负载开始不平衡时, 它就崩溃了. 因此这个补丁引入 load_too_imbalanced() 来判定, 如果不平衡较小, 或者新的不平衡小于原来的不平衡, 则允许在 NUMA 节点之间移动任务. | v1 ☑ 3.16-rc1 | [COMMIT](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e63da03639cc9e6e83b62e7ef8ffdbb92421416a) |
|
||||
| 2018/09/21 | Srikar Dronamraju <srikar@linux.vnet.ibm.com> | [sched/numa: Avoid task migration for small NUMA improvement](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6fd98e775f24fd41520928d345f5db3ff52bb35d) | 如果 NUMAC 层次的任务迁移带来的改进非常小(小于 SMALLIMP), 那么应该尽量避免任务迁移. 否则可能会带来 pingpong(进程来回迁移颠簸), 甚至 cache-miss 引起的性能下降. | v1 ☑ 4.19-rc7 | [COMMIT](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6fd98e775f24fd41520928d345f5db3ff52bb35d) |
|
||||
| 2022/01/28 | Paul Gortmaker <paul.gortmaker@windriver.com> | [sched/numa: Process Adaptive autoNUMA](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/?id=abedf8e2419fb873d919dd74de2e84b510259339) | NA | v0 ☑ 4.6-rc1 | [LKML v0,0/5](https://lkml.org/lkml/2022/1/28/16), [LORE](https://lore.kernel.org/lkml/20220128052851.17162-1-bharata@amd.com) |
|
||||
|
||||
|
||||
|
||||
|
||||
## 4.4 rework_load_balance
|
||||
|
||||
Reference in New Issue
Block a user