Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp1234830pxu; Fri, 16 Oct 2020 07:15:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywRkTmy0tT4eVQQEzhPLan/XEH7q7SIoIsU7tWCg+/WpfBFFupyMYKEP3ZJxZOlAkxmNDB X-Received: by 2002:a17:906:a886:: with SMTP id ha6mr4101684ejb.135.1602857724163; Fri, 16 Oct 2020 07:15:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602857724; cv=none; d=google.com; s=arc-20160816; b=EJu6tTc6/0T+2UVoE5NDMRt6XBOIIZ2UHf2O+QALCYZNx/kBUnN8oLPDGYGYEU230J C9y6oxNA+Bn2ftMLW+1C3WcvVv1JqkTlewA4BDIdW+BKoioTgRCgbudXrA0pz+HME6LE ke6W3HU+pMnCU286LRpIIwTV9lSTB1hPYv/7GYL9ehpLtwJ0ALv5As3lfR0BmhmoAkcj S1kGIADXFppqN7ApbV5MsfelxJyVoaIrQDYsIOwTNVti6Cy6yxYbi7wf8y0tQZ1/65Hj I9JD59JC4qa8bjKQDRce1Ubq9PIj6K7MFWKz++QEPgnq+qYMydoAC6c4/VkTlxim5m8E Q90g== 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=cG+u7UAAOPIg1MHG159pbyZWQJrtO6RNWf/EPwIxAOc=; b=ucdOjETunS59ApqjlvcEYJyS5kaLzW1iIexx7mDVTuwGIwVaq3BBQ7d+hjI+x+Hiiy WRefCqGBQjUNm6lQ8Ajf5Wy8n+eI+EvJ6/+UzxM5VkPnQUOYCtZST+Lo3dfGShcs9Mkn hueiWEYYBJOR9LlOwlNBFR0Ce0jStLCffmaquYklYEszzfQtJjwmBaX36rVlfkHu2+/p FfgVGPjAALkzKxzwEWLdQGe3kg1RWT9M/78NzlZBb1zE8RKpQ8AAg5/VGN5vr1+6p1cN FQbvwrF1DmcEeWH0xCvzMjGGCDh+QqcUDn4QYnRDlr5ANcyfDLBBpDmQOV+f3zBoM2jY vIoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Bpak9ggy; 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 p22si1751564ejd.52.2020.10.16.07.15.01; Fri, 16 Oct 2020 07:15:24 -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=Bpak9ggy; 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 S2395331AbgJPKdG (ORCPT + 99 others); Fri, 16 Oct 2020 06:33:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:32866 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2395327AbgJPKdF (ORCPT ); Fri, 16 Oct 2020 06:33:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602844384; 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=cG+u7UAAOPIg1MHG159pbyZWQJrtO6RNWf/EPwIxAOc=; b=Bpak9ggyS76E8GwZXv7/RltfxwoAIyRhCdmM6C0qj0Vk0rf1U+c9h5SW8GeORdFexdrQ9G 5cpNKrzzGO7ZgwbAlE4FZ5uxjUhTfj+d04uvh3AZ43nNzAxrt+MwgAeUVo77EZmUzAtD1U SIeFFKnEVNT39Ww4mFFTemXycsPbTCw= 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-317-QefDyz4ZPAG0u3sryVe0XQ-1; Fri, 16 Oct 2020 06:33:00 -0400 X-MC-Unique: QefDyz4ZPAG0u3sryVe0XQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4447564092; Fri, 16 Oct 2020 10:32:56 +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 685B45D9DD; Fri, 16 Oct 2020 10:32:51 +0000 (UTC) Subject: Re: [PATCH v1 05/29] virtio-mem: generalize check for added memory 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-6-david@redhat.com> <20201015082808.GE86495@L-31X9LVDL-1304.local> <994394f3-c16d-911c-c9fc-d2280f32e7b1@redhat.com> <20201016021651.GI86495@L-31X9LVDL-1304.local> <5caec772-295c-436a-2b19-ca261ea1ad0c@redhat.com> <20201016100211.GI44269@L-31X9LVDL-1304.local> From: David Hildenbrand Organization: Red Hat GmbH Message-ID: Date: Fri, 16 Oct 2020 12:32:50 +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: <20201016100211.GI44269@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.14 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >>> Ok, I seems to understand the logic now. >>> >>> But how we prevent ONLINE_PARTIAL memory block get offlined? There are three >>> calls in virtio_mem_set_fake_offline(), while all of them adjust page's flag. >>> How they hold reference to struct page? >> >> Sorry, I should have given you the right pointer. (similar to my other >> reply) >> >> We hold a reference either via >> >> 1. alloc_contig_range() > > I am not familiar with this one, need to spend some time to look into. Each individual page will have a pagecount of 1. > >> 2. memmap init code, when not calling generic_online_page(). > > I may miss some code here. Before online pages, memmaps are allocated in > section_activate(). They are supposed to be zero-ed. (I don't get the exact > code line.) I am not sure when we grab a refcount here. Best to refer to __init_single_page() -> init_page_count(). Each page that wasn't onlined via generic_online_page() has a refcount of 1 and looks like allocated. -- Thanks, David / dhildenb