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=-6.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS 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 C4462ECE58D for ; Sun, 6 Oct 2019 08:57:35 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 93FA92133F for ; Sun, 6 Oct 2019 08:57:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 93FA92133F 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 452816B000D; Sun, 6 Oct 2019 04:57:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 404216B000E; Sun, 6 Oct 2019 04:57:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2F4796B0010; Sun, 6 Oct 2019 04:57:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0061.hostedemail.com [216.40.44.61]) by kanga.kvack.org (Postfix) with ESMTP id 0BEB56B000D for ; Sun, 6 Oct 2019 04:57:35 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id 9FCDB3CEE for ; Sun, 6 Oct 2019 08:57:34 +0000 (UTC) X-FDA: 76012756428.07.pet08_24f707888285a X-HE-Tag: pet08_24f707888285a X-Filterd-Recvd-Size: 3467 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by imf20.hostedemail.com (Postfix) with ESMTP for ; Sun, 6 Oct 2019 08:57:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E1E0F806CD; Sun, 6 Oct 2019 08:57:32 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-58.ams2.redhat.com [10.36.116.58]) by smtp.corp.redhat.com (Postfix) with ESMTP id C1AC65B681; Sun, 6 Oct 2019 08:57:27 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, x86@kernel.org, David Hildenbrand , Andrew Morton , Oscar Salvador , Michal Hocko , Pavel Tatashin , Dan Williams Subject: [PATCH v6 06/10] mm/memory_hotplug: Poison memmap in remove_pfn_range_from_zone() Date: Sun, 6 Oct 2019 10:56:42 +0200 Message-Id: <20191006085646.5768-7-david@redhat.com> In-Reply-To: <20191006085646.5768-1-david@redhat.com> References: <20191006085646.5768-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Sun, 06 Oct 2019 08:57:33 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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: Let's poison the pages similar to when adding new memory in sparse_add_section(). Also call remove_pfn_range_from_zone() from memunmap_pages(), so we can poison the memmap from there as well. While at it, calculate the pfn in memunmap_pages() only once. Cc: Andrew Morton Cc: David Hildenbrand Cc: Oscar Salvador Cc: Michal Hocko Cc: Pavel Tatashin Cc: Dan Williams Signed-off-by: David Hildenbrand --- mm/memory_hotplug.c | 3 +++ mm/memremap.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 5b003ffa5dc9..bf5173e7913d 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -464,6 +464,9 @@ void __ref remove_pfn_range_from_zone(struct zone *zo= ne, struct pglist_data *pgdat =3D zone->zone_pgdat; unsigned long flags; =20 + /* Poison struct pages because they are now uninitialized again. */ + page_init_poison(pfn_to_page(start_pfn), sizeof(struct page) * nr_pages= ); + #ifdef CONFIG_ZONE_DEVICE /* * Zone shrinking code cannot properly deal with ZONE_DEVICE. So diff --git a/mm/memremap.c b/mm/memremap.c index 70263e6f093e..7fed8bd32a18 100644 --- a/mm/memremap.c +++ b/mm/memremap.c @@ -139,6 +139,8 @@ void memunmap_pages(struct dev_pagemap *pgmap) nid =3D page_to_nid(first_page); =20 mem_hotplug_begin(); + remove_pfn_range_from_zone(page_zone(first_page), PHYS_PFN(res->start), + PHYS_PFN(resource_size(res))); if (pgmap->type =3D=3D MEMORY_DEVICE_PRIVATE) { __remove_pages(PHYS_PFN(res->start), PHYS_PFN(resource_size(res)), NULL); --=20 2.21.0