Re: [RFC PATCH v2] mm: initialize struct pages reserved by ZONE_DEVICE driver.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 17.09.19 11:32, Toshiki Fukasawa wrote:
> On 2019/09/17 16:13, David Hildenbrand wrote:
>> On 17.09.19 04:34, Toshiki Fukasawa wrote:
>>> On 2019/09/09 16:46, David Hildenbrand wrote:
>>>> Let's take a step back here to understand the issues I am aware of. I
>>>> think we should solve this for good now:
>>>>
>>>> A PFN walker takes a look at a random PFN at a random point in time. It
>>>> finds a PFN with SECTION_MARKED_PRESENT && !SECTION_IS_ONLINE. The
>>>> options are:
>>>>
>>>> 1. It is buddy memory (add_memory()) that has not been online yet. The
>>>> memmap contains garbage. Don't access.
>>>>
>>>> 2. It is ZONE_DEVICE memory with a valid memmap. Access it.
>>>>
>>>> 3. It is ZONE_DEVICE memory with an invalid memmap, because the section
>>>> is only partially present: E.g., device starts at offset 64MB within a
>>>> section or the device ends at offset 64MB within a section. Don't access it.
>>>
>>> I don't agree with case #3. In the case, struct page area is not allocated on
>>> ZONE_DEVICE, but is allocated on system memory. So I think we can access the
>>> struct pages. What do you mean "invalid memmap"?
>> No, that's not the case. There is no memory, especially not system
>> memory. We only allow partially present sections (sub-section memory
>> hotplug) for ZONE_DEVICE.
> 
> Let me clear my thoughts. If I read correctly, the struct pages for sections
> (including partially present sections) on ZONE_DEVICE are allocated by
> vmemmap_populate(). And all the struct pages except (altmap->base_pfn) to
> (altmap->base_pfn + altmap->reserve) are initialized by memmap_init_zone()
> and memmap_init_zone_device().
> 
> Do struct pages for partially present sections go through a different process?

No. However, the memmap is initialized via move_pfn_range_to_zone(). So
partially present sections will have partially uninitialized memmaps.

But I get your point. I just saw that pfn_valid() does take care of the
subsection map via pfn_section_valid(). - pfn_present() does not, which
is weird, but ok.

So I agree, in case #3 might have a partially uninitialized memmap, but
we can test via pfn_valid() if the memory is at least valid. So there is
some way to test. Then we're back to the race between adding the memory
and initializing the memmap.

Thanks!

> 
> Thanks,
> Toshiki Fukasawa
>>


-- 

Thanks,

David / dhildenb





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux