Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2589232pxj; Mon, 17 May 2021 05:21:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzlT1Mb3wY0z+A50Byu/OJLFS7rVF4ysgC58kENl/ehWxEfcRsPrIR9p6FYtXYJ1M56O894 X-Received: by 2002:a02:b90b:: with SMTP id v11mr7970604jan.1.1621254084188; Mon, 17 May 2021 05:21:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621254084; cv=none; d=google.com; s=arc-20160816; b=wDDJMxwnVUchUL93HHMrXyMR3foI1KQA8gcJpqSrox5VmmA6dyYKVwoUd+8gOsv5lS cnwXYPwgO0Njy0ygfGTrtelvLsf/Skhqmzm3G+na4OBpr2X0GilXxZwZ/mX0THUK5oxP YkQly+impS3s+5+pTUoEP5Y1GLiTRWZXDFohIBy/q9AaST9vBleabOouNTFP2vDGZmBg Ae+hVOuPjmY6MMb2xPiOP1VQy9Y6vxUruvFEkcgnbT3Z/Mu2nCkRQqzLqWrtHybtFNCW kTZ+mOWIYW9bdmiIW3MXTnMnqp3TagCPCP6CoRVJRK3dhdhboQvq69bfK8ggQwR/gG8D 65ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=MxKsLxpNNkRp4C7Lxq1+z01SsiEWshUM6iiicRd0ics=; b=LOKEAJIVT0gszbyyY4LdxqdI+Zb67Nd/Yo7IBTVcyqvk26d9xwxjAkQEvBQEOdeHeh KBFaM+0kf1ln7RBesHt39Gvo6MVs/EXfO+6kXybup2YoFgJDZNKpk+QvHHuNBEib1Yhz iZ3wu69nSCKUXSYUn1j9ogDTT5NNwH3iz5gJIyUkaZrQih4YW9aQqnKt4uwI/TbaGAHB 6HlvHymRyX97DKUw+uPsEwm1cw/5oLx6ienYbbjTUzImiW8en+njRV4qhadgRkXjszYb tHqHMPx196ecmSyf7saI0yGXOL3XB1vgS1SijkaqX8jLXzHp2mkt1LSfd1zvDccy/xsE clRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ogor81X1; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k25si9158170jap.38.2021.05.17.05.21.08; Mon, 17 May 2021 05:21: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=@kernel.org header.s=k20201202 header.b=ogor81X1; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233899AbhEQGpJ (ORCPT + 99 others); Mon, 17 May 2021 02:45:09 -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.