[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <185d502e-d5a8-9149-18fc-1ef9b251843e@redhat.com>
Date: Thu, 6 Feb 2020 14:59:50 +0100
From: David Hildenbrand <david@...hat.com>
To: Wei Yang <richard.weiyang@...il.com>
Cc: Wei Yang <richardw.yang@...ux.intel.com>,
akpm@...ux-foundation.org, osalvador@...e.de,
dan.j.williams@...el.com, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, bhe@...hat.com
Subject: Re: [PATCH] mm/sparsemem: pfn_to_page is not valid yet on SPARSEMEM
On 06.02.20 14:57, Wei Yang wrote:
> On Thu, Feb 06, 2020 at 02:28:53PM +0100, David Hildenbrand wrote:
>> On 06.02.20 13:53, Wei Yang wrote:
>>> When we use SPARSEMEM instead of SPARSEMEM_VMEMMAP, pfn_to_page()
>>> doesn't work before sparse_init_one_section() is called. This leads to a
>>> crash when hotplug memory.
>>>
>>> We should use memmap as it did.
>>>
>>> Fixes: ba72b4c8cf60 ("mm/sparsemem: support sub-section hotplug")
>>> Signed-off-by: Wei Yang <richardw.yang@...ux.intel.com>
>>> CC: Dan Williams <dan.j.williams@...el.com>
>>> ---
>>> mm/sparse.c | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/mm/sparse.c b/mm/sparse.c
>>> index 5a8599041a2a..2efb24ff8f96 100644
>>> --- a/mm/sparse.c
>>> +++ b/mm/sparse.c
>>> @@ -882,7 +882,7 @@ int __meminit sparse_add_section(int nid, unsigned long start_pfn,
>>> * Poison uninitialized struct pages in order to catch invalid flags
>>> * combinations.
>>> */
>>> - page_init_poison(pfn_to_page(start_pfn), sizeof(struct page) * nr_pages);
>>> + page_init_poison(memmap, sizeof(struct page) * nr_pages);
>>
>> If you add sub-sections that don't fall onto the start of the section,
>>
>> pfn_to_page(start_pfn) != memmap
>>
>> and your patch would break that under SPARSEMEM_VMEMMAP if I am not wrong.
>>
>> Instead of memmap, there would have to be something like
>>
>> memmap + (start_pfn - SECTION_ALIGN_DOWN(start_pfn))
>>
>> If I am not wrong :)
>
> Hi, David, Thanks for your comment.
>
> To be hones, I am not familiar with SPARSEMEM_VMEMMAP. Here is my
> understanding about section_activate() when SPARSEMEM_VMEMMAP is set.
>
> section_activate(nid, start_pfn, nr_pages, altmap)
> populate_section_mmemap(start_pfn, nr_pages, nid, altmap)
> __populate_section_mmemap(start_pfn, nr_pages, nid, altmap)
> return pfn_to_page(start_pfn)
>
> So the memmap is the page struct for start_pfn when SPARSEMEM_VMEMMAP is set.
>
> Maybe I missed some critical part?
I was assuming that memmap is the memmap of the section, not of the
sub-section. (judging from the change in the original patch)
If the right memmap pointer to the sub-section is returned, then we are
fine. Will double check :)
--
Thanks,
David / dhildenb
Powered by blists - more mailing lists