网址:https://www.kernel.org/doc/html/latest/vm/page_migration.html

Page migration allows moving the physical location of pages between nodes in a NUMA system while the process is running. This means that the virtual addresses that the process sees do not change. However, the system rearranges the physical location of those pages.

The main intent of page migration is to reduce the latency of memory accesses by moving pages near to the processor where the process accessing that memory is running.

How migrate_pages() works
migrate_pages() does several passes over its list of pages. A page is moved if all references to a page are removable at the time. The page has already been removed from the LRU via isolate_lru_page() and the refcount is increased so that the page cannot be freed while page migration occurs.
Steps:
1. Lock the page to be migrated.
2. Ensure that writeback is complete.
3. Lock the new page that we want to move to. It is locked so that accesses to this (not yet up-to-date) page immediately block while the move is in progress.
4. All the page table references to the page are converted to migration entries. This decreases the mapcount of a page. If the resulting mapcount is not zero then we do not migrate the page. All user space processes that attempt to access the page will now wait on the page lock or wait for the migration page table entry to be removed.
5. The i_pages lock is taken. This will cause all processes trying to access the page via the mapping to block on the spinlock.
6. The refcount of the page is examined and we back out if references remain. Otherwise, we know that we are the only one referencing this page.
7. The radix tree is checked and if it does not contain the pointer to this page then we back out because someone else modified the radix tree.
8. The new page is prepped with some settings from the old page so that accesses to the new page will discover a page with the correct settings.
9. The radix tree is changed to point to the new page.
10. The reference count of the old page is dropped because the address space reference is gone. A reference to the new page is established because the new page is referenced by the address space.
11. The i_pages lock is dropped. With that lookups in the mapping become possible again. Processes will move from spinning on the lock to sleeping on the locked new page.
12. The page contents are copied to the new page.
13. The remaining page flags are copied to the new page.
14. The old page flags are cleared to indicate that the page does not provide any information anymore.
15. Queued up writeback on the new page is triggered.
16. If migration entries were inserted into the page table, then replace them with real ptes. Doing so will enable access for user space processes not already waiting for the page lock.
17. The page locks are dropped from the old and new page. Processes waiting on the page lock will redo their page faults and will reach the new page.
18. The new page is moved to the LRU and can be scanned by the swapper, etc. again.

Page migration相关推荐

  1. linux cuda 异常退出,cudaErrorCudartUnloading问题排查及建议方案

    原文请猛戳这里 敲黑板划重点--顺求异构计算/高性能计算/CUDA/ARM优化类开发职位 最近一段时间一直在负责做我厂神经网络前向框架库的优化,前几天接了一个bug report,报错信息大体是这样的 ...

  2. linux内核(4.17.10)配置项详解(x86)

    64-bit kernel--支持64位 General setup--通用设置 Cross-compiler tool prefix--交叉编译工具前缀 Local version-append t ...

  3. linux内核编译如何选择cpu类型,Ubuntu内核编译和CPU Hot-Plug特性配置全过程及遇到问题记录...

    最近编译Palacios需要linux的内核支持cpu Hot-Plug(内存热插拔)特性,无奈我机器上安装的Ubuntu10.04系统默认不支持内存热插拔特性,所以需要修改配置文件并重新编译linu ...

  4. linux内核那些事之mempolicy(1)

    mempolicy为内核分配内存策略管理模块,主要是在numa系统中用于根据指定的内存分配策略决定分配的内存所处的NUMA节点中: In the Linux kernel, "memory ...

  5. linux内核那些事之buddy(anti-fragment机制)(4)

    程序运行过程中,有些内存是短暂的驻留 用完一段时间之后就可以将内存释放以供后面再次使用,但是有些内存一旦申请之后,会长期使用而得不到释放.长久运行有可能造成碎片.以<professional l ...

  6. linux内核那些事之ZONE

    struct zone 从linux 三大内存模型中可以了解到,linux内核将物理内存按照实际使用用途划分成不同的ZONE区域,ZONE管理在物理内存中占用重要地位,在内核中对应的结构为struct ...

  7. Tesla P100

    特色与介绍 将人工智能应用于自动驾驶汽车,预测未来气候,研发治疗癌症的新型药物,这些都是如今需要克服的全球重大挑战,但是,必须进行海量的计算才能实现相应目标.当今的数据中心依赖大量互连的通用计算节点, ...

  8. Kernel Samepage Merging | 同页合并

    https://www.kernel.org/doc/html/latest/admin-guide/mm/ksm.html 示例:https://github.com/Rtoax/test/tree ...

  9. 异构内存管理 Heterogeneous Memory Management (HMM)

    https://www.kernel.org/doc/html/latest/vm/hmm.html 目录 异构内存管理 (HMM) 使用特定于设备的内存分配器的问题 I/O 总线.设备内存特性 共享 ...

  10. NUMA全称 Non-Uniform Memory Access,译为“非一致性内存访问”,积极NUMA内存策略

    目录 NUMA的诞生背景 NUMA构架细节 上机演示 NUMA Memory Policy What is NUMA Memory Policy? Memory Policy Concepts Sco ...

最新文章

  1. 2-SAT 问题 详解
  2. Adaboost 算法的原理与推导
  3. 监督学习应用与梯度下降
  4. python难度如何_入门Python学习难吗怎样规划学习路线
  5. 百练OJ:4148:生理周期
  6. 本科、硕士、博士之间的差距!
  7. laravel-神奇的服务容器(转)
  8. MongoDB:Map-Reduce
  9. 卡饭论坛--金山毒霸/卫士 广告过滤规则(附纯文本版) [2015.7.1] 党生日版
  10. excel中统计COUNTIFS的值为0
  11. oracle无法进入nomount状态,数据库进入nomount状态
  12. 你不可不知的《哈利波特》秘密(三)
  13. 原生js代码实现图片放大境效果
  14. springboot(九):定时任务
  15. 六、MySQL 数据库练习题1(包含前5章练习题目及答案)
  16. python的endswith()的用法及实例
  17. 两位数合并成一个四位数的C++代码
  18. matlab win32错误,尝试运行Matlab-Compiler-Runtime应用程序时Windows 7中出现SxS错误
  19. Java中实现原子操作
  20. 目前月薪存一百万需要多久?

热门文章

  1. MongoDb进阶实践之七 MongoDB的索引入门
  2. opencv 应用程序无法正常启动0xc000007b
  3. centos8安装和使用fmmpeg
  4. unity学习笔记-Avpro和安卓结合
  5. 谁说bug解决不了?试试这个使用日志法
  6. 英语3500词(15/20)crime主题(2022.1.27)
  7. 摄影构图学83年绝版_学手机摄影最好要知道的81条忠告!都是大实话
  8. 基于Proteus学习单片机系列(五)——定时器实现电子表
  9. window启动activemq失败
  10. windows 无法停止ics_Windows10系统不能启动ICS服务致无法连接WiFi热点的三种解决方法...