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=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 C7BBBC4360C for ; Thu, 26 Sep 2019 13:35:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 79422222C0 for ; Thu, 26 Sep 2019 13:35:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 79422222C0 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 EB6ED8E000F; Thu, 26 Sep 2019 09:35:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E8E338E0001; Thu, 26 Sep 2019 09:35:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DA45E8E000F; Thu, 26 Sep 2019 09:35:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0026.hostedemail.com [216.40.44.26]) by kanga.kvack.org (Postfix) with ESMTP id A96288E0001 for ; Thu, 26 Sep 2019 09:35:01 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id 331B4824CA26 for ; Thu, 26 Sep 2019 13:35:01 +0000 (UTC) X-FDA: 75977167602.22.turn95_82faf7dc60f19 X-HE-Tag: turn95_82faf7dc60f19 X-Filterd-Recvd-Size: 4766 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by imf20.hostedemail.com (Postfix) with ESMTP for ; Thu, 26 Sep 2019 13:34:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C56A03082131; Thu, 26 Sep 2019 13:34:58 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B135AA210; Thu, 26 Sep 2019 13:34:58 +0000 (UTC) Received: from zmail21.collab.prod.int.phx2.redhat.com (zmail21.collab.prod.int.phx2.redhat.com [10.5.83.24]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 858D34EE50; Thu, 26 Sep 2019 13:34:58 +0000 (UTC) Date: Thu, 26 Sep 2019 09:34:58 -0400 (EDT) From: Pankaj Gupta To: "Aneesh Kumar K.V" Cc: dan j williams , akpm@linux-foundation.org, David Hildenbrand , linux-nvdimm@lists.01.org, linux-mm@kvack.org Message-ID: <327305557.3319542.1569504897998.JavaMail.zimbra@redhat.com> In-Reply-To: <20190926122552.17905-1-aneesh.kumar@linux.ibm.com> References: <20190830091428.18399-1-david@redhat.com> <20190926122552.17905-1-aneesh.kumar@linux.ibm.com> Subject: Re: [PATCH 1/2] mm/memunmap: Use the correct start and end pfn when removing pages from zone MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.117.36, 10.4.195.2] Thread-Topic: mm/memunmap: Use the correct start and end pfn when removing pages from zone Thread-Index: Ay8FhhcGaFIgIhiU5abdq26E4sJNGQ== X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 26 Sep 2019 13:34:59 +0000 (UTC) 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: > > With altmap, all the resource pfns are not initialized. While initializing > pfn, altmap reserve space is skipped. Hence when removing pfn from zone skip > pfns that were never initialized. > > Update memunmap_pages to calculate start and end pfn based on altmap > values. This fixes a kernel crash that is observed when destroying namespace. > > [ 74.745056] BUG: Unable to handle kernel data access at 0xc00c000001400000 > [ 74.745256] Faulting instruction address: 0xc0000000000b58b0 > cpu 0x2: Vector: 300 (Data Access) at [c00000026ea93580] > pc: c0000000000b58b0: memset+0x68/0x104 > lr: c0000000003eb008: page_init_poison+0x38/0x50 > ... > current = 0xc000000271c67d80 > paca = 0xc00000003fffd680 irqmask: 0x03 irq_happened: 0x01 > pid = 3665, comm = ndctl > [link register ] c0000000003eb008 page_init_poison+0x38/0x50 > [c00000026ea93830] c0000000004754d4 remove_pfn_range_from_zone+0x64/0x3e0 > [c00000026ea938a0] c0000000004b8a60 memunmap_pages+0x300/0x400 > [c00000026ea93930] c0000000009e32a0 devm_action_release+0x30/0x50 > ... > > Signed-off-by: Aneesh Kumar K.V > --- > mm/memremap.c | 15 ++++++++++----- > 1 file changed, 10 insertions(+), 5 deletions(-) > > diff --git a/mm/memremap.c b/mm/memremap.c > index 390bb3544589..76b98110031e 100644 > --- a/mm/memremap.c > +++ b/mm/memremap.c > @@ -113,7 +113,8 @@ static void dev_pagemap_cleanup(struct dev_pagemap > *pgmap) > void memunmap_pages(struct dev_pagemap *pgmap) > { > struct resource *res = &pgmap->res; > - unsigned long pfn = PHYS_PFN(res->start); > + unsigned long start_pfn, end_pfn; > + unsigned long pfn, nr_pages; > int nid; > > dev_pagemap_kill(pgmap); > @@ -121,14 +122,18 @@ void memunmap_pages(struct dev_pagemap *pgmap) > put_page(pfn_to_page(pfn)); > dev_pagemap_cleanup(pgmap); > > + start_pfn = pfn_first(pgmap); > + end_pfn = pfn_end(pgmap); > + nr_pages = end_pfn - start_pfn; > + > /* pages are dead and unused, undo the arch mapping */ > - nid = page_to_nid(pfn_to_page(pfn)); > + nid = page_to_nid(pfn_to_page(start_pfn)); > > mem_hotplug_begin(); > - remove_pfn_range_from_zone(page_zone(pfn_to_page(pfn)), pfn, > - PHYS_PFN(resource_size(res))); > + remove_pfn_range_from_zone(page_zone(pfn_to_page(start_pfn)), > + start_pfn, nr_pages); > if (pgmap->type == MEMORY_DEVICE_PRIVATE) { > - __remove_pages(pfn, PHYS_PFN(resource_size(res)), NULL); > + __remove_pages(start_pfn, nr_pages, NULL); > } else { > arch_remove_memory(nid, res->start, resource_size(res), > pgmap_altmap(pgmap)); > -- > 2.21.0 Reviewed-by: Pankaj Gupta > > >