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=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 ACB0CC433ED for ; Mon, 17 May 2021 06:43:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 91BCF61241 for ; Mon, 17 May 2021 06:43:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234076AbhEQGpK (ORCPT ); Mon, 17 May 2021 02:45:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:43706 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229527AbhEQGpH (ORCPT ); Mon, 17 May 2021 02:45:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 68C6361222; Mon, 17 May 2021 06:43:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621233831; bh=iVkxnDqQwpjrvJxXr6u24PcRby2BSTwHKSdPjJSUJ5Q=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ogor81X1A8Eh/ncAo15e7z4ugTGkNL3ChO3x+Hv3aKTzEtnifDg0uwpUSy+Sr0Jfl 6/5Dhjut2z14RKcXwWaOFZj2Ja1TQDEyZZ3m0XnRmN9/nY1TB6Yl+VWzKTE+frPaiY kY6bn2KIk6JH6pXRKRlsrFEBCPh3qraFilRzNOvQS+yaz0+8obR9z9o5U1D64lAFty lbBG1S5mhNUEuuNF9q/+L2c0Vk4p2CvdvFyF+AZ3Ad/8VIAXUbGWS2uGu4ptdO0JjE nH4OD3XqTlfDE8mb3UyTd/1R5PM1or23JHARwN56MqeKT2wS6GghvRCaC/wlmgNycn TnOAkP4yLxqfQ== Date: Mon, 17 May 2021 09:43:40 +0300 From: Mike Rapoport To: David Hildenbrand 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 Subject: Re: [PATCH v2 5/6] virtio-mem: use page_offline_(start|end) when setting PageOffline() Message-ID: References: <20210514172247.176750-1-david@redhat.com> <20210514172247.176750-6-david@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210514172247.176750-6-david@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 14, 2021 at 07:22:46PM +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. > > Existing balloon implementations usually allow reading inflated memory; > doing so might result in unnecessary overhead in the hypervisor, which > is currently the case with virtio-mem. > > For future virtio-mem use cases, it will be different when using shmem, > huge pages, !anonymous private mappings, ... as backing storage for a VM. > virtio-mem unplugged memory must no longer be accessed and access might > result in undefined behavior. There will be a virtio spec extension to > document this change, including a new feature flag indicating the > changed behavior. We really don't want to race against PFN walkers > reading random page content. > > Acked-by: Michael S. Tsirkin Acked-by: Mike Rapoport > Signed-off-by: David Hildenbrand > --- > drivers/virtio/virtio_mem.c | 2 ++ > 1 file changed, 2 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(); > } > > /* > -- > 2.31.1 > > -- Sincerely yours, Mike.