Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp1353732pxy; Thu, 29 Apr 2021 05:29:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxiFQSkQCT72b5lxwViahkWz/qJUtW9u3E1jGpQuwecS39uesGH96NTrGvyeiZzL1J8h9O8 X-Received: by 2002:a62:1b88:0:b029:1fb:d3d0:343a with SMTP id b130-20020a621b880000b02901fbd3d0343amr33312044pfb.76.1619699364659; Thu, 29 Apr 2021 05:29:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619699364; cv=none; d=google.com; s=arc-20160816; b=tYUEtjvrtzRzdIX+sRWL1ahoR9mPh617cnkS74hU9MnNeXfMi2z1yL+HhrIXtG+qOQ Bqj259iAni44Md9ZpRtXtyn6qgxg9gAgNBS1bg6xNjoDF/NtWiq20ESc3eEGDy+yNFLO cGzFCd313Bw5ijZMqnc7MYbXeVL4uBBYV6DubFljXGnPSI+eSTlLdjYTC0qBmlrKrSAQ 7SLYmvQXXxyUNzPpAfD5ZNuJlBLEiGnrgxuU03YH3nHuWWh/1PpvyBPATAOJtUwTcjow 25n13RaU9tXyQSufogr3W3CIShqK1qhdxvgs/ttl9eWeYCXYUt2DARcFGLCTyFY8XUM2 DKZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ba5FM83Cpmj9gJNSK1p4e73c9iU8c7zv5ZhHHm+jp5A=; b=XKSMxS8DOC274TPEr9zk4efECv1FWpjJPxPs+awsHSXrvv6luunaadsLm5SdO/yLU+ ragmshi4hcWYzHTGP+zFWemks8S9yL1mFPviVPP7j/VXrlm794DfiaOZvqVxz12jYjSM viCiCDsuycrTUBgrWVV2MCdTljGYaM2SOHs1tVyh0OMWdxkWxot1BjNgJoZeSDyoaYh7 lD5as7uOel3cLLp1YLIeazDf74PU0mgGDyR5RC2fB1KG/35zT2qm5SfzEqXNghpofQWH Q70wFWNEDBsTO4SQJoJxqBeyMV7g4ZsNPO5mMHkjO9AdM0amO/SeT88z+kAmdfAvLVTj Yrxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cdzjZB9+; 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 s2si3261315pgp.290.2021.04.29.05.29.11; Thu, 29 Apr 2021 05:29: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=cdzjZB9+; 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 S237261AbhD2M1g (ORCPT + 99 others); Thu, 29 Apr 2021 08:27:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:56405 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237228AbhD2M1f (ORCPT ); Thu, 29 Apr 2021 08:27:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619699209; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ba5FM83Cpmj9gJNSK1p4e73c9iU8c7zv5ZhHHm+jp5A=; b=cdzjZB9+OS7X7ncEdezdyDbxdJ8y6myUQtRaXAK631ZQa4wAwlZuxYkobshgMKZrG7GH2v FEJ+afzzW+9DSvEw4XizITHNWL+wZUutAkmkVDrjHX8O9FgDrEd5Qdq2O4lybC2/n+sbpE M89b/dRKh8CI4bsuVNXXKUj8gGboB6M= 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-564-61zoBJZfO3q1P9IGYPwAlA-1; Thu, 29 Apr 2021 08:26:45 -0400 X-MC-Unique: 61zoBJZfO3q1P9IGYPwAlA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 679691926DA3; Thu, 29 Apr 2021 12:26:43 +0000 (UTC) Received: from t480s.redhat.com (ovpn-114-50.ams2.redhat.com [10.36.114.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6529C18796; Thu, 29 Apr 2021 12:26:35 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: David Hildenbrand , Andrew Morton , "Michael S. Tsirkin" , Jason Wang , Alexey Dobriyan , Mike Rapoport , "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: [PATCH v1 6/7] virtio-mem: use page_offline_(start|end) when setting PageOffline() Date: Thu, 29 Apr 2021 14:25:18 +0200 Message-Id: <20210429122519.15183-7-david@redhat.com> In-Reply-To: <20210429122519.15183-1-david@redhat.com> References: <20210429122519.15183-1-david@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(); } /* diff --git a/mm/util.c b/mm/util.c index 95395d4e4209..d0e357bd65e6 100644 --- a/mm/util.c +++ b/mm/util.c @@ -1046,8 +1046,10 @@ void page_offline_begin(void) { down_write(&page_offline_rwsem); } +EXPORT_SYMBOL(page_offline_begin); void page_offline_end(void) { up_write(&page_offline_rwsem); } +EXPORT_SYMBOL(page_offline_end); -- 2.30.2