From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0CC8CC433DF for ; Fri, 16 Oct 2020 22:38:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 63D7920874 for ; Fri, 16 Oct 2020 22:38:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 63D7920874 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3D6456B005D; Fri, 16 Oct 2020 18:38:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 31D846B0062; Fri, 16 Oct 2020 18:38:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 18AD76B0068; Fri, 16 Oct 2020 18:38:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0169.hostedemail.com [216.40.44.169]) by kanga.kvack.org (Postfix) with ESMTP id CCD486B005D for ; Fri, 16 Oct 2020 18:38:17 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 676E2180AD807 for ; Fri, 16 Oct 2020 22:38:17 +0000 (UTC) X-FDA: 77379253434.23.cent61_230109227220 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin23.hostedemail.com (Postfix) with ESMTP id 43A2E37608 for ; Fri, 16 Oct 2020 22:38:17 +0000 (UTC) X-HE-Tag: cent61_230109227220 X-Filterd-Recvd-Size: 3722 Received: from out30-45.freemail.mail.aliyun.com (out30-45.freemail.mail.aliyun.com [115.124.30.45]) by imf09.hostedemail.com (Postfix) with ESMTP for ; Fri, 16 Oct 2020 22:38:15 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R201e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01424;MF=richard.weiyang@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0UCEHOas_1602887891; Received: from localhost(mailfrom:richard.weiyang@linux.alibaba.com fp:SMTPD_---0UCEHOas_1602887891) by smtp.aliyun-inc.com(127.0.0.1); Sat, 17 Oct 2020 06:38:12 +0800 Date: Sat, 17 Oct 2020 06:38:11 +0800 From: Wei Yang To: David Hildenbrand Cc: Wei Yang , linux-kernel@vger.kernel.org, linux-mm@kvack.org, virtualization@lists.linux-foundation.org, Andrew Morton , "Michael S . Tsirkin" , Jason Wang , Pankaj Gupta Subject: Re: [PATCH v1 05/29] virtio-mem: generalize check for added memory Message-ID: <20201016223811.GJ44269@L-31X9LVDL-1304.local> Reply-To: Wei Yang References: <20201012125323.17509-1-david@redhat.com> <20201012125323.17509-6-david@redhat.com> <20201015082808.GE86495@L-31X9LVDL-1304.local> <994394f3-c16d-911c-c9fc-d2280f32e7b1@redhat.com> <20201016021651.GI86495@L-31X9LVDL-1304.local> <5caec772-295c-436a-2b19-ca261ea1ad0c@redhat.com> <20201016100211.GI44269@L-31X9LVDL-1304.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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. >-- >Thanks, > >David / dhildenb -- Wei Yang Help you, Help me