lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 5 Oct 2021 10:06:24 -0700
From:   Mike Kravetz <mike.kravetz@...cle.com>
To:     Oscar Salvador <osalvador@...e.de>
Cc:     linux-mm@...ck.org, linux-kernel@...r.kernel.org,
        David Hildenbrand <david@...hat.com>,
        Michal Hocko <mhocko@...e.com>, Zi Yan <ziy@...dia.com>,
        Muchun Song <songmuchun@...edance.com>,
        Naoya Horiguchi <naoya.horiguchi@...ux.dev>,
        David Rientjes <rientjes@...gle.com>,
        "Aneesh Kumar K . V" <aneesh.kumar@...ux.ibm.com>,
        Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH v3 2/5] mm/cma: add cma_pages_valid to determine if pages
 are in CMA

On 10/5/21 1:45 AM, Oscar Salvador wrote:
> 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;
>> -
> 
> After this patch, the timing of printing the debug statement changes as we back
> off earlier.
> You might want to point that out in the changelog in case someone wonders why.
> 

When making this change, I did not want to duplicate that debug
statement.  However, duplicated code only becomes an issue if
CONFIG_DEBUG.  So, duplication should be acceptable.

I will make the debug statements function as before.
-- 
Mike Kravetz

Powered by blists - more mailing lists