All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Nazarewicz <mina86@mina86.com>
To: Weijie Yang <weijie.yang@samsung.com>, iamjoonsoo.kim@lge.com
Cc: aneesh.kumar@linux.vnet.ibm.com, m.szyprowski@samsung.com,
	'Andrew Morton' <akpm@linux-foundation.org>,
	'linux-kernel' <linux-kernel@vger.kernel.org>,
	'Linux-MM' <linux-mm@kvack.org>
Subject: Re: [PATCH] mm/cma: fix cma bitmap aligned mask computing
Date: Fri, 10 Oct 2014 16:18:54 +0200	[thread overview]
Message-ID: <xa1tvbns2ek1.fsf@mina86.com> (raw)
In-Reply-To: <000301cfe430$504b0290$f0e107b0$%yang@samsung.com>

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>

WARNING: multiple messages have this Message-ID (diff)
From: Michal Nazarewicz <mina86@mina86.com>
To: Weijie Yang <weijie.yang@samsung.com>, iamjoonsoo.kim@lge.com
Cc: aneesh.kumar@linux.vnet.ibm.com, m.szyprowski@samsung.com,
	"'Andrew Morton'" <akpm@linux-foundation.org>,
	"'linux-kernel'" <linux-kernel@vger.kernel.org>,
	"'Linux-MM'" <linux-mm@kvack.org>
Subject: Re: [PATCH] mm/cma: fix cma bitmap aligned mask computing
Date: Fri, 10 Oct 2014 16:18:54 +0200	[thread overview]
Message-ID: <xa1tvbns2ek1.fsf@mina86.com> (raw)
In-Reply-To: <000301cfe430$504b0290$f0e107b0$%yang@samsung.com>

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--

  reply	other threads:[~2014-10-10 14:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-10  2:15 [PATCH] mm/cma: fix cma bitmap aligned mask computing Weijie Yang
2014-10-10  2:15 ` Weijie Yang
2014-10-10 14:18 ` Michal Nazarewicz [this message]
2014-10-10 14:18   ` Michal Nazarewicz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xa1tvbns2ek1.fsf@mina86.com \
    --to=mina86@mina86.com \
    --cc=akpm@linux-foundation.org \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=m.szyprowski@samsung.com \
    --cc=weijie.yang@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.