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 171ADC433DF for ; Sun, 18 Oct 2020 12:27:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7D0452087C for ; Sun, 18 Oct 2020 12:27:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7D0452087C 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 6CCFB6B0062; Sun, 18 Oct 2020 08:27:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 67EC06B0068; Sun, 18 Oct 2020 08:27:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5949B6B006E; Sun, 18 Oct 2020 08:27:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0066.hostedemail.com [216.40.44.66]) by kanga.kvack.org (Postfix) with ESMTP id 290036B0062 for ; Sun, 18 Oct 2020 08:27:49 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id A947E180AD802 for ; Sun, 18 Oct 2020 12:27:48 +0000 (UTC) X-FDA: 77384972616.15.noise30_23041b32722e Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin15.hostedemail.com (Postfix) with ESMTP id 883BA1814B0C7 for ; Sun, 18 Oct 2020 12:27:48 +0000 (UTC) X-HE-Tag: noise30_23041b32722e X-Filterd-Recvd-Size: 4014 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) by imf37.hostedemail.com (Postfix) with ESMTP for ; Sun, 18 Oct 2020 12:27:47 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R211e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04395;MF=richard.weiyang@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0UCMqSC1_1603024061; Received: from localhost(mailfrom:richard.weiyang@linux.alibaba.com fp:SMTPD_---0UCMqSC1_1603024061) by smtp.aliyun-inc.com(127.0.0.1); Sun, 18 Oct 2020 20:27:42 +0800 Date: Sun, 18 Oct 2020 20:27:41 +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: <20201018122741.GB50506@L-31X9LVDL-1304> Reply-To: Wei Yang References: <20201016223811.GJ44269@L-31X9LVDL-1304.local> <2E12AC3C-872A-4B30-8FD7-12420FA1D14E@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <2E12AC3C-872A-4B30-8FD7-12420FA1D14E@redhat.com> Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sat, Oct 17, 2020 at 09:39:38AM +0200, David Hildenbrand wrote: > >> Am 17.10.2020 um 00:38 schrieb Wei Yang : >>=20 >> =EF=BB=BFOn Fri, Oct 16, 2020 at 12:32:50PM +0200, David Hildenbrand w= rote: >>>>>> Ok, I seems to understand the logic now. >>>>>>=20 >>>>>> 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 p= age's flag. >>>>>> How they hold reference to struct page? >>>>>=20 >>>>> Sorry, I should have given you the right pointer. (similar to my ot= her >>>>> reply) >>>>>=20 >>>>> We hold a reference either via >>>>>=20 >>>>> 1. alloc_contig_range() >>>>=20 >>>> I am not familiar with this one, need to spend some time to look int= o. >>>=20 >>> Each individual page will have a pagecount of 1. >>>=20 >>>>=20 >>>>> 2. memmap init code, when not calling generic_online_page(). >>>>=20 >>>> I may miss some code here. Before online pages, memmaps are allocate= d in >>>> section_activate(). They are supposed to be zero-ed. (I don't get th= e exact >>>> code line.) I am not sure when we grab a refcount here. >>>=20 >>> Best to refer to __init_single_page() -> init_page_count(). >>>=20 >>> Each page that wasn't onlined via generic_online_page() has a refcoun= t >>> of 1 and looks like allocated. >>>=20 >>=20 >> Thanks, I see the logic. >>=20 >> online_pages() >> move_pfn_range_to_zone() --- 1) >> online_pages_range() --- 2) >>=20 >> At 1), __init_single_page() would set page count to 1. At 2), >> generic_online_page() would clear page count, while the call back woul= d not. >>=20 >> 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. >>=20 >> So the GUARD we prevent offline partial-onlined pages is >>=20 >> (PageOffline && page_count) >>=20 >> And your commit aa218795cb5fd583c94f >>=20 >> mm: Allow to offline unmovable PageOffline() pages via MEM_GOING_OFFLI= NE >>=20 >> is introduced to handle this case. >>=20 >> That's pretty clear now. >>=20 > >I=E2=80=98m happy to see that I am no longer the only person that unders= tands all this magic :) Thanks for sharing the magic :-) > >Thanks for having a look / reviewing! > >>> --=20 >>> Thanks, >>>=20 >>> David / dhildenb >>=20 >> --=20 >> Wei Yang >> Help you, Help me >>=20 --=20 Wei Yang Help you, Help me