Re: [PATCH v1 05/29] virtio-mem: generalize check for added memory

From: David Hildenbrand
Date: Fri Oct 16 2020 - 06:33:08 EST


>>> Ok, I seems to understand the logic now.
>>>
>>> But how we prevent ONLINE_PARTIAL memory block get offlined? There are three
>>> calls in virtio_mem_set_fake_offline(), while all of them adjust page's flag.
>>> How they hold reference to struct page?
>>
>> Sorry, I should have given you the right pointer. (similar to my other
>> reply)
>>
>> We hold a reference either via
>>
>> 1. alloc_contig_range()
>
> I am not familiar with this one, need to spend some time to look into.

Each individual page will have a pagecount of 1.

>
>> 2. memmap init code, when not calling generic_online_page().
>
> I may miss some code here. Before online pages, memmaps are allocated in
> section_activate(). They are supposed to be zero-ed. (I don't get the exact
> code line.) I am not sure when we grab a refcount here.

Best to refer to __init_single_page() -> init_page_count().

Each page that wasn't onlined via generic_online_page() has a refcount
of 1 and looks like allocated.

--
Thanks,

David / dhildenb