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=-17.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham 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 E283EC43461 for ; Mon, 3 May 2021 08:16:12 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4D65261186 for ; Mon, 3 May 2021 08:16:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4D65261186 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 B8F9D6B0036; Mon, 3 May 2021 04:16:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B19816B006E; Mon, 3 May 2021 04:16:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 96A676B0070; Mon, 3 May 2021 04:16:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0172.hostedemail.com [216.40.44.172]) by kanga.kvack.org (Postfix) with ESMTP id 75BBD6B0036 for ; Mon, 3 May 2021 04:16:11 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 3831B52AE for ; Mon, 3 May 2021 08:16:11 +0000 (UTC) X-FDA: 78099212142.03.BCB0309 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf12.hostedemail.com (Postfix) with ESMTP id 05C933F3 for ; Mon, 3 May 2021 08:15:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620029770; 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=3uB/EYYvRDIWzIKd9NUtpds132sJrn5ZaXZy/6UA0sM=; b=GNbUAaF2WD3BEvnFoLvpEAjiYa1z/T7fUWnxqp+QIiq3lixTYH/u0Rxu0WqImN87/4LdzK iKPSuc5TJZFtJX2iPoKshc22XLVAJcOrAC347MkSXh2F5mirNOQzkGHQ1INNIxvd0xNyJo 4hvKB3l1peOUONJ0U7iUrbYPEiXp3Uw= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-291-uGihG0WWMQiW2NY8Kny6KA-1; Mon, 03 May 2021 04:16:06 -0400 X-MC-Unique: uGihG0WWMQiW2NY8Kny6KA-1 Received: by mail-ed1-f69.google.com with SMTP id z12-20020aa7d40c0000b0290388179cc8bfso4048694edq.21 for ; Mon, 03 May 2021 01:16:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=3uB/EYYvRDIWzIKd9NUtpds132sJrn5ZaXZy/6UA0sM=; b=YfbrGYoQ50D+GjfljoER53AWrrb7j5dTODCThrngFbTfRK7pMq6xXrnMjodsBSYjdo Y7DjLQIV8H8sFW7tp6Wjk2xFYNkNxS4CK6fFnlToGtG5M++nAAemfj3+Want5es32aTh uLP8CjN2eO2UJHPeT8XUVqkdpY2dsiniVqRklCo+Ztc1fFwB26uSzofkWmbmJJeDywyG 9KaylN9fbN0uaKvfrnlLl8OGFwATMyaFMRZZmS/mugpIDywjRUOeFzSgT0jWi25OIQ8E h5iEUofku5HGb2EHpWowgBcLrf3ulVMVIs2MFv2K6MCBuJd99qRPEnvBDKE2aG3aRNFQ afMA== X-Gm-Message-State: AOAM532l99ORMbcgow/kgHH2SsHQWFDyljYFzaBGaZ30S9nzqU6zbtWW /bJlxxVsNdmL0qIzE8bTlGDSlbGQNgzbbKOKgZfCUCFTKo+fU83HyNB0jXXaDBGZxfCDXM6Q7yg DXRxmiWimfC9+MW9MlDwE2nldf9yRbqSTAITHU6NnPvucwHj/8etK10TarMg= X-Received: by 2002:a17:906:8147:: with SMTP id z7mr11677898ejw.496.1620029764949; Mon, 03 May 2021 01:16:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5t6QJnu76x0vRJx5wjyCiN1MvkzdCqG/1DMVBAPOiuRhGpdYa0HWbVhYZGZKhNk34vPvb6A== X-Received: by 2002:a17:906:8147:: with SMTP id z7mr11677854ejw.496.1620029764611; Mon, 03 May 2021 01:16:04 -0700 (PDT) Received: from [192.168.3.132] (p5b0c649f.dip0.t-ipconnect.de. [91.12.100.159]) by smtp.gmail.com with ESMTPSA id lr15sm4554094ejb.107.2021.05.03.01.16.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 03 May 2021 01:16:04 -0700 (PDT) Subject: Re: [PATCH v1 6/7] virtio-mem: use page_offline_(start|end) when setting PageOffline() To: Mike Rapoport Cc: linux-kernel@vger.kernel.org, Andrew Morton , "Michael S. Tsirkin" , Jason Wang , Alexey Dobriyan , "Matthew Wilcox (Oracle)" , Oscar Salvador , Michal Hocko , Roman Gushchin , Alex Shi , Steven Price , Mike Kravetz , Aili Yao , Jiri Bohac , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Naoya Horiguchi , linux-hyperv@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org References: <20210429122519.15183-1-david@redhat.com> <20210429122519.15183-7-david@redhat.com> From: David Hildenbrand Organization: Red Hat Message-ID: <98f22a46-da8b-2891-fade-09937c0ccf69@redhat.com> Date: Mon, 3 May 2021 10:16:03 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=GNbUAaF2; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf12.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 216.205.24.124) smtp.mailfrom=david@redhat.com X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 05C933F3 X-Stat-Signature: 3zxhrnxzhan4j6ew7w8rrimeuuh9k9k6 Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf12; identity=mailfrom; envelope-from=""; helo=us-smtp-delivery-124.mimecast.com; client-ip=216.205.24.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620029757-945582 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: On 02.05.21 08:33, Mike Rapoport wrote: > On Thu, Apr 29, 2021 at 02:25:18PM +0200, David Hildenbrand wrote: >> Let's properly use page_offline_(start|end) to synchronize setting >> PageOffline(), so we won't have valid page access to unplugged memory >> regions from /proc/kcore. >> >> Signed-off-by: David Hildenbrand >> --- >> drivers/virtio/virtio_mem.c | 2 ++ >> mm/util.c | 2 ++ >> 2 files changed, 4 insertions(+) >> >> diff --git a/drivers/virtio/virtio_mem.c b/drivers/virtio/virtio_mem.c >> index 10ec60d81e84..dc2a2e2b2ff8 100644 >> --- a/drivers/virtio/virtio_mem.c >> +++ b/drivers/virtio/virtio_mem.c >> @@ -1065,6 +1065,7 @@ static int virtio_mem_memory_notifier_cb(struct notifier_block *nb, >> static void virtio_mem_set_fake_offline(unsigned long pfn, >> unsigned long nr_pages, bool onlined) >> { >> + page_offline_begin(); >> for (; nr_pages--; pfn++) { >> struct page *page = pfn_to_page(pfn); >> >> @@ -1075,6 +1076,7 @@ static void virtio_mem_set_fake_offline(unsigned long pfn, >> ClearPageReserved(page); >> } >> } >> + page_offline_end(); > > I'm not really familiar with ballooning and memory hotplug, but is it the > only place that needs page_offline_{begin,end} ? Existing balloon implementations that I am aware of (Hyper-V, XEN, virtio-balloon, vmware-balloon) usually allow reading inflated memory; doing so might result in unnecessary overhead in the hypervisor, so we really want to avoid it -- but it's strictly not forbidden and has been working forever. So we barely care about races: if there would be a rare race, we'd still be able to read that memory. For virtio-mem, it'll be different in the future when using shmem, huge pages, !anonymous private mappings, ... as backing storage for a VM; there will be a virtio spec extension to document that virtio-mem changes that indicate the new behavior won't allow reading unplugged memory and doing so will result in undefined behavior. -- Thanks, David / dhildenb