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=-5.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 04BE0C433DF for ; Fri, 16 Oct 2020 08:57:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 422AA206D5 for ; Fri, 16 Oct 2020 08:57:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Lm53REuO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 422AA206D5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id ADFF6900003; Fri, 16 Oct 2020 04:57:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A689D900002; Fri, 16 Oct 2020 04:57:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 95889900003; Fri, 16 Oct 2020 04:57:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0006.hostedemail.com [216.40.44.6]) by kanga.kvack.org (Postfix) with ESMTP id 7A3C5900002 for ; Fri, 16 Oct 2020 04:57:49 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 31F70249C for ; Fri, 16 Oct 2020 08:57:49 +0000 (UTC) X-FDA: 77377185858.12.test08_1f0c6fd2721b Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin12.hostedemail.com (Postfix) with ESMTP id 1443918019A16 for ; Fri, 16 Oct 2020 08:57:49 +0000 (UTC) X-HE-Tag: test08_1f0c6fd2721b X-Filterd-Recvd-Size: 3664 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by imf38.hostedemail.com (Postfix) with ESMTP for ; Fri, 16 Oct 2020 08:57:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602838668; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yajcjuZ6uO56PGYXi5xPi6C1F2lWsOwbXSJhWt9V0A8=; b=Lm53REuOL2//QFRx499W0S/ra0sVAk1hdtEWmdb4cSOSa8kM619ARasrGhfbewyLmVbyqg J0BZ8s6eYC3brN8gnkZfk6Qr22tqdvdFy6En/VGSN5sXNVaTP8fTDD25v31/DJHeGmFSSv 2Z2dUUNt1qpIj0oiErAbayT03S6kfX4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-490-FPbhpK8fPrK86akRRhCSSQ-1; Fri, 16 Oct 2020 04:57:42 -0400 X-MC-Unique: FPbhpK8fPrK86akRRhCSSQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 13CCA835B73; Fri, 16 Oct 2020 08:57:41 +0000 (UTC) Received: from [10.36.113.23] (ovpn-113-23.ams2.redhat.com [10.36.113.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7B32276649; Fri, 16 Oct 2020 08:57:36 +0000 (UTC) Subject: Re: [PATCH v1 13/29] virtio-mem: factor out handling of fake-offline pages in memory notifier To: Wei Yang Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, virtualization@lists.linux-foundation.org, Andrew Morton , "Michael S . Tsirkin" , Jason Wang , Pankaj Gupta 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> From: David Hildenbrand Organization: Red Hat GmbH Message-ID: <17ca9bd8-bdc6-541c-b8f9-4076cb9a7322@redhat.com> Date: Fri, 16 Oct 2020 10:57:35 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.3.1 MIME-Version: 1.0 In-Reply-To: <20201016080046.GA43862@L-31X9LVDL-1304.local> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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: >> 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) -- Thanks, David / dhildenb