From: David Hildenbrand <david@redhat.com>
To: Anshuman Khandual <anshuman.khandual@arm.com>,
Michal Hocko <mhocko@kernel.org>
Cc: linux-mm@kvack.org, Mike Kravetz <mike.kravetz@oracle.com>,
Andrew Morton <akpm@linux-foundation.org>,
Vlastimil Babka <vbabka@suse.cz>,
David Rientjes <rientjes@google.com>,
Andrea Arcangeli <aarcange@redhat.com>,
Oscar Salvador <osalvador@suse.de>,
Mel Gorman <mgorman@techsingularity.net>,
Mike Rapoport <rppt@linux.ibm.com>,
Dan Williams <dan.j.williams@intel.com>,
Pavel Tatashin <pavel.tatashin@microsoft.com>,
Matthew Wilcox <willy@infradead.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH V2] mm/page_alloc: Add alloc_contig_pages()
Date: Wed, 16 Oct 2019 18:48:37 +0200 [thread overview]
Message-ID: <e37c16f5-7068-5359-a539-bee58e705122@redhat.com> (raw)
In-Reply-To: <97cadd99-d05e-3174-6532-fe18f0301ba7@arm.com>
On 16.10.19 17:31, Anshuman Khandual wrote:
>
>
> On 10/16/2019 06:11 PM, Michal Hocko wrote:
>> On Wed 16-10-19 14:29:05, David Hildenbrand wrote:
>>> On 16.10.19 13:51, Michal Hocko wrote:
>>>> On Wed 16-10-19 16:43:57, Anshuman Khandual wrote:
>>>>>
>>>>>
>>>>> On 10/16/2019 04:39 PM, David Hildenbrand wrote:
>>>> [...]
>>>>>> Just to make sure, you ignored my comment regarding alignment
>>>>>> although I explicitly mentioned it a second time? Thanks.
>>>>>
>>>>> I had asked Michal explicitly what to be included for the respin. Anyways
>>>>> seems like the previous thread is active again. I am happy to incorporate
>>>>> anything new getting agreed on there.
>>>>
>>>> Your patch is using the same alignment as the original code would do. If
>>>> an explicit alignement is needed then this can be added on top, right?
>>>>
>>>
>>> Again, the "issue" I see here is that we could now pass in numbers that are
>>> not a power of two. For gigantic pages it was clear that we always have a
>>> number of two. The alignment does not make any sense otherwise.
>
> ALIGN() does expect nr_pages two be power of two otherwise the mask
> value might not be correct, affecting start pfn value for a zone.
>
> #define ALIGN(x, a) __ALIGN_KERNEL((x), (a))
> #define __ALIGN_KERNEL(x, a) __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1)
> #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
>
>>>
>>> What I'm asking for is
>>>
>>> a) Document "The resulting PFN is aligned to nr_pages" and "nr_pages should
>>> be a power of two".
>>
>> OK, this makes sense.
> Sure, will add this to the alloc_contig_pages() helper description and
> in the commit message as well.
As long as it is documented that implicit alignment will happen, fine
with me.
The thing about !is_power_of2() is that we usually don't need an
alignment there (or instead an explicit one). And as I mentioned, the
current function might fail easily to allocate a suitable range due to
the way the search works (== check aligned blocks only). The search
really only provides reliable results when size==alignment and it's a
power of two IMHO. Not documenting that is in my opinion misleading -
somebody who wants !is_power_of2() and has no alignment requirements
should probably rework the function first.
So with some documentation regarding that
Acked-by: David Hildenbrand <david@redhat.com>
--
Thanks,
David / dhildenb
next prev parent reply other threads:[~2019-10-16 16:48 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-16 11:02 [PATCH V2] mm/page_alloc: Add alloc_contig_pages() Anshuman Khandual
2019-10-16 11:09 ` David Hildenbrand
2019-10-16 11:13 ` Anshuman Khandual
2019-10-16 11:51 ` Michal Hocko
2019-10-16 12:29 ` David Hildenbrand
2019-10-16 12:41 ` Michal Hocko
2019-10-16 15:31 ` Anshuman Khandual
2019-10-16 15:45 ` Michal Hocko
2019-10-16 16:48 ` David Hildenbrand [this message]
[not found] ` <c60b9e95-5c6c-fcb2-c8bb-13e7646ba8ea@arm.com>
2019-10-17 7:11 ` Michal Hocko
2019-10-17 7:21 ` David Hildenbrand
2019-10-17 7:34 ` Michal Hocko
2019-10-17 7:38 ` David Hildenbrand
2019-10-17 0:50 ` Mike Kravetz
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=e37c16f5-7068-5359-a539-bee58e705122@redhat.com \
--to=david@redhat.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=anshuman.khandual@arm.com \
--cc=dan.j.williams@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@techsingularity.net \
--cc=mhocko@kernel.org \
--cc=mike.kravetz@oracle.com \
--cc=osalvador@suse.de \
--cc=pavel.tatashin@microsoft.com \
--cc=rientjes@google.com \
--cc=rppt@linux.ibm.com \
--cc=vbabka@suse.cz \
--cc=willy@infradead.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 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).