linux-4.4.1/__alloc_pages_slowpath()
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
*参照元 [#l1e9098f]
#backlinks
*説明 [#r84b798a]
-パス: [[linux-4.4.1/mm/page_alloc.c]]
-FIXME: これは何?
--説明
**引数 [#v4249ee9]
-gfp_t gfp_mask
--
--[[linux-4.4.1/gfp_t]]
-unsigned int order
--
-struct alloc_context *ac
--
--[[linux-4.4.1/alloc_context]]
**返り値 [#scb12eb4]
-struct page *
--
--[[linux-4.4.1/page]]
**参考 [#p6f52271]
*実装 [#rbda4e19]
static inline struct page *
__alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
struct a...
{
bool can_direct_reclaim = gfp_mask & __GFP_DIREC...
struct page *page = NULL;
int alloc_flags;
unsigned long pages_reclaimed = 0;
unsigned long did_some_progress;
enum migrate_mode migration_mode = MIGRATE_ASYNC;
bool deferred_compaction = false;
int contended_compaction = COMPACT_CONTENDED_NONE;
-
--[[linux-4.4.1/__GFP_DIRECT_RECLAIM]]
--[[linux-4.4.1/migrate_mode]]
--[[linux-4.4.1/COMPACT_CONTENDED_NONE]]
/*
* In the slowpath, we sanity check order to avo...
* reclaim >= MAX_ORDER areas which will never s...
* be using allocators in order of preference fo...
* too large.
*/
if (order >= MAX_ORDER) {
WARN_ON_ONCE(!(gfp_mask & __GFP_NOWARN));
return NULL;
}
-
--[[linux-4.4.1/MAX_ORDER]]
--[[linux-4.4.1/WARN_ON_ONCE()]]
--[[linux-4.4.1/__GFP_NOWARN]]
/*
* We also sanity check to catch abuse of atomic...
* callers that are not in atomic context.
*/
if (WARN_ON_ONCE((gfp_mask & (__GFP_ATOMIC|__GFP...
(__GFP_ATOMIC|__GFP_DIRE...
gfp_mask &= ~__GFP_ATOMIC;
-
--[[linux-4.4.1/__GFP_ATOMIC]]
/*
* If this allocation cannot block and it is for...
* fail early. There's no need to wakeup kswapd...
* speculative node-specific allocation.
*/
if (IS_ENABLED(CONFIG_NUMA) && (gfp_mask & __GFP...
goto nopage;
-
--[[linux-4.4.1/IS_ENABLED()]]
--[[linux-4.4.1/CONFIG_NUMA]]
retry:
if (gfp_mask & __GFP_KSWAPD_RECLAIM)
wake_all_kswapds(order, ac);
-
--[[linux-4.4.1/__GFP_KSWAPD_RECLAIM]]
--[[linux-4.4.1/wake_all_kswapds()]]
/*
* OK, we're below the kswapd watermark and have...
* reclaim. Now things get more complex, so set ...
* to how we want to proceed.
*/
alloc_flags = gfp_to_alloc_flags(gfp_mask);
-
--[[linux-4.4.1/gfp_to_alloc_flags()]]
/*
* Find the true preferred zone if the allocatio...
* cpusets.
*/
if (!(alloc_flags & ALLOC_CPUSET) && !ac->nodema...
struct zoneref *preferred_zoneref;
preferred_zoneref = first_zones_zonelist...
ac->high_zoneidx, NULL, ...
ac->classzone_idx = zonelist_zone_idx(pr...
}
-
--[[linux-4.4.1/ALLOC_CPUSET]]
--[[linux-4.4.1/zoneref]]
--[[linux-4.4.1/first_zones_zonelist()]]
--[[linux-4.4.1/zonelist_zone_idx()]]
/* This is the last chance, in general, before t...
page = get_page_from_freelist(gfp_mask, order,
alloc_flags & ~ALLOC_NO_...
if (page)
goto got_pg;
-
--[[linux-4.4.1/get_page_from_freelist()]]
/* Allocate without watermarks if the context al...
if (alloc_flags & ALLOC_NO_WATERMARKS) {
/*
* Ignore mempolicies if ALLOC_NO_WATERM...
* the allocation is high priority and t...
* allocations are system rather than us...
*/
ac->zonelist = node_zonelist(numa_node_i...
page = __alloc_pages_high_priority(gfp_m...
if (page) {
goto got_pg;
}
-
--[[linux-4.4.1/node_zonelist()]]
--[[linux-4.4.1/numa_node_id()]]
--[[linux-4.4.1/__alloc_pages_high_priority()]]
}
/* Caller is not willing to reclaim, we can't ba...
if (!can_direct_reclaim) {
/*
* All existing users of the deprecated ...
* blockable, so warn of any new users t...
* type of allocation to fail.
*/
WARN_ON_ONCE(gfp_mask & __GFP_NOFAIL);
goto nopage;
}
/* Avoid recursion of direct reclaim */
if (current->flags & PF_MEMALLOC)
goto nopage;
-
--[[linux-4.4.1/PF_MEMALLOC]]
/* Avoid allocations with no watermarks from loo...
if (test_thread_flag(TIF_MEMDIE) && !(gfp_mask &...
goto nopage;
-
--[[linux-4.4.1/TIF_MEMDIE]]
/*
* Try direct compaction. The first pass is asyn...
* attempts after direct reclaim are synchronous
*/
page = __alloc_pages_direct_compact(gfp_mask, or...
migration_mode,
&contended_compa...
&deferred_compac...
if (page)
goto got_pg;
-
--[[linux-4.4.1/__alloc_pages_direct_compact()]]
/* Checks for THP-specific high-order allocation...
if (is_thp_gfp_mask(gfp_mask)) {
/*
* If compaction is deferred for high-or...
* because sync compaction recently fail...
* and the caller requested a THP alloca...
* to heavily disrupt the system, so we ...
* instead of entering direct reclaim.
*/
if (deferred_compaction)
goto nopage;
-
--[[linux-4.4.1/is_thp_gfp_mask()]]
/*
* In all zones where compaction was att...
* deferred or skipped), lock contention...
* For THP allocation we do not want to ...
* so we fallback to base pages instead.
*/
if (contended_compaction == COMPACT_CONT...
goto nopage;
-
--[[linux-4.4.1/COMPACT_CONTENDED_LOCK]]
/*
* If compaction was aborted due to need...
* want to further increase allocation l...
* khugepaged trying to collapse.
*/
if (contended_compaction == COMPACT_CONT...
&& !(current->flags & PF_KTHREAD))
goto nopage;
-
--[[linux-4.4.1/COMPACT_CONTENDED_SCHED]]
--[[linux-4.4.1/PF_KTHREAD]]
}
/*
* It can become very expensive to allocate tran...
* fault, so use asynchronous memory compaction ...
* khugepaged trying to collapse.
*/
if (!is_thp_gfp_mask(gfp_mask) || (current->flag...
migration_mode = MIGRATE_SYNC_LIGHT;
-
--[[linux-4.4.1/MIGRATE_SYNC_LIGHT]]
/* Try direct reclaim and then allocating */
page = __alloc_pages_direct_reclaim(gfp_mask, or...
...
if (page)
goto got_pg;
-
--[[linux-4.4.1/__alloc_pages_direct_reclaim()]]
/* Do not loop if specifically requested */
if (gfp_mask & __GFP_NORETRY)
goto noretry;
-
--[[linux-4.4.1/__GFP_NORETRY]]
/* Keep reclaiming pages as long as there is rea...
pages_reclaimed += did_some_progress;
if ((did_some_progress && order <= PAGE_ALLOC_CO...
((gfp_mask & __GFP_REPEAT) && pages_reclaime...
/* Wait for some write requests to compl...
wait_iff_congested(ac->preferred_zone, B...
goto retry;
}
-
--[[linux-4.4.1/PAGE_ALLOC_COSTLY_ORDER]]
--[[linux-4.4.1/__GFP_REPEAT]]
--[[linux-4.4.1/wait_iff_congested()]]
--[[linux-4.4.1/BLK_RW_ASYNC]]
/* Reclaim has failed us, start killing things */
page = __alloc_pages_may_oom(gfp_mask, order, ac...
if (page)
goto got_pg;
-
--[[linux-4.4.1/__alloc_pages_may_oom()]]
/* Retry as long as the OOM killer is making pro...
if (did_some_progress)
goto retry;
noretry:
/*
* High-order allocations do not necessarily loo...
* direct reclaim and reclaim/compaction depends...
* being called after reclaim so call directly i...
*/
page = __alloc_pages_direct_compact(gfp_mask, or...
ac, migratio...
&contended_c...
&deferred_co...
if (page)
goto got_pg;
-
--[[linux-4.4.1/__alloc_pages_direct_compact()]]
nopage:
warn_alloc_failed(gfp_mask, order, NULL);
-
--[[linux-4.4.1/warn_alloc_failed()]]
got_pg:
return page;
}
*コメント [#acb650a4]
終了行:
*参照元 [#l1e9098f]
#backlinks
*説明 [#r84b798a]
-パス: [[linux-4.4.1/mm/page_alloc.c]]
-FIXME: これは何?
--説明
**引数 [#v4249ee9]
-gfp_t gfp_mask
--
--[[linux-4.4.1/gfp_t]]
-unsigned int order
--
-struct alloc_context *ac
--
--[[linux-4.4.1/alloc_context]]
**返り値 [#scb12eb4]
-struct page *
--
--[[linux-4.4.1/page]]
**参考 [#p6f52271]
*実装 [#rbda4e19]
static inline struct page *
__alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
struct a...
{
bool can_direct_reclaim = gfp_mask & __GFP_DIREC...
struct page *page = NULL;
int alloc_flags;
unsigned long pages_reclaimed = 0;
unsigned long did_some_progress;
enum migrate_mode migration_mode = MIGRATE_ASYNC;
bool deferred_compaction = false;
int contended_compaction = COMPACT_CONTENDED_NONE;
-
--[[linux-4.4.1/__GFP_DIRECT_RECLAIM]]
--[[linux-4.4.1/migrate_mode]]
--[[linux-4.4.1/COMPACT_CONTENDED_NONE]]
/*
* In the slowpath, we sanity check order to avo...
* reclaim >= MAX_ORDER areas which will never s...
* be using allocators in order of preference fo...
* too large.
*/
if (order >= MAX_ORDER) {
WARN_ON_ONCE(!(gfp_mask & __GFP_NOWARN));
return NULL;
}
-
--[[linux-4.4.1/MAX_ORDER]]
--[[linux-4.4.1/WARN_ON_ONCE()]]
--[[linux-4.4.1/__GFP_NOWARN]]
/*
* We also sanity check to catch abuse of atomic...
* callers that are not in atomic context.
*/
if (WARN_ON_ONCE((gfp_mask & (__GFP_ATOMIC|__GFP...
(__GFP_ATOMIC|__GFP_DIRE...
gfp_mask &= ~__GFP_ATOMIC;
-
--[[linux-4.4.1/__GFP_ATOMIC]]
/*
* If this allocation cannot block and it is for...
* fail early. There's no need to wakeup kswapd...
* speculative node-specific allocation.
*/
if (IS_ENABLED(CONFIG_NUMA) && (gfp_mask & __GFP...
goto nopage;
-
--[[linux-4.4.1/IS_ENABLED()]]
--[[linux-4.4.1/CONFIG_NUMA]]
retry:
if (gfp_mask & __GFP_KSWAPD_RECLAIM)
wake_all_kswapds(order, ac);
-
--[[linux-4.4.1/__GFP_KSWAPD_RECLAIM]]
--[[linux-4.4.1/wake_all_kswapds()]]
/*
* OK, we're below the kswapd watermark and have...
* reclaim. Now things get more complex, so set ...
* to how we want to proceed.
*/
alloc_flags = gfp_to_alloc_flags(gfp_mask);
-
--[[linux-4.4.1/gfp_to_alloc_flags()]]
/*
* Find the true preferred zone if the allocatio...
* cpusets.
*/
if (!(alloc_flags & ALLOC_CPUSET) && !ac->nodema...
struct zoneref *preferred_zoneref;
preferred_zoneref = first_zones_zonelist...
ac->high_zoneidx, NULL, ...
ac->classzone_idx = zonelist_zone_idx(pr...
}
-
--[[linux-4.4.1/ALLOC_CPUSET]]
--[[linux-4.4.1/zoneref]]
--[[linux-4.4.1/first_zones_zonelist()]]
--[[linux-4.4.1/zonelist_zone_idx()]]
/* This is the last chance, in general, before t...
page = get_page_from_freelist(gfp_mask, order,
alloc_flags & ~ALLOC_NO_...
if (page)
goto got_pg;
-
--[[linux-4.4.1/get_page_from_freelist()]]
/* Allocate without watermarks if the context al...
if (alloc_flags & ALLOC_NO_WATERMARKS) {
/*
* Ignore mempolicies if ALLOC_NO_WATERM...
* the allocation is high priority and t...
* allocations are system rather than us...
*/
ac->zonelist = node_zonelist(numa_node_i...
page = __alloc_pages_high_priority(gfp_m...
if (page) {
goto got_pg;
}
-
--[[linux-4.4.1/node_zonelist()]]
--[[linux-4.4.1/numa_node_id()]]
--[[linux-4.4.1/__alloc_pages_high_priority()]]
}
/* Caller is not willing to reclaim, we can't ba...
if (!can_direct_reclaim) {
/*
* All existing users of the deprecated ...
* blockable, so warn of any new users t...
* type of allocation to fail.
*/
WARN_ON_ONCE(gfp_mask & __GFP_NOFAIL);
goto nopage;
}
/* Avoid recursion of direct reclaim */
if (current->flags & PF_MEMALLOC)
goto nopage;
-
--[[linux-4.4.1/PF_MEMALLOC]]
/* Avoid allocations with no watermarks from loo...
if (test_thread_flag(TIF_MEMDIE) && !(gfp_mask &...
goto nopage;
-
--[[linux-4.4.1/TIF_MEMDIE]]
/*
* Try direct compaction. The first pass is asyn...
* attempts after direct reclaim are synchronous
*/
page = __alloc_pages_direct_compact(gfp_mask, or...
migration_mode,
&contended_compa...
&deferred_compac...
if (page)
goto got_pg;
-
--[[linux-4.4.1/__alloc_pages_direct_compact()]]
/* Checks for THP-specific high-order allocation...
if (is_thp_gfp_mask(gfp_mask)) {
/*
* If compaction is deferred for high-or...
* because sync compaction recently fail...
* and the caller requested a THP alloca...
* to heavily disrupt the system, so we ...
* instead of entering direct reclaim.
*/
if (deferred_compaction)
goto nopage;
-
--[[linux-4.4.1/is_thp_gfp_mask()]]
/*
* In all zones where compaction was att...
* deferred or skipped), lock contention...
* For THP allocation we do not want to ...
* so we fallback to base pages instead.
*/
if (contended_compaction == COMPACT_CONT...
goto nopage;
-
--[[linux-4.4.1/COMPACT_CONTENDED_LOCK]]
/*
* If compaction was aborted due to need...
* want to further increase allocation l...
* khugepaged trying to collapse.
*/
if (contended_compaction == COMPACT_CONT...
&& !(current->flags & PF_KTHREAD))
goto nopage;
-
--[[linux-4.4.1/COMPACT_CONTENDED_SCHED]]
--[[linux-4.4.1/PF_KTHREAD]]
}
/*
* It can become very expensive to allocate tran...
* fault, so use asynchronous memory compaction ...
* khugepaged trying to collapse.
*/
if (!is_thp_gfp_mask(gfp_mask) || (current->flag...
migration_mode = MIGRATE_SYNC_LIGHT;
-
--[[linux-4.4.1/MIGRATE_SYNC_LIGHT]]
/* Try direct reclaim and then allocating */
page = __alloc_pages_direct_reclaim(gfp_mask, or...
...
if (page)
goto got_pg;
-
--[[linux-4.4.1/__alloc_pages_direct_reclaim()]]
/* Do not loop if specifically requested */
if (gfp_mask & __GFP_NORETRY)
goto noretry;
-
--[[linux-4.4.1/__GFP_NORETRY]]
/* Keep reclaiming pages as long as there is rea...
pages_reclaimed += did_some_progress;
if ((did_some_progress && order <= PAGE_ALLOC_CO...
((gfp_mask & __GFP_REPEAT) && pages_reclaime...
/* Wait for some write requests to compl...
wait_iff_congested(ac->preferred_zone, B...
goto retry;
}
-
--[[linux-4.4.1/PAGE_ALLOC_COSTLY_ORDER]]
--[[linux-4.4.1/__GFP_REPEAT]]
--[[linux-4.4.1/wait_iff_congested()]]
--[[linux-4.4.1/BLK_RW_ASYNC]]
/* Reclaim has failed us, start killing things */
page = __alloc_pages_may_oom(gfp_mask, order, ac...
if (page)
goto got_pg;
-
--[[linux-4.4.1/__alloc_pages_may_oom()]]
/* Retry as long as the OOM killer is making pro...
if (did_some_progress)
goto retry;
noretry:
/*
* High-order allocations do not necessarily loo...
* direct reclaim and reclaim/compaction depends...
* being called after reclaim so call directly i...
*/
page = __alloc_pages_direct_compact(gfp_mask, or...
ac, migratio...
&contended_c...
&deferred_co...
if (page)
goto got_pg;
-
--[[linux-4.4.1/__alloc_pages_direct_compact()]]
nopage:
warn_alloc_failed(gfp_mask, order, NULL);
-
--[[linux-4.4.1/warn_alloc_failed()]]
got_pg:
return page;
}
*コメント [#acb650a4]
ページ名: