Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp2518911pxu; Sun, 18 Oct 2020 05:39:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVLhQQiXRIwqLfQoN5HRY+MMOSPFdePgTyNNd8lY2mmwycLvF6qi9eKWMT0buGu9T7aBzX X-Received: by 2002:a17:906:5841:: with SMTP id h1mr1603699ejs.342.1603024770753; Sun, 18 Oct 2020 05:39:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603024770; cv=none; d=google.com; s=arc-20160816; b=YzudSV5/X8TmstlW8y+oK+T/eQTC9S9zlLb1xcV8C61IyMwfLAwWmVYJ8cLRzryUxn 2vSDVCPyJLiHxQX6H4m19xbDCtS6C+t8aK5GHoZQpk/3WkT55Swm/XjTEHt6363Kz6to JtL8d6Y8Wtm+Qrqcr7/OmRYXSrctrhqQdJA3B1NAvqoalG9CnRuusWz/gLr7m8scbnys q4oR9O64dFZ5heWzgFRoj8/Wek5yVU4cO7AdXnreFwWBx4AQoVl5bUGKhqnLjirogpgJ +sl/GKLIwZRUxAe0p75hBQSBtPCHvVCAvh8ShQ3cLbbC7GCNTvtIAjK0wQQbFkjXvZlM PwIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date; bh=h9w5SSBXmkqahhXt18UJ/X5Al0apIkfRCQOS3ww+RqI=; b=o2ScvUADcsM1fk0DKmGkQj7FsDzSVFloGcZ7PMGIMKjwUSw9Ou0FxNJGEPWEMgoHgK K+tD2TaKjhawCvxravFE9fi5QM3om6Q/w0rAmEsrD6CF4WpdZVz7rUjRS4OuXRjh/U/F FK8fm0Se9IPSLvrYF9ty0/Rxcwd/cplN3KrQCbwo4Nnwdt4UeoJJqQ1pSpbEN93APlLh tNzleb1flJsoMj8ajWVbgoohzu7o13HBb4uh28QtIGAlI6DgqUPncVUp2/LT9CBIiQzY yds+6Tdxyp8u/FallEQ+4vBHMAJmh5DIR/DO3UE12YYms8eKhSuvBhOZeqJdjyA4NyiD R3xw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a23si5630740ejg.50.2020.10.18.05.39.07; Sun, 18 Oct 2020 05:39:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726364AbgJRMhh (ORCPT + 99 others); Sun, 18 Oct 2020 08:37:37 -0400 Received: from out30-43.freemail.mail.aliyun.com ([115.124.30.43]:48886 "EHLO out30-43.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725776AbgJRMhh (ORCPT ); Sun, 18 Oct 2020 08:37:37 -0400 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> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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