Skip to content

Commit

Permalink
mm: fix dead loop if signal pending for cma alloc task [1/1]
Browse files Browse the repository at this point in the history
PD#GH-17

Problem:
If a task be killed during CMA allocation, then it will abort
cma allocation in function compact_unlock_should_abort. But in
function aml_cma_alloc_range, it will return -EBUSY. Which cause
cma allocation loop won't exit and run again and again.

Solution:
return -EINT for this case to exit cma allocaion loop.

Verify:
newman platform

Change-Id: I6559bb184fc035ae68c8ccd001407767e1e22f0c
Signed-off-by: Tao Zeng <tao.zeng@amlogic.com>
  • Loading branch information
kongsuozt authored and xiane committed Jun 29, 2020
1 parent d502d2b commit cd60585
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions drivers/amlogic/memory_ext/aml_cma.c
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ int aml_cma_alloc_range(unsigned long start, unsigned long end)
.mode = MIGRATE_SYNC,
.page_type = COMPACT_CMA,
.ignore_skip_hint = true,
.contended = false,
};
INIT_LIST_HEAD(&cc.migratepages);

Expand Down Expand Up @@ -611,11 +612,8 @@ int aml_cma_alloc_range(unsigned long start, unsigned long end)
outer_start = start;
while (!PageBuddy(pfn_to_page(outer_start))) {
if (++order >= MAX_ORDER) {
ret = -EBUSY;
try_times++;
if (try_times < 10)
goto try_again;
goto done;
outer_start = start;
break;
}
outer_start &= ~0UL << order;
}
Expand Down Expand Up @@ -647,7 +645,11 @@ int aml_cma_alloc_range(unsigned long start, unsigned long end)
/* Grab isolated pages from freelists. */
outer_end = isolate_freepages_range(&cc, outer_start, end);
if (!outer_end) {
ret = -EBUSY;
if (cc.contended) {
ret = -EINTR;
pr_info("cma_alloc [%lx-%lx] aborted\n", start, end);
} else
ret = -EBUSY;
goto done;
}

Expand Down

0 comments on commit cd60585

Please sign in to comment.