From: Michal Nazarewicz <mina86@mina86.com>
To: Danesh Petigara <dpetigara@broadcom.com>, akpm@linux-foundation.org
Cc: m.szyprowski@samsung.com, iamjoonsoo.kim@lge.com,
aneesh.kumar@linux.vnet.ibm.com,
laurent.pinchart+renesas@ideasonboard.com,
gregory.0xf0@gmail.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] mm: cma: fix CMA aligned offset calculation
Date: Tue, 24 Feb 2015 22:10:28 +0100 [thread overview]
Message-ID: <xa1twq37ow1n.fsf@mina86.com> (raw)
In-Reply-To: <1424807759-23311-1-git-send-email-dpetigara@broadcom.com>
On Tue, Feb 24 2015, Danesh Petigara <dpetigara@broadcom.com> wrote:
> 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.
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Danesh Petigara <dpetigara@broadcom.com>
> Reviewed-by: Gregory Fong <gregory.0xf0@gmail.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
> ---
> mm/cma.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/mm/cma.c b/mm/cma.c
> index 75016fd..58f37bd 100644
> --- a/mm/cma.c
> +++ b/mm/cma.c
> @@ -70,9 +70,13 @@ static unsigned long cma_bitmap_aligned_offset(struct cma *cma, int align_order)
>
> if (align_order <= cma->order_per_bit)
> return 0;
> - alignment = 1UL << (align_order - cma->order_per_bit);
> - return ALIGN(cma->base_pfn, alignment) -
> - (cma->base_pfn >> cma->order_per_bit);
> +
> + /*
> + * Find a PFN aligned to the specified order and return
> + * an offset represented in order_per_bits.
> + */
It probably makes sense to move this comment outside of the function as
function documentation.
> + return (ALIGN(cma->base_pfn, (1UL << align_order))
> + - cma->base_pfn) >> cma->order_per_bit;
> }
>
> static unsigned long cma_bitmap_maxno(struct cma *cma)
> --
> 1.9.1
>
--
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: Danesh Petigara <dpetigara@broadcom.com>, akpm@linux-foundation.org
Cc: m.szyprowski@samsung.com, iamjoonsoo.kim@lge.com,
aneesh.kumar@linux.vnet.ibm.com,
laurent.pinchart+renesas@ideasonboard.com,
gregory.0xf0@gmail.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org,
Danesh Petigara <dpetigara@broadcom.com>,
stable@vger.kernel.org
Subject: Re: [PATCH] mm: cma: fix CMA aligned offset calculation
Date: Tue, 24 Feb 2015 22:10:28 +0100 [thread overview]
Message-ID: <xa1twq37ow1n.fsf@mina86.com> (raw)
In-Reply-To: <1424807759-23311-1-git-send-email-dpetigara@broadcom.com>
On Tue, Feb 24 2015, Danesh Petigara <dpetigara@broadcom.com> wrote:
> 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.
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Danesh Petigara <dpetigara@broadcom.com>
> Reviewed-by: Gregory Fong <gregory.0xf0@gmail.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
> ---
> mm/cma.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/mm/cma.c b/mm/cma.c
> index 75016fd..58f37bd 100644
> --- a/mm/cma.c
> +++ b/mm/cma.c
> @@ -70,9 +70,13 @@ static unsigned long cma_bitmap_aligned_offset(struct cma *cma, int align_order)
>
> if (align_order <= cma->order_per_bit)
> return 0;
> - alignment = 1UL << (align_order - cma->order_per_bit);
> - return ALIGN(cma->base_pfn, alignment) -
> - (cma->base_pfn >> cma->order_per_bit);
> +
> + /*
> + * Find a PFN aligned to the specified order and return
> + * an offset represented in order_per_bits.
> + */
It probably makes sense to move this comment outside of the function as
function documentation.
> + return (ALIGN(cma->base_pfn, (1UL << align_order))
> + - cma->base_pfn) >> cma->order_per_bit;
> }
>
> static unsigned long cma_bitmap_maxno(struct cma *cma)
> --
> 1.9.1
>
--
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--
WARNING: multiple messages have this Message-ID (diff)
From: Michal Nazarewicz <mina86@mina86.com>
To: Danesh Petigara <dpetigara@broadcom.com>, akpm@linux-foundation.org
Cc: m.szyprowski@samsung.com, iamjoonsoo.kim@lge.com,
aneesh.kumar@linux.vnet.ibm.com,
laurent.pinchart+renesas@ideasonboard.com,
gregory.0xf0@gmail.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org,
Danesh Petigara <dpetigara@broadcom.com>,
stable@vger.kernel.org
Subject: Re: [PATCH] mm: cma: fix CMA aligned offset calculation
Date: Tue, 24 Feb 2015 22:10:28 +0100 [thread overview]
Message-ID: <xa1twq37ow1n.fsf@mina86.com> (raw)
In-Reply-To: <1424807759-23311-1-git-send-email-dpetigara@broadcom.com>
On Tue, Feb 24 2015, Danesh Petigara <dpetigara@broadcom.com> wrote:
> 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.
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Danesh Petigara <dpetigara@broadcom.com>
> Reviewed-by: Gregory Fong <gregory.0xf0@gmail.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
> ---
> mm/cma.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/mm/cma.c b/mm/cma.c
> index 75016fd..58f37bd 100644
> --- a/mm/cma.c
> +++ b/mm/cma.c
> @@ -70,9 +70,13 @@ static unsigned long cma_bitmap_aligned_offset(struct cma *cma, int align_order)
>
> if (align_order <= cma->order_per_bit)
> return 0;
> - alignment = 1UL << (align_order - cma->order_per_bit);
> - return ALIGN(cma->base_pfn, alignment) -
> - (cma->base_pfn >> cma->order_per_bit);
> +
> + /*
> + * Find a PFN aligned to the specified order and return
> + * an offset represented in order_per_bits.
> + */
It probably makes sense to move this comment outside of the function as
function documentation.
> + return (ALIGN(cma->base_pfn, (1UL << align_order))
> + - cma->base_pfn) >> cma->order_per_bit;
> }
>
> static unsigned long cma_bitmap_maxno(struct cma *cma)
> --
> 1.9.1
>
--
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>
next prev parent reply other threads:[~2015-02-24 21:10 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-24 19:55 [PATCH] mm: cma: fix CMA aligned offset calculation Danesh Petigara
2015-02-24 19:55 ` Danesh Petigara
2015-02-24 19:55 ` Danesh Petigara
2015-02-24 20:54 ` Gregory Fong
2015-02-24 20:54 ` Gregory Fong
2015-02-24 21:10 ` Michal Nazarewicz [this message]
2015-02-24 21:10 ` Michal Nazarewicz
2015-02-24 21:10 ` Michal Nazarewicz
2015-02-24 21:43 ` Danesh Petigara
2015-02-24 21:43 ` Danesh Petigara
2015-02-24 21:43 ` Danesh Petigara
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=xa1twq37ow1n.fsf@mina86.com \
--to=mina86@mina86.com \
--cc=akpm@linux-foundation.org \
--cc=aneesh.kumar@linux.vnet.ibm.com \
--cc=dpetigara@broadcom.com \
--cc=gregory.0xf0@gmail.com \
--cc=iamjoonsoo.kim@lge.com \
--cc=laurent.pinchart+renesas@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=m.szyprowski@samsung.com \
--cc=stable@vger.kernel.org \
/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.