lkml.org 
[lkml]   [2021]   [Oct]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3 2/5] mm/cma: add cma_pages_valid to determine if pages are in CMA
On Fri, Oct 01, 2021 at 10:52:07AM -0700, Mike Kravetz wrote:
> +bool cma_pages_valid(struct cma *cma, const struct page *pages,
> + unsigned long count)
> +{
> + unsigned long pfn;
> +
> + if (!cma || !pages)
> + return false;
> +
> + pfn = page_to_pfn(pages);
> +
> + if (pfn < cma->base_pfn || pfn >= cma->base_pfn + cma->count)
> + return false;
> +
> + return true;
> +}
> +
> /**
> * cma_release() - release allocated pages
> * @cma: Contiguous memory region for which the allocation is performed.
> @@ -539,16 +555,13 @@ bool cma_release(struct cma *cma, const struct page *pages,
> {
> unsigned long pfn;
>
> - if (!cma || !pages)
> + if (!cma_pages_valid(cma, pages, count))
> return false;
>
> pr_debug("%s(page %p, count %lu)\n", __func__, (void *)pages, count);
>
> pfn = page_to_pfn(pages);
>
> - if (pfn < cma->base_pfn || pfn >= cma->base_pfn + cma->count)
> - return false;
> -

Might be worth noting that after this change, the debug statement will not be
printed as before. Now, we back off before firing it.

You might want to point that out in the changelog in case someone wonders
why.

--
Oscar Salvador
SUSE Labs

\
 
 \ /
  Last update: 2021-10-05 10:43    [W:0.040 / U:0.120 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site