Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions arch/x86/mm/mem_encrypt_hygon.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ static void __init csv_cma_reserve_mem(void)
1 << CSV_CMA_SHIFT, node);
break;
}
cma_enable_concurrency(csv_cma->cma);

if (start > cma_get_base(csv_cma->cma) || !start)
start = cma_get_base(csv_cma->cma);
Expand Down
1 change: 1 addition & 0 deletions include/linux/cma.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,5 @@ extern int cma_for_each_area(int (*it)(struct cma *cma, void *data), void *data)
extern void cma_reserve_pages_on_error(struct cma *cma);

extern int __init cma_alloc_areas(unsigned int max_cma_size);
extern void cma_enable_concurrency(struct cma *cma);
#endif
14 changes: 12 additions & 2 deletions mm/cma.c
Original file line number Diff line number Diff line change
Expand Up @@ -492,10 +492,12 @@ struct page *cma_alloc(struct cma *cma, unsigned long count,
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;
Expand Down Expand Up @@ -609,3 +611,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;
}
1 change: 1 addition & 0 deletions mm/cma.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ struct cma {
unsigned long *bitmap;
unsigned int order_per_bit; /* Order of pages represented by one bit */
spinlock_t lock;
bool no_mutex;
#ifdef CONFIG_CMA_DEBUGFS
struct hlist_head mem_head;
spinlock_t mem_head_lock;
Expand Down