All of the physical pages in the system are described by the mem_map  data structure which is a list of mem_map_t 
 
typedef struct page { 
// these must be first (free area handling)
struct page        *next;
struct page        *prev;
struct inode       *inode;
unsigned long      offset;
struct page        *next_hash;
atomic_t           count;        //本页使用者计数
unsigned           flags;    // atomic flags, some possibly
                                   updated asynchronously
unsigned           dirty:16, 
                          age:8;        //描述本页的年龄,用来判断该页是否为淘汰或交换的好的候选
struct wait_queue *wait;
struct page        *prev_hash;
struct buffer_head *buffers;
unsigned long      swap_unlock_entry;
unsigned long      map_nr;   // page->map_nr == page - mem_map 物理页的页帧号
} mem_map_t;
 

Each mem_map_t  describes a single physical page in the system. Important fields (so far as memory management is concerned) are:

count
This is a count of the number of users of this page. The count is greater than one when the page is shared between many processes,
age
This field describes the age of the page and is used to decide if the page is a good candidate for discarding or swapping,
map_nr
This is the physical PFN that this mem_map_t  describes.
 
allocation example:
The allocation algorithm first searches for blocks of pages of the size requested. It follows the chain of free pages that is queued on the list element of the free_area  data structure. If no blocks of pages of the requested size are free, blocks of the next size (which is twice that of the size requested) are looked for. This process continues until all of the free_area  has been searched or until a block of pages has been found. If the block of pages found is larger than that requested it must be broken down until there is a block of the right size. Because the blocks are each a power of 2 pages big then this breaking down process is easy as you simply break the blocks in half. The free blocks are queued on the appropriate queue and the allocated block of pages is returned to the caller.
 
deallocation example:
 if PFN 1 were to be freed, then that would be combined with the already free PFN 0 and queued onto element 1 of the free_area  as a free block of size 2 pages.
 
 

linux page allocation and deallocation的更多相关文章

  1. warn_alloc():page allocation failure问题分析

    关键词:warn_alloc().__GFP_XXX.order.CMA等等. 在内存申请的时候经常会遇到类似“ xxx: page allocation failure: order:10...”类 ...

  2. kernel: swapper: page allocation failure. order:1, mode:0x20

    场景:领导电话通知,我们的主站宕机了,到家后从另外一台机器上ssh一直处于等待状态,开始怀疑机器的负载比较高,后查看监控机器,发现网卡.cpu.nginx连接数.....通通都没有数据了,显然不是负载 ...

  3. 【转】Linux Page Cache的工作原理

    1 .前言 自从诞生以来,Linux 就被不断完善和普及,目前它已经成为主流通用操作系统之一,使用得非常广泛,它与Windows.UNIX 一起占据了操作系统领域几乎所有的市场份额.特别是在高性能计算 ...

  4. linux page cache和buffer cache

    主要区别是,buffer cache缓存元信息,page cache缓存文件数据 buffer 与 cache 是作为磁盘文件缓存(磁盘高速缓存disk cache)来使用,主要目的提高文件系统系性能 ...

  5. linux page table entry struct

    Page Table Entry The access control information is held in the PTE and is CPU specific; figure bit f ...

  6. linux page buffer cache深入理解

    Linux上free命令的输出. 下面是free的运行结果,一共有4行.为了方便说明,我加上了列号.这样可以把free的输出看成一个二维数组FO(Free Output).例如: FO[2][1] = ...

  7. linux Page cache和buffer cache正解

    Page cache和buffer cache一直以来是两个比较容易混淆的概念,在网上也有很多人在争辩和猜想这两个cache到底有什么区别,讨论到最后也一直没有一个统一和正确的结论,在我工作的这一段时 ...

  8. System and method to prioritize large memory page allocation in virtualized systems

    The prioritization of large memory page mapping is a function of the access bits in the L1 page tabl ...

  9. linux Page cache和buffer cache----- systemtap

    http://shixm.iteye.com/blog/1724718 http://blog.csdn.net/dianhuiren/article/details/7543886

随机推荐

  1. 20145312袁心《网络对抗》Web基础实践

    20145312袁心<网络对抗>Web基础实践 问题回答 1.什么是表单: 表单在网页中主要负责数据采集功能. 一个表单有三个基本组成部分: 表单标签:这里面包含了处理表单数据所用CGI程 ...

  2. Serv-U FTP服务器安装及使用图解教程

    Serv-U,是一种被广泛运用的FTP服务器端软件,支持3x/9x/ME/NT/2K等全Windows系列.可以设定多个FTP服务器.限定登录用户的权限.登录主目录及空间大小等,功能非常完备. 它具有 ...

  3. python函数作用域LEGB

    我们的在学习Python函数的时候,经常会遇到很多定义域的问题,全部变量,内部变量,内部嵌入的函数,等等,Python是如何查找的呢?以及Python又是按照什么顺序来查找的呢?这里做一个顺序的说明 ...

  4. MVC5 一套Action的登录控制流程

    流程: 用拦截器控制每一个页面请求和ajax请求,根据请求体的cookie里面是否有token判断是否登录,还必须判断该token在redis里面的缓存是否存在 组成部分: 拦截器: using Sy ...

  5. How do I update a GitHub forked repository?

    I recently forked a project and applied several fixes. I then created a pull request which was then ...

  6. [AtCoder ARC101D/ABC107D] Median of Medians

    题目链接 题意:给n个数,求出所有子区间的中位数,组成另外一个序列,求出它的中位数 这里的中位数的定义是:将当前区间排序后,设区间长度为m,则中位数为第m/2+1个数 做法:二分+前缀和+树状数组维护 ...

  7. C# WinCE项目 VS2008 单例窗体实现

    项目现有主界面FormMain,模板界面FormModel,其余5个子界面皆继承自模板. 现在想要实现在主界面下可以打开任意子界面,并且可以随时关闭.当打开的子窗体未执行Close事件时,要保证每次显 ...

  8. HDU 6069 Counting Divisors(唯一分解定理+因子数)

    http://acm.hdu.edu.cn/showproblem.php?pid=6069 题意: 思路: 根据唯一分解定理,$n={a_{1}}^{p1}*{a2_{}}^{p2}...*{a_{ ...

  9. DDSM数据处理之PngWithOverlay 框出病灶区域

    修改代码路径 若overlay是某一侧的标注. 文件夹里某一侧的png 应该有对应 某一侧的overlay 这样一一对应才可以使得代码运行. 否则需要手动删除没有overlay的png图片. 左侧没有 ...

  10. python 判断一个数字是否为4的幂

    def is_Power_of_four(n): while n and not (n & 0b11): n >>= ) print(is_Power_of_four()) pri ...