统计内存外碎片事件

avatar
作者
猴君
阅读量:0

参考

  • https://blog.csdn.net/qq_43573047/article/details/140734352
  • https://zhuanlan.zhihu.com/p/479922331

在内存分配的时候,当指定的迁移类型的内存不足时,会向其他迁移类型借,内核通过下面的数组定义了迁移类型的借用顺序:

/*  * This array describes the order lists are fallen back to when  * the free lists for the desirable migrate type are depleted  *  * The other migratetypes do not have fallbacks.  */ static int fallbacks[MIGRATE_TYPES][3] = {     	[MIGRATE_UNMOVABLE]   = {     MIGRATE_RECLAIMABLE, MIGRATE_MOVABLE,   MIGRATE_TYPES }, 	[MIGRATE_MOVABLE]     = {     MIGRATE_RECLAIMABLE, MIGRATE_UNMOVABLE, MIGRATE_TYPES }, 	[MIGRATE_RECLAIMABLE] = {     MIGRATE_UNMOVABLE,   MIGRATE_MOVABLE,   MIGRATE_TYPES }, }; 

这部分的代码如下:

/*  * Try finding a free buddy page on the fallback list and put it on the free  * list of requested migratetype, possibly along with other pages from the same  * block, depending on fragmentation avoidance heuristics. Returns true if  * fallback was found so that __rmqueue_smallest() can grab it.  *  * The use of signed ints for order and current_order is a deliberate  * deviation from the rest of this file, to make the for loop  * condition simpler.  */ static __always_inline bool __rmqueue_fallback(struct zone *zone, int order, int start_migratetype, 						unsigned int alloc_flags) {     	struct 

广告一刻

为您即时展示最新活动产品广告消息,让您随时掌握产品活动新动态!