anolis: mm/cma: add API to enable concurrent allocation from the CMA
ANBZ: #7046 The mutex prevents allocating CMA memory concurently, and it's removed and reverted back and forth, refer to patch60a60e32cf
and60a60e32cf
from mainline. To solve the awkward dilemma, an API to enable concurrency is added, it's up to user to decide whether their CMA can handle concurrent allocations. Signed-off-by: Yangwencheng <yangwencheng@hygon.cn> Signed-off-by: Xin Jiang <jiangxin@hygon.cn> Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com> Link: https://gitee.com/anolis/cloud-kernel/pulls/2350
This commit is contained in:
parent
1b4d4cce1b
commit
9fecbc8830
|
@ -50,4 +50,5 @@ extern bool cma_release(struct cma *cma, const struct page *pages, unsigned int
|
|||
|
||||
extern int cma_for_each_area(int (*it)(struct cma *cma, void *data), void *data);
|
||||
extern int __init cma_alloc_areas(unsigned int max_cma_size);
|
||||
extern void cma_enable_concurrency(struct cma *cma);
|
||||
#endif
|
||||
|
|
14
mm/cma.c
14
mm/cma.c
|
@ -476,10 +476,12 @@ struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align,
|
|||
spin_unlock_irq(&cma->lock);
|
||||
|
||||
pfn = cma->base_pfn + (bitmap_no << cma->order_per_bit);
|
||||
mutex_lock(&cma_mutex);
|
||||
if (!cma->no_mutex)
|
||||
mutex_lock(&cma_mutex);
|
||||
ret = alloc_contig_range(pfn, pfn + count, MIGRATE_CMA,
|
||||
GFP_KERNEL | (no_warn ? __GFP_NOWARN : 0));
|
||||
mutex_unlock(&cma_mutex);
|
||||
if (!cma->no_mutex)
|
||||
mutex_unlock(&cma_mutex);
|
||||
if (ret == 0) {
|
||||
page = pfn_to_page(pfn);
|
||||
break;
|
||||
|
@ -563,3 +565,11 @@ int cma_for_each_area(int (*it)(struct cma *cma, void *data), void *data)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void cma_enable_concurrency(struct cma *cma)
|
||||
{
|
||||
if (!cma)
|
||||
return;
|
||||
|
||||
cma->no_mutex = true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue