lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sat, 17 Oct 2020 09:39:38 +0200
From:   David Hildenbrand <david@...hat.com>
To:     Wei Yang <richard.weiyang@...ux.alibaba.com>
Cc:     David Hildenbrand <david@...hat.com>, linux-kernel@...r.kernel.org,
        linux-mm@...ck.org, virtualization@...ts.linux-foundation.org,
        Andrew Morton <akpm@...ux-foundation.org>,
        "Michael S . Tsirkin" <mst@...hat.com>,
        Jason Wang <jasowang@...hat.com>,
        Pankaj Gupta <pankaj.gupta.linux@...il.com>
Subject: Re: [PATCH v1 05/29] virtio-mem: generalize check for added memory


> Am 17.10.2020 um 00:38 schrieb Wei Yang <richard.weiyang@...ux.alibaba.com>:
> 
> On Fri, Oct 16, 2020 at 12:32:50PM +0200, David Hildenbrand wrote:
>>>>> 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, I see the logic.
> 
>    online_pages()
>        move_pfn_range_to_zone()  --- 1)
>    online_pages_range()      --- 2)
> 
> At 1), __init_single_page() would set page count to 1. At 2),
> generic_online_page() would clear page count, while the call back would not.
> 
> Then I am trying to search the place where un-zero page count prevent offline.
> scan_movable_pages() would fail, since this is a PageOffline() and has 1 page
> count.
> 
> So the GUARD we prevent offline partial-onlined pages is
> 
>    (PageOffline && page_count)
> 
> And your commit aa218795cb5fd583c94f
> 
> mm: Allow to offline unmovable PageOffline() pages via MEM_GOING_OFFLINE
> 
> is introduced to handle this case.
> 
> That's pretty clear now.
> 

I‘m happy to see that I am no longer the only person that understands all this magic :)

Thanks for having a look / reviewing!

>> -- 
>> Thanks,
>> 
>> David / dhildenb
> 
> -- 
> Wei Yang
> Help you, Help me
> 

Powered by blists - more mailing lists