mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 10:58:48 +09:00
FROMLIST: mm: failfast mode with __GFP_NORETRY in alloc_contig_range
Contiguous memory allocation can be stalled due to waiting
on page writeback and/or page lock which causes unpredictable
delay. It's a unavoidable cost for the requestor to get *big*
contiguous memory but it's expensive for *small* contiguous
memory(e.g., order-4) because caller could retry the request
in different range where would have easy migratable pages
without stalling.
This patch introduce __GFP_NORETRY as compaction gfp_mask in
alloc_contig_range so it will fail fast without blocking
when it encounters pages needed waiting.
Bug: 170340257
Bug: 120293424
Link: https://lore.kernel.org/linux-mm/YAnM5PbNJZlk%2F%2FiX@google.com/T/#m1362218ebb69e6e10c20d9361008b079745c4e6f
Signed-off-by: Minchan Kim <minchan@kernel.org>
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: I42ba8dd5aeb065d936978ab205e4baf84bf9a321
Signed-off-by: Richard Chang <richardycc@google.com>
(cherry picked from commit 20512940b8)
This commit is contained in:
committed by
Richard Chang
parent
eebff8eab2
commit
9cb760bc6a
@@ -9146,12 +9146,16 @@ static int __alloc_contig_migrate_range(struct compact_control *cc,
|
||||
unsigned int nr_reclaimed;
|
||||
unsigned long pfn = start;
|
||||
unsigned int tries = 0;
|
||||
unsigned int max_tries = 5;
|
||||
int ret = 0;
|
||||
struct migration_target_control mtc = {
|
||||
.nid = zone_to_nid(cc->zone),
|
||||
.gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL,
|
||||
};
|
||||
|
||||
if (cc->alloc_contig && cc->mode == MIGRATE_ASYNC)
|
||||
max_tries = 1;
|
||||
|
||||
lru_cache_disable();
|
||||
|
||||
while (pfn < end || !list_empty(&cc->migratepages)) {
|
||||
@@ -9167,7 +9171,7 @@ static int __alloc_contig_migrate_range(struct compact_control *cc,
|
||||
break;
|
||||
pfn = cc->migrate_pfn;
|
||||
tries = 0;
|
||||
} else if (++tries == 5) {
|
||||
} else if (++tries == max_tries) {
|
||||
ret = -EBUSY;
|
||||
break;
|
||||
}
|
||||
@@ -9239,7 +9243,7 @@ int alloc_contig_range(unsigned long start, unsigned long end,
|
||||
.nr_migratepages = 0,
|
||||
.order = -1,
|
||||
.zone = page_zone(pfn_to_page(start)),
|
||||
.mode = MIGRATE_SYNC,
|
||||
.mode = gfp_mask & __GFP_NORETRY ? MIGRATE_ASYNC : MIGRATE_SYNC,
|
||||
.ignore_skip_hint = true,
|
||||
.no_set_skip_hint = true,
|
||||
.gfp_mask = current_gfp_context(gfp_mask),
|
||||
|
||||
Reference in New Issue
Block a user