* [PATCH] mm/cma: fix cma bitmap aligned mask computing
@ 2014-10-10 2:15 Weijie Yang
2014-10-10 14:18 ` Michal Nazarewicz
0 siblings, 1 reply; 2+ messages in thread
From: Weijie Yang @ 2014-10-10 2:15 UTC (permalink / raw)
To: iamjoonsoo.kim
Cc: mina86, aneesh.kumar, m.szyprowski, 'Andrew Morton',
'linux-kernel', 'Linux-MM'
The current cma bitmap aligned mask compute way is incorrect, it could
cause an unexpected align when using cma_alloc() if wanted align order
is bigger than cma->order_per_bit.
Take kvm for example (PAGE_SHIFT = 12), kvm_cma->order_per_bit is set to 6,
when kvm_alloc_rma() tries to alloc kvm_rma_pages, it will input 15 as
expected align value, after using current computing, however, we get 0 as
cma bitmap aligned mask other than 511.
This patch fixes the cma bitmap aligned mask compute way.
Signed-off-by: Weijie Yang <weijie.yang@samsung.com>
---
mm/cma.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/mm/cma.c b/mm/cma.c
index c17751c..f6207ef 100644
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -57,7 +57,10 @@ unsigned long cma_get_size(struct cma *cma)
static unsigned long cma_bitmap_aligned_mask(struct cma *cma, int align_order)
{
- return (1UL << (align_order >> cma->order_per_bit)) - 1;
+ if (align_order <= cma->order_per_bit)
+ return 0;
+ else
+ return (1UL << (align_order - cma->order_per_bit)) - 1;
}
static unsigned long cma_bitmap_maxno(struct cma *cma)
--
1.7.10.4
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mm/cma: fix cma bitmap aligned mask computing
2014-10-10 2:15 [PATCH] mm/cma: fix cma bitmap aligned mask computing Weijie Yang
@ 2014-10-10 14:18 ` Michal Nazarewicz
0 siblings, 0 replies; 2+ messages in thread
From: Michal Nazarewicz @ 2014-10-10 14:18 UTC (permalink / raw)
To: Weijie Yang, iamjoonsoo.kim
Cc: aneesh.kumar, m.szyprowski, 'Andrew Morton',
'linux-kernel', 'Linux-MM'
On Fri, Oct 10 2014, Weijie Yang wrote:
> The current cma bitmap aligned mask compute way is incorrect, it could
> cause an unexpected align when using cma_alloc() if wanted align order
> is bigger than cma->order_per_bit.
>
> Take kvm for example (PAGE_SHIFT = 12), kvm_cma->order_per_bit is set to 6,
> when kvm_alloc_rma() tries to alloc kvm_rma_pages, it will input 15 as
> expected align value, after using current computing, however, we get 0 as
> cma bitmap aligned mask other than 511.
>
> This patch fixes the cma bitmap aligned mask compute way.
>
> Signed-off-by: Weijie Yang <weijie.yang@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Should that also get:
Cc: <stable@vger.kernel.org> # v3.17
> ---
> mm/cma.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/mm/cma.c b/mm/cma.c
> index c17751c..f6207ef 100644
> --- a/mm/cma.c
> +++ b/mm/cma.c
> @@ -57,7 +57,10 @@ unsigned long cma_get_size(struct cma *cma)
>
> static unsigned long cma_bitmap_aligned_mask(struct cma *cma, int align_order)
> {
> - return (1UL << (align_order >> cma->order_per_bit)) - 1;
> + if (align_order <= cma->order_per_bit)
> + return 0;
> + else
> + return (1UL << (align_order - cma->order_per_bit)) - 1;
> }
>
> static unsigned long cma_bitmap_maxno(struct cma *cma)
> --
> 1.7.10.4
>
>
--
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Michał “mina86” Nazarewicz (o o)
ooo +--<mpn@google.com>--<xmpp:mina86@jabber.org>--ooO--(_)--Ooo--
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-10-10 14:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-10 2:15 [PATCH] mm/cma: fix cma bitmap aligned mask computing Weijie Yang
2014-10-10 14:18 ` Michal Nazarewicz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).