From: Andrew Morton <akpm@linux-foundation.org>
To: Rabin Vincent <rabin.vincent@axis.com>
Cc: linux@arm.linux.org.uk, mina86@mina86.com,
linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, Rabin Vincent <rabinv@axis.com>
Subject: Re: [PATCH 1/2] mm: cma: split out in_cma check to separate function
Date: Fri, 19 Feb 2016 13:23:23 -0800 [thread overview]
Message-ID: <20160219132323.d3c6bfb8cf1a420b4cb1b508@linux-foundation.org> (raw)
In-Reply-To: <1455869524-13874-1-git-send-email-rabin.vincent@axis.com>
On Fri, 19 Feb 2016 09:12:03 +0100 Rabin Vincent <rabin.vincent@axis.com> wrote:
> Split out the logic in cma_release() which checks if the page is in the
> contiguous area to a new function which can be called separately. ARM
> will use this.
>
> ...
>
> --- a/include/linux/cma.h
> +++ b/include/linux/cma.h
> @@ -27,5 +27,17 @@ extern int cma_init_reserved_mem(phys_addr_t base, phys_addr_t size,
> unsigned int order_per_bit,
> struct cma **res_cma);
> extern struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align);
> +
> extern bool cma_release(struct cma *cma, const struct page *pages, unsigned int count);
> +#ifdef CONFIG_CMA
> +extern bool in_cma(struct cma *cma, const struct page *pages,
> + unsigned int count);
> +#else
> +static inline bool in_cma(struct cma *cma, const struct page *pages,
> + unsigned int count)
> +{
> + return false;
> +}
> +#endif
Calling it "pages" is weird. I immediately read it as a `struct page **'.
Drop the 's' please. Or call it `start_page' if you wish to retain the
"we're dealing with more than one page here" info.
And `nr_pages' is a better name than `count'.
And `in_cma' seems rather ... brief. And it breaks the convention that
interface identifiers start with the name of the subsystem. Look at the rest
of cma.h: cma_get_base(), cma_get_size() cma_declare_contiguous(), etc -
let's not break that.
> #endif
> diff --git a/mm/cma.c b/mm/cma.c
> index ea506eb..55cda16 100644
> --- a/mm/cma.c
> +++ b/mm/cma.c
> @@ -426,6 +426,23 @@ struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align)
> return page;
> }
>
> +bool in_cma(struct cma *cma, const struct page *pages, unsigned int count)
A bit of documentation would be nice.
> +{
> + unsigned long pfn;
> +
> + if (!cma || !pages)
> + return false;
Is this actually needed? If there's no good reason for the test, let's leave
it out because it will just be hiding bugs in the caller.
> + pfn = page_to_pfn(pages);
> +
> + if (pfn < cma->base_pfn || pfn >= cma->base_pfn + cma->count)
> + return false;
> +
> + VM_BUG_ON(pfn + count > cma->base_pfn + cma->count);
> +
> + return true;
> +}
> +
> /**
> * cma_release() - release allocated pages
> * @cma: Contiguous memory region for which the allocation is performed.
Apart from those cosmeticish things, no objections from me.
prev parent reply other threads:[~2016-02-19 21:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-19 8:12 [PATCH 1/2] mm: cma: split out in_cma check to separate function Rabin Vincent
2016-02-19 8:12 ` [PATCH 2/2] ARM: dma-mapping: fix alloc/free for coherent + CMA + gfp=0 Rabin Vincent
2016-02-19 13:50 ` Michal Nazarewicz
2016-02-23 15:30 ` Rabin Vincent
2016-02-19 14:06 ` Russell King - ARM Linux
2016-02-23 15:23 ` Rabin Vincent
2016-02-19 13:46 ` [PATCH 1/2] mm: cma: split out in_cma check to separate function Michal Nazarewicz
2016-02-19 21:23 ` Andrew Morton [this message]
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=20160219132323.d3c6bfb8cf1a420b4cb1b508@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux@arm.linux.org.uk \
--cc=mina86@mina86.com \
--cc=rabin.vincent@axis.com \
--cc=rabinv@axis.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 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).