Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932459AbbFEIDE (ORCPT ); Fri, 5 Jun 2015 04:03:04 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:42846 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753902AbbFEIC6 (ORCPT ); Fri, 5 Jun 2015 04:02:58 -0400 X-AuditID: cbfee61a-f79516d000006302-8c-557157acd10a From: Weijie Yang To: iamjoonsoo.kim@lge.com Cc: mina86@mina86.com, m.szyprowski@samsung.com, "'Andrew Morton'" , "'Weijie Yang'" , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] cma: allow concurrent cma pages allocation for multi-cma areas Date: Fri, 05 Jun 2015 16:01:56 +0800 Message-id: <"000001d09f66$056b67f0$104237d0$@yang"@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-transfer-encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-index: AdCfZeQUCx+vwcZyTY6wqDWB2JtElQ== Content-language: zh-cn X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrPLMWRmVeSWpSXmKPExsVy+t9jAd014YWhBpdmcVrMWb+GzWJldzOb xeVdc9gs7q35z2qx9shddosFx1tYLZ6c+M/iwO6xc9Zddo9Nnyaxe3S9vcLkcWLGbxaPdX9e MXn0bVnF6PF5k1wAexSXTUpqTmZZapG+XQJXxuOFpxgLFvNX9DScZGtgXMHTxcjBISFgIvF4 U34XIyeQKSZx4d56ti5GLg4hgUWMEjMvXGeEcN4xSjRdOMEIUsUmoC1xt38jK4gtIiAlcer7 CbAiZoF9jBIne+8xgSSEBfwl9jf0sIHYLAKqEkcuv2AHsXkFHCQuPFkHZQtK/Jh8jwXkCmYB dYkpU3JBwswC8hKb17xlhjhOXeLRX12IVXoSy2/dZ4IoEZfYeOQWywRGgVlIBs1CGDQLyaBZ SDoWMLKsYhRNLUguKE5KzzXUK07MLS7NS9dLzs/dxAiOhmdSOxhXNlgcYhTgYFTi4W0wLAwV Yk0sK67MPcQowcGsJMJ7wB8oxJuSWFmVWpQfX1Sak1p8iFGag0VJnPdkvk+okEB6Yklqdmpq QWoRTJaJg1OqgfHsO4FEjr3fV25Mjy87LaPkf6Uxju2N/PTeY7Ou318qIPxefH/6Z19Bbv8M h5udCtX3WgyetP5xKDTu3bdn+pGzF5XWbWV4kn01rt8hMGDGyo33ruSr1N+t3/QhimH5K+6z Ge1f9ARYwxWuy/C0bwycs8qvPjOarWK9Rfe7PSmFZVbVbrcSDiuxFGckGmoxFxUnAgAlk65S ggIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2137 Lines: 68 Currently we have to hold the single cma_mutex when alloc cma pages, it is ok when there is only one cma area in system. However, when there are several cma areas, such as in our Android smart phone, the single cma_mutex prevents concurrent cma page allocation. This patch removes the single cma_mutex and uses per-cma area alloc_lock, this allows concurrent cma pages allocation for different cma areas while protects access to the same pageblocks. Signed-off-by: Weijie Yang --- mm/cma.c | 6 +++--- mm/cma.h | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/mm/cma.c b/mm/cma.c index 3a7a67b..eaf1afe 100644 --- a/mm/cma.c +++ b/mm/cma.c @@ -41,7 +41,6 @@ struct cma cma_areas[MAX_CMA_AREAS]; unsigned cma_area_count; -static DEFINE_MUTEX(cma_mutex); phys_addr_t cma_get_base(const struct cma *cma) { @@ -128,6 +127,7 @@ static int __init cma_activate_area(struct cma *cma) } while (--i); mutex_init(&cma->lock); + mutex_init(&cma->alloc_lock); #ifdef CONFIG_CMA_DEBUGFS INIT_HLIST_HEAD(&cma->mem_head); @@ -398,9 +398,9 @@ struct page *cma_alloc(struct cma *cma, unsigned int count, unsigned int align) mutex_unlock(&cma->lock); pfn = cma->base_pfn + (bitmap_no << cma->order_per_bit); - mutex_lock(&cma_mutex); + mutex_lock(&cma->alloc_lock); ret = alloc_contig_range(pfn, pfn + count, MIGRATE_CMA); - mutex_unlock(&cma_mutex); + mutex_unlock(&cma->alloc_lock); if (ret == 0) { page = pfn_to_page(pfn); break; diff --git a/mm/cma.h b/mm/cma.h index 1132d73..2084c9f 100644 --- a/mm/cma.h +++ b/mm/cma.h @@ -7,6 +7,7 @@ struct cma { unsigned long *bitmap; unsigned int order_per_bit; /* Order of pages represented by one bit */ struct mutex lock; + struct mutex alloc_lock; #ifdef CONFIG_CMA_DEBUGFS struct hlist_head mem_head; spinlock_t mem_head_lock; -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/