ANDROID: mm: cma: skip problematic pageblock

alloc_contig_range is supposed to work on max(MAX_ORDER_NR_PAGES,
or pageblock_nr_pages) granularity aligned range. If it fails
at a page and return error to user, user doesn't know what page
makes the allocation failure and keep retrying another allocation
with new range including the failed page and encountered error
again and again until it could escape the out of the granularity
block. Instead, let's make CMA aware of what pfn was troubled in
previous trial and then continue to work new pageblock out of the
failed page so it doesn't see the repeated error repeatedly.

Currently, this option works for only __GFP_NORETRY case for
safe for existing CMA users.

Bug: 192475091
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: I0959c9df3d4b36408a68920abbb4d52d31026079
This commit is contained in:
Minchan Kim
2021-06-29 12:08:44 -07:00
committed by Todd Kjos
parent 9938b82be1
commit 0e688e972d
6 changed files with 34 additions and 11 deletions

View File

@@ -532,8 +532,16 @@ struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align,
trace_cma_alloc_busy_retry(cma->name, pfn, pfn_to_page(pfn),
count, align);
/* try again with a bit different memory target */
start = bitmap_no + mask + 1;
if (info.failed_pfn && gfp_mask & __GFP_NORETRY) {
/* try again from following failed page */
start = (pfn_max_align_up(info.failed_pfn + 1) -
cma->base_pfn) >> cma->order_per_bit;
} else {
/* try again with a bit different memory target */
start = bitmap_no + mask + 1;
}
}
trace_cma_alloc_finish(cma->name, pfn, page, count, align);