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 E56E4C433E7 for ; Sun, 18 Oct 2020 12:37:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2E5B9208B8 for ; Sun, 18 Oct 2020 12:37:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2E5B9208B8 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 616D56B0062; Sun, 18 Oct 2020 08:37:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5A0C66B0068; Sun, 18 Oct 2020 08:37:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 48FE26B006E; Sun, 18 Oct 2020 08:37:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0201.hostedemail.com [216.40.44.201]) by kanga.kvack.org (Postfix) with ESMTP id 17DEC6B0062 for ; Sun, 18 Oct 2020 08:37:43 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id A8D80180AD802 for ; Sun, 18 Oct 2020 12:37:42 +0000 (UTC) X-FDA: 77384997564.03.shock41_55170342722e Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin03.hostedemail.com (Postfix) with ESMTP id 899B628A4E8 for ; Sun, 18 Oct 2020 12:37:42 +0000 (UTC) X-HE-Tag: shock41_55170342722e X-Filterd-Recvd-Size: 2918 Received: from out30-44.freemail.mail.aliyun.com (out30-44.freemail.mail.aliyun.com [115.124.30.44]) by imf43.hostedemail.com (Postfix) with ESMTP for ; Sun, 18 Oct 2020 12:37:41 +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=alimailimapcm10staff010182156082;MF=richard.weiyang@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0UCMVb5V_1603024653; Received: from localhost(mailfrom:richard.weiyang@linux.alibaba.com fp:SMTPD_---0UCMVb5V_1603024653) by smtp.aliyun-inc.com(127.0.0.1); Sun, 18 Oct 2020 20:37:34 +0800 Date: Sun, 18 Oct 2020 20:37:33 +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 13/29] virtio-mem: factor out handling of fake-offline pages in memory notifier Message-ID: <20201018123733.GC50506@L-31X9LVDL-1304> Reply-To: Wei Yang References: <20201012125323.17509-1-david@redhat.com> <20201012125323.17509-14-david@redhat.com> <20201016071502.GM86495@L-31X9LVDL-1304.local> <20201016080046.GA43862@L-31X9LVDL-1304.local> <17ca9bd8-bdc6-541c-b8f9-4076cb9a7322@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <17ca9bd8-bdc6-541c-b8f9-4076cb9a7322@redhat.com> 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 10:57:35AM +0200, David Hildenbrand wrote: >>> Do we adjust the count twice? >>> >> >> Ah, I got the reason why we need to adjust count for *unplugged* sub-blocks. > >Exactly. > >> >>>> - for (i = 0; i < nr_pages; i++) { >>>> - page = pfn_to_page(pfn + i); >>>> - if (WARN_ON(!page_ref_dec_and_test(page))) >> >> Another question is when we grab a refcount for the unpluged pages? The one >> you mentioned in virtio_mem_set_fake_offline(). > >Yeah, that was confusing on my side. I actually meant >virtio_mem_fake_offline() - patch #12. > >We have a reference on unplugged (fake offline) blocks via > >1. memmap initialization, if never online via generic_online_page() > >So if we keep pages fake offline when onlining memory, they > >a) Have a refcount of 1 >b) Have *not* increased the managed page count > >2. alloc_contig_range(), if fake offlined. After we fake-offlined pages >(e.g., patch #12), such pages > >a) Have a refcount of 1 >b) Have *not* increased the managed page count (because we manually >decreased it) > Yep, I got the reason now. > >-- >Thanks, > >David / dhildenb -- Wei Yang Help you, Help me