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 DFF28C433DF for ; Fri, 16 Oct 2020 08:57:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7585E206D5 for ; Fri, 16 Oct 2020 08:57:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="QXUy5gij" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405246AbgJPI5r (ORCPT ); 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