All of lore.kernel.org
 help / color / mirror / Atom feed
* [merged] mm-cma-fix-cma-aligned-offset-calculation.patch removed from -mm tree
@ 2015-03-16 18:02 akpm
  0 siblings, 0 replies; only message in thread
From: akpm @ 2015-03-16 18:02 UTC (permalink / raw)
  To: dpetigara, gregory.0xf0, mina86, stable, mm-commits


The patch titled
     Subject: mm: cma: fix CMA aligned offset calculation
has been removed from the -mm tree.  Its filename was
     mm-cma-fix-cma-aligned-offset-calculation.patch

This patch was dropped because it was merged into mainline or a subsystem tree

------------------------------------------------------
From: Danesh Petigara <dpetigara@broadcom.com>
Subject: mm: cma: fix CMA aligned offset calculation

The CMA aligned offset calculation is incorrect for non-zero order_per_bit
values.

For example, if cma->order_per_bit=1, cma->base_pfn= 0x2f800000 and
align_order=12, the function returns a value of 0x17c00 instead of 0x400.

This patch fixes the CMA aligned offset calculation.

The previous calculation was wrong and would return too-large values for
the offset, so that when cma_alloc looks for free pages in the bitmap with
the requested alignment > order_per_bit, it starts too far into the bitmap
and so CMA allocations will fail despite there actually being plenty of
free pages remaining.  It will also probably have the wrong alignment. 
With this change, we will get the correct offset into the bitmap.

One affected user is powerpc KVM, which has kvm_cma->order_per_bit set to
KVM_CMA_CHUNK_ORDER - PAGE_SHIFT, or 18 - 12 = 6.

[gregory.0xf0@gmail.com: changelog additions]
Signed-off-by: Danesh Petigara <dpetigara@broadcom.com>
Reviewed-by: Gregory Fong <gregory.0xf0@gmail.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 mm/cma.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff -puN mm/cma.c~mm-cma-fix-cma-aligned-offset-calculation mm/cma.c
--- a/mm/cma.c~mm-cma-fix-cma-aligned-offset-calculation
+++ a/mm/cma.c
@@ -64,15 +64,17 @@ static unsigned long cma_bitmap_aligned_
 	return (1UL << (align_order - cma->order_per_bit)) - 1;
 }
 
+/*
+ * Find a PFN aligned to the specified order and return an offset represented in
+ * order_per_bits.
+ */
 static unsigned long cma_bitmap_aligned_offset(struct cma *cma, int align_order)
 {
-	unsigned int alignment;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-03-16 18:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-16 18:02 [merged] mm-cma-fix-cma-aligned-offset-calculation.patch removed from -mm tree akpm

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.