*参照元 [#lc32b544]
#backlinks

*説明 [#eecfca4f]
-パス: [[linux-4.4.1/include/linux/gfp.h]]

-FIXME: これは何?
--gfp フラグから、ページマイグレーション属性(MIGRATE_XX)を得る。
--求め方は gfp_flags を GFP_MOVABLE_MASK でマスクして GFP_MOVABLE_SHIFT だけ右シフトする。
---GFP_MOVABLE_MASK の値は (__GFP_RECLAIMABLE|__GFP_MOVABLE)
---__GFP_MOVABLE は、数値にすると 0x08u
---__GFP_RECLAIMABLE は、数値にすると 0x10u
---GFP_MOVABLE_SHIFT は 3

| GFP_RECLAIMABLE | GFP_MOVABLE | 結果 |
| x               | x           | 0 = MIGRATE_UNMOVABLE |
| x               | o           | 1 = MIGRATE_MOVABLE |
| o               | x           | 2 = MIGRATE_RECLAIMABLE |
| o               | o           | 3 = MIGRATE_PCPTYPES, MIGRATE_HIGHATOMIC |

-MIGRATE_CMA 以上の値は特殊


**引数 [#nf4ff30f]
-const gfp_t gfp_flags
--
--[[linux-4.4.1/gfp_t]]


**返り値 [#i228b4c9]
-int
--


**参考 [#b5e80a1a]

 enum {
 	MIGRATE_UNMOVABLE,
 	MIGRATE_MOVABLE,
 	MIGRATE_RECLAIMABLE,
 	MIGRATE_PCPTYPES,	/* the number of types on the pcp lists */
 	MIGRATE_HIGHATOMIC = MIGRATE_PCPTYPES,
 #ifdef CONFIG_CMA
 	/*
 	 * MIGRATE_CMA migration type is designed to mimic the way
 	 * ZONE_MOVABLE works.  Only movable pages can be allocated
 	 * from MIGRATE_CMA pageblocks and page allocator never
 	 * implicitly change migration type of MIGRATE_CMA pageblock.
 	 *
 	 * The way to use it is to change migratetype of a range of
 	 * pageblocks to MIGRATE_CMA which can be done by
 	 * __free_pageblock_cma() function.  What is important though
 	 * is that a range of pageblocks must be aligned to
 	 * MAX_ORDER_NR_PAGES should biggest page be bigger then
 	 * a single pageblock.
 	 */
 	MIGRATE_CMA,
 #endif
 #ifdef CONFIG_MEMORY_ISOLATION
 	MIGRATE_ISOLATE,	/* can't allocate from here */
 #endif
 	MIGRATE_TYPES
 };

 #define ___GFP_MOVABLE		0x08u
 #define ___GFP_RECLAIMABLE	0x10u
 #define ___GFP_HIGH		0x20u
 #define ___GFP_IO		0x40u
 #define ___GFP_FS		0x80u

-他の値は下記参照。
--[[linux-4.4.1/GFP]]

 #define __GFP_MOVABLE	((__force gfp_t)___GFP_MOVABLE)  /* ZONE_MOVABLE allowed */
 ...
 #define __GFP_RECLAIMABLE ((__force gfp_t)___GFP_RECLAIMABLE)


*実装 [#w1a5880b]
 /* Convert GFP flags to their corresponding migrate type */
 #define GFP_MOVABLE_MASK (__GFP_RECLAIMABLE|__GFP_MOVABLE)
 #define GFP_MOVABLE_SHIFT 3
 
 static inline int gfpflags_to_migratetype(const gfp_t gfp_flags)
 {
 	VM_WARN_ON((gfp_flags & GFP_MOVABLE_MASK) == GFP_MOVABLE_MASK);
 	BUILD_BUG_ON((1UL << GFP_MOVABLE_SHIFT) != ___GFP_MOVABLE);
 	BUILD_BUG_ON((___GFP_MOVABLE >> GFP_MOVABLE_SHIFT) != MIGRATE_MOVABLE);
 
-
--[[linux-4.4.1/VM_WARN_ON()]]
--[[linux-4.4.1/BUILD_BUG_ON()]]
--[[linux-4.4.1/___GFP_MOVABLE]]

 	if (unlikely(page_group_by_mobility_disabled))
 		return MIGRATE_UNMOVABLE;
 
-
--[[linux-4.4.1/unlikely()]]
--[[linux-4.4.1/page_group_by_mobility_disabled(global)]]

 	/* Group based on mobility */
 	return (gfp_flags & GFP_MOVABLE_MASK) >> GFP_MOVABLE_SHIFT;
 }
 #undef GFP_MOVABLE_MASK
 #undef GFP_MOVABLE_SHIFT


*コメント [#o972f373]

トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS