Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp1039188pxu; Fri, 16 Oct 2020 02:09:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySjjTmCpIUMWXSWm0t9jr2elwLaYCvvFZHTeyDPQ1eyQo7w6ZSr7lcMA5EcsqgUBxGZf2m X-Received: by 2002:aa7:c2c4:: with SMTP id m4mr2873214edp.172.1602839399507; Fri, 16 Oct 2020 02:09:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602839399; cv=none; d=google.com; s=arc-20160816; b=HCK3/WAOQ3JgwiXBR+DBu2lgqJkgMFwuX2R5QnhHeofrrCgaKQo/kSY+Wyvtosnmwr 1npwYvGuRPIHQKSBnOZyMXlSpanz2WWJqeejhzmx98qYLyHomqLWKQOyzUoyQ89QU8BQ OZdxpWk4+xsdeTkNV3XiyFL9j1xD46UdAgvJNl6vCPaLUux1PkKzOd6charRm4+WbJfX C0AtVbP5XTKvQKJLloHUi8MLLBiuIwyHPQk6Nwa/OOpp2enRY8immeoqt0qOv4sjWlAe ykOoY4NDlSYjQEuY8mdrXJ1K+rjEUd09logL18x0iuLpjcWp62+PanodC8jqKMaUqBR+ 9adw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:cc:to:subject:dkim-signature; bh=yajcjuZ6uO56PGYXi5xPi6C1F2lWsOwbXSJhWt9V0A8=; b=IHxoEdI6lRRGFQ94dwWNVzplF5tkLdFZ3c7lG9Jys5dueWg1klK3melrGzJRD9a4IK vp4m076FgCYpiCk7jHyqXWGCE/yCd2qYLoglPF8JfMNo9+u8/GhejpIdpsc1NTPFEWSP Y41A90px/Rx6QXFKV9e9wD274Ws/yAdZYoRt4R2OCow7BJRf0KIouInCk3IrZThKInQ7 0MM/XmOC0bTlonMQsgyVvkQmpXnBSefXNUtyOeA+JXvFGlg4u5tZTGuUpobmJJzHXZLI IfUjvp1Dz5eIMb/aF9xCbxga57JOwat4MdWIWMP8B60aAnYpx34at6okSBC8IvhBIwX3 SYhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QXUy5gij; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g1si1413922ejf.525.2020.10.16.02.09.37; Fri, 16 Oct 2020 02:09:59 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QXUy5gij; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405242AbgJPI5r (ORCPT + 99 others); Fri, 16 Oct 2020 04:57:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:30083 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404372AbgJPI5q (ORCPT ); Fri, 16 Oct 2020 04:57:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602838665; 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=QXUy5gijWNFu/5BFZTfaFV4aNXoGe0IcuL2ZdnDJrM5QpAiH5yMsF/dJVNqc8FB7cawNRU 13EviqpajAGRbJpo8GSg5CvoNXppHf/yDUOMtg6nxBrx0+s4SDgA0LcBKHzkUm1K9uBOCs qdcVquQmv+JWSfxTQPBcbXv3mCzxwcQ= 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >> 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