lkml.org 
[lkml]   [2019]   [Aug]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v2 4/5] mm/memory_hotplug: Make sure the pfn is aligned to the order when onlining
From
Date
On 14.08.19 22:56, Andrew Morton wrote:
> On Wed, 14 Aug 2019 17:41:08 +0200 David Hildenbrand <david@redhat.com> wrote:
>
>> Commit a9cd410a3d29 ("mm/page_alloc.c: memory hotplug: free pages as higher
>> order") assumed that any PFN we get via memory resources is aligned to
>> to MAX_ORDER - 1, I am not convinced that is always true. Let's play safe,
>> check the alignment and fallback to single pages.
>>
>> ...
>>
>> --- a/mm/memory_hotplug.c
>> +++ b/mm/memory_hotplug.c
>> @@ -646,6 +646,9 @@ static int online_pages_range(unsigned long start_pfn, unsigned long nr_pages,
>> */
>> for (pfn = start_pfn; pfn < end_pfn; pfn += 1ul << order) {
>> order = min(MAX_ORDER - 1, get_order(PFN_PHYS(end_pfn - pfn)));
>> + /* __free_pages_core() wants pfns to be aligned to the order */
>> + if (unlikely(!IS_ALIGNED(pfn, 1ul << order)))
>> + order = 0;
>> (*online_page_callback)(pfn_to_page(pfn), order);
>> }
>
> We aren't sure if this occurs, but if it does, we silently handle it.
>
> It seems a reasonable defensive thing to do, but should we add a
> WARN_ON_ONCE() so that we get to find out about it? If we get such a
> report then we can remove the WARN_ON_ONCE() and add an illuminating
> comment.
>
>

Makes sense, do you want to add the WARN_ON_ONCE() or shall I resend?

I was recently thinking about limiting offlining to memory blocks
without holes - then also onlining would only apply to memory blocks
without holes and we could simplify both paths (single zone/node, no
holes) - including this check, we would always have memory block size
alignments. But I am not sure yet if there is a valid use case for
offlining/re-online boot memory with holes.

--

Thanks,

David / dhildenb

\
 
 \ /
  Last update: 2019-08-14 23:49    [W:0.150 / U:0.132 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site