mm/cma: fix cma bitmap aligned mask computing
Subsystems (2)
PATCH 1/1 mm/cma: fix cma bitmap aligned mask computing
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.
--- mm/cma.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
mm/cma.c +4 -1
@@ -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)
Signature · 8 lines
1.7.10.4 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 4 lines · Weijie Yang
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 thancma->order_per_bit.
Quoted 8 lines
Take kvm for example (
PAGE_SHIFT= 12),kvm_cma->order_per_bitis set to 6, whenkvm_alloc_rma()tries to allockvm_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 <[email protected]>
Should that also get:
Quoted 24 lines
--- mm/cma.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)mm/cma.c +4
-1@@ -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)Signature · 1 line
1.7.10.4
Signature · 10 lines
Best regards, _ _ .o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o ..o | Computer Science, Michał “mina86” Nazarewicz (o o) ooo +--<[email protected]>--<xmpp:[email protected]>--ooO--(_)--Ooo-- -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>