+ mm-cma-remove-unsupported-gfp_mask-parameter-from-cma_alloc.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     Subject: mm/cma: remove unsupported gfp_mask parameter from cma_alloc()
has been added to the -mm tree.  Its filename is
     mm-cma-remove-unsupported-gfp_mask-parameter-from-cma_alloc.patch

This patch should soon appear at
    http://ozlabs.org/~akpm/mmots/broken-out/mm-cma-remove-unsupported-gfp_mask-parameter-from-cma_alloc.patch
and later at
    http://ozlabs.org/~akpm/mmotm/broken-out/mm-cma-remove-unsupported-gfp_mask-parameter-from-cma_alloc.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: Marek Szyprowski <m.szyprowski@xxxxxxxxxxx>
Subject: mm/cma: remove unsupported gfp_mask parameter from cma_alloc()

cma_alloc() doesn't really support gfp flags other than __GFP_NOWARN, so
convert gfp_mask parameter to boolean no_warn parameter.

This will help to avoid giving false feeling that this function supports
standard gfp flags and callers can pass __GFP_ZERO to get zeroed buffer,
what has already been an issue: see commit dd65a941f6ba ("arm64:
dma-mapping: clear buffers allocated with FORCE_CONTIGUOUS flag").

Link: http://lkml.kernel.org/r/20180709122019eucas1p2340da484acfcc932537e6014f4fd2c29~-sqTPJKij2939229392eucas1p2j@xxxxxxxxxxxxxxxxxxxx
Signed-off-by: Marek Szyprowski <m.szyprowski@xxxxxxxxxxx>
Acked-by: Michal Hocko <mhocko@xxxxxxxx>
Acked-by: Acked-by: Michał Nazarewicz <mina86@xxxxxxxxxx>
Acked-by: Laura Abbott <labbott@xxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 arch/powerpc/kvm/book3s_hv_builtin.c       |    2 +-
 drivers/s390/char/vmcp.c                   |    2 +-
 drivers/staging/android/ion/ion_cma_heap.c |    2 +-
 include/linux/cma.h                        |    2 +-
 kernel/dma/contiguous.c                    |    3 ++-
 mm/cma.c                                   |    8 ++++----
 mm/cma_debug.c                             |    2 +-
 7 files changed, 11 insertions(+), 10 deletions(-)

diff -puN arch/powerpc/kvm/book3s_hv_builtin.c~mm-cma-remove-unsupported-gfp_mask-parameter-from-cma_alloc arch/powerpc/kvm/book3s_hv_builtin.c
--- a/arch/powerpc/kvm/book3s_hv_builtin.c~mm-cma-remove-unsupported-gfp_mask-parameter-from-cma_alloc
+++ a/arch/powerpc/kvm/book3s_hv_builtin.c
@@ -77,7 +77,7 @@ struct page *kvm_alloc_hpt_cma(unsigned
 	VM_BUG_ON(order_base_2(nr_pages) < KVM_CMA_CHUNK_ORDER - PAGE_SHIFT);
 
 	return cma_alloc(kvm_cma, nr_pages, order_base_2(HPT_ALIGN_PAGES),
-			 GFP_KERNEL);
+			 false);
 }
 EXPORT_SYMBOL_GPL(kvm_alloc_hpt_cma);
 
diff -puN drivers/s390/char/vmcp.c~mm-cma-remove-unsupported-gfp_mask-parameter-from-cma_alloc drivers/s390/char/vmcp.c
--- a/drivers/s390/char/vmcp.c~mm-cma-remove-unsupported-gfp_mask-parameter-from-cma_alloc
+++ a/drivers/s390/char/vmcp.c
@@ -68,7 +68,7 @@ static void vmcp_response_alloc(struct v
 	 * anymore the system won't work anyway.
 	 */
 	if (order > 2)
-		page = cma_alloc(vmcp_cma, nr_pages, 0, GFP_KERNEL);
+		page = cma_alloc(vmcp_cma, nr_pages, 0, false);
 	if (page) {
 		session->response = (char *)page_to_phys(page);
 		session->cma_alloc = 1;
diff -puN drivers/staging/android/ion/ion_cma_heap.c~mm-cma-remove-unsupported-gfp_mask-parameter-from-cma_alloc drivers/staging/android/ion/ion_cma_heap.c
--- a/drivers/staging/android/ion/ion_cma_heap.c~mm-cma-remove-unsupported-gfp_mask-parameter-from-cma_alloc
+++ a/drivers/staging/android/ion/ion_cma_heap.c
@@ -39,7 +39,7 @@ static int ion_cma_allocate(struct ion_h
 	if (align > CONFIG_CMA_ALIGNMENT)
 		align = CONFIG_CMA_ALIGNMENT;
 
-	pages = cma_alloc(cma_heap->cma, nr_pages, align, GFP_KERNEL);
+	pages = cma_alloc(cma_heap->cma, nr_pages, align, false);
 	if (!pages)
 		return -ENOMEM;
 
diff -puN include/linux/cma.h~mm-cma-remove-unsupported-gfp_mask-parameter-from-cma_alloc include/linux/cma.h
--- a/include/linux/cma.h~mm-cma-remove-unsupported-gfp_mask-parameter-from-cma_alloc
+++ a/include/linux/cma.h
@@ -33,7 +33,7 @@ extern int cma_init_reserved_mem(phys_ad
 					const char *name,
 					struct cma **res_cma);
 extern struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align,
-			      gfp_t gfp_mask);
+			      bool no_warn);
 extern bool cma_release(struct cma *cma, const struct page *pages, unsigned int count);
 
 extern int cma_for_each_area(int (*it)(struct cma *cma, void *data), void *data);
diff -puN kernel/dma/contiguous.c~mm-cma-remove-unsupported-gfp_mask-parameter-from-cma_alloc kernel/dma/contiguous.c
--- a/kernel/dma/contiguous.c~mm-cma-remove-unsupported-gfp_mask-parameter-from-cma_alloc
+++ a/kernel/dma/contiguous.c
@@ -191,7 +191,8 @@ struct page *dma_alloc_from_contiguous(s
 	if (align > CONFIG_CMA_ALIGNMENT)
 		align = CONFIG_CMA_ALIGNMENT;
 
-	return cma_alloc(dev_get_cma_area(dev), count, align, gfp_mask);
+	return cma_alloc(dev_get_cma_area(dev), count, align,
+			 gfp_mask & __GFP_NOWARN);
 }
 
 /**
diff -puN mm/cma.c~mm-cma-remove-unsupported-gfp_mask-parameter-from-cma_alloc mm/cma.c
--- a/mm/cma.c~mm-cma-remove-unsupported-gfp_mask-parameter-from-cma_alloc
+++ a/mm/cma.c
@@ -395,13 +395,13 @@ static inline void cma_debug_show_areas(
  * @cma:   Contiguous memory region for which the allocation is performed.
  * @count: Requested number of pages.
  * @align: Requested alignment of pages (in PAGE_SIZE order).
- * @gfp_mask:  GFP mask to use during compaction
+ * @no_warn: Avoid printing message about failed allocation
  *
  * This function allocates part of contiguous memory on specific
  * contiguous memory area.
  */
 struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align,
-		       gfp_t gfp_mask)
+		       bool no_warn)
 {
 	unsigned long mask, offset;
 	unsigned long pfn = -1;
@@ -447,7 +447,7 @@ struct page *cma_alloc(struct cma *cma,
 		pfn = cma->base_pfn + (bitmap_no << cma->order_per_bit);
 		mutex_lock(&cma_mutex);
 		ret = alloc_contig_range(pfn, pfn + count, MIGRATE_CMA,
-					 gfp_mask);
+				     GFP_KERNEL | (no_warn ? __GFP_NOWARN : 0));
 		mutex_unlock(&cma_mutex);
 		if (ret == 0) {
 			page = pfn_to_page(pfn);
@@ -466,7 +466,7 @@ struct page *cma_alloc(struct cma *cma,
 
 	trace_cma_alloc(pfn, page, count, align);
 
-	if (ret && !(gfp_mask & __GFP_NOWARN)) {
+	if (ret && !no_warn) {
 		pr_err("%s: alloc failed, req-size: %zu pages, ret: %d\n",
 			__func__, count, ret);
 		cma_debug_show_areas(cma);
diff -puN mm/cma_debug.c~mm-cma-remove-unsupported-gfp_mask-parameter-from-cma_alloc mm/cma_debug.c
--- a/mm/cma_debug.c~mm-cma-remove-unsupported-gfp_mask-parameter-from-cma_alloc
+++ a/mm/cma_debug.c
@@ -139,7 +139,7 @@ static int cma_alloc_mem(struct cma *cma
 	if (!mem)
 		return -ENOMEM;
 
-	p = cma_alloc(cma, count, 0, GFP_KERNEL);
+	p = cma_alloc(cma, count, 0, false);
 	if (!p) {
 		kfree(mem);
 		return -ENOMEM;
_

Patches currently in -mm which might be from m.szyprowski@xxxxxxxxxxx are

mm-cma-remove-unsupported-gfp_mask-parameter-from-cma_alloc.patch
dma-remove-unsupported-gfp_mask-parameter-from-dma_alloc_from_contiguous.patch

--
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux