From ee76ce9ce01830280db7d4242cd93b972724d266 Mon Sep 17 00:00:00 2001 From: tao zeng Date: Mon, 23 Oct 2017 09:35:57 +0800 Subject: [PATCH] mm: fix cma allocate fail problem PD#152454: mm: fix cma allocate fail problem boost work shoud return right value of __alloc_contig_migrate_range Change-Id: I8275a8541cd263f5ea5574fba1c053a30e3cbc80 Signed-off-by: tao zeng --- mm/page_alloc.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index cd6b05dc18f4..ceceeaa56b76 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -7507,6 +7507,7 @@ static int __alloc_contig_migrate_range(struct compact_control *cc, } #ifdef CONFIG_AMLOGIC_MODIFY +#define BOOST_BUSY (0xffff) struct cma_pcp_work { unsigned long pfn; unsigned long count; @@ -7537,19 +7538,24 @@ static void cma_boost_work_func(struct work_struct *work) cc.zone = page_zone(pfn_to_page(pfn)); end = pfn + c_work->count; ret = __alloc_contig_migrate_range(&cc, pfn, end); + ok = (atomic_t *)c_work->data; if (!ret) { - ok = (atomic_t *)c_work->data; atomic_inc(ok); lru_add_drain(); drain_pages(this_cpu); - } else - pr_err("%s, failed, ret:%d\n", __func__, ret); + } else if (ret == -EBUSY) + atomic_add(BOOST_BUSY, ok); /* tell caller busy */ + + if (ret) { + pr_err("%s, failed, ret:%d, ok:%d\n", + __func__, ret, atomic_read(ok)); + } } int alloc_contig_boost(unsigned long start_pfn, unsigned long count) { static struct cpumask has_work; - int cpu, cpus, i = 0; + int cpu, cpus, i = 0, ret; atomic_t ok; unsigned long delta; unsigned long cnt; @@ -7580,9 +7586,18 @@ int alloc_contig_boost(unsigned long start_pfn, unsigned long count) } if (atomic_read(&ok) == cpus) - return 0; + ret = 0; + else if (atomic_read(&ok) >= BOOST_BUSY) + ret = -EBUSY; else - return -EINVAL; + ret = -EINVAL; + + if (ret) { + pr_err("%s, failed, ret:%d, ok:%d\n", + __func__, ret, atomic_read(&ok)); + } + + return ret; } #endif /* CONFIG_AMLOGIC_MODIFY */