From patchwork Thu Sep 26 12:25:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aneesh Kumar K.V" X-Patchwork-Id: 11162713 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5247E112B for ; Thu, 26 Sep 2019 12:26:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2670C20673 for ; Thu, 26 Sep 2019 12:26:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2670C20673 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2418C8E0005; Thu, 26 Sep 2019 08:26:13 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1F3758E0001; Thu, 26 Sep 2019 08:26:13 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0BA368E0005; Thu, 26 Sep 2019 08:26:13 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0032.hostedemail.com [216.40.44.32]) by kanga.kvack.org (Postfix) with ESMTP id DEA328E0001 for ; Thu, 26 Sep 2019 08:26:12 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id 8D1D875B5 for ; Thu, 26 Sep 2019 12:26:12 +0000 (UTC) X-FDA: 75976994184.27.slope92_705b8a93cb03c X-Spam-Summary: 2,0,0,b2d3bfe44925825d,d41d8cd98f00b204,aneesh.kumar@linux.ibm.com,:dan.j.williams@intel.com:akpm@linux-foundation.org:david@redhat.com:linux-nvdimm@lists.01.org::aneesh.kumar@linux.ibm.com,RULES_HIT:41:355:379:541:800:960:968:973:988:989:1260:1261:1311:1314:1345:1359:1431:1437:1515:1535:1542:1711:1730:1747:1777:1792:2393:2559:2562:2895:2901:2902:3138:3139:3140:3141:3142:3353:3622:3865:3867:3868:3871:3874:4321:5007:6117:6119:6120:6261:7875:7901:7903:8634:9165:10004:11026:11473:11658:11914:12043:12296:12297:12438:12555:12679:12895:12986:13255:13894:13972:14096:14181:14394:14721:21080:21451:21524:21627:21939,0,RBL:148.163.158.5:@linux.ibm.com:.lbl8.mailshell.net-62.2.0.100 64.100.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:26,LUA_SUMMARY:none X-HE-Tag: slope92_705b8a93cb03c X-Filterd-Recvd-Size: 5949 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf41.hostedemail.com (Postfix) with ESMTP for ; Thu, 26 Sep 2019 12:26:11 +0000 (UTC) Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x8QCN70R044775; Thu, 26 Sep 2019 08:26:04 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 2v8w54rnjw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Sep 2019 08:26:03 -0400 Received: from m0098413.ppops.net (m0098413.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.27/8.16.0.27) with SMTP id x8QCOgDd051112; Thu, 26 Sep 2019 08:26:03 -0400 Received: from ppma02wdc.us.ibm.com (aa.5b.37a9.ip4.static.sl-reverse.com [169.55.91.170]) by mx0b-001b2d01.pphosted.com with ESMTP id 2v8w54rnjh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Sep 2019 08:26:03 -0400 Received: from pps.filterd (ppma02wdc.us.ibm.com [127.0.0.1]) by ppma02wdc.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id x8QCQ0k6003088; Thu, 26 Sep 2019 12:26:02 GMT Received: from b03cxnp08025.gho.boulder.ibm.com (b03cxnp08025.gho.boulder.ibm.com [9.17.130.17]) by ppma02wdc.us.ibm.com with ESMTP id 2v5bg7exj3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Sep 2019 12:26:02 +0000 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x8QCQ1pe56754614 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 26 Sep 2019 12:26:01 GMT Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9C2BF6E052; Thu, 26 Sep 2019 12:26:01 +0000 (GMT) Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 436FE6E04C; Thu, 26 Sep 2019 12:25:59 +0000 (GMT) Received: from skywalker.ibmuc.com (unknown [9.199.34.158]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 26 Sep 2019 12:25:58 +0000 (GMT) From: "Aneesh Kumar K.V" To: dan.j.williams@intel.com, akpm@linux-foundation.org, David Hildenbrand Cc: linux-nvdimm@lists.01.org, linux-mm@kvack.org, "Aneesh Kumar K.V" Subject: [PATCH 1/2] mm/memunmap: Use the correct start and end pfn when removing pages from zone Date: Thu, 26 Sep 2019 17:55:51 +0530 Message-Id: <20190926122552.17905-1-aneesh.kumar@linux.ibm.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190830091428.18399-1-david@redhat.com> References: <20190830091428.18399-1-david@redhat.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-09-26_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1909260118 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 Reviewed-by: Pankaj Gupta --- 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)); From patchwork Thu Sep 26 12:25:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aneesh Kumar K.V" X-Patchwork-Id: 11162709 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9BE0A17D4 for ; Thu, 26 Sep 2019 12:26:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 722BF20673 for ; Thu, 26 Sep 2019 12:26:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 722BF20673 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B1A9E6B000C; Thu, 26 Sep 2019 08:26:10 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id ACC126B000D; Thu, 26 Sep 2019 08:26:10 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9BAC68E0001; Thu, 26 Sep 2019 08:26:10 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0053.hostedemail.com [216.40.44.53]) by kanga.kvack.org (Postfix) with ESMTP id 7D7B66B000C for ; Thu, 26 Sep 2019 08:26:10 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id 1F12B180AD802 for ; Thu, 26 Sep 2019 12:26:10 +0000 (UTC) X-FDA: 75976994100.15.town38_6ffa1c4626146 X-Spam-Summary: 2,0,0,087027373455f8d7,d41d8cd98f00b204,aneesh.kumar@linux.ibm.com,:dan.j.williams@intel.com:akpm@linux-foundation.org:david@redhat.com:linux-nvdimm@lists.01.org::aneesh.kumar@linux.ibm.com,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1261:1311:1314:1345:1359:1431:1437:1515:1535:1541:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3352:3369:3865:3866:3867:3870:3871:5007:6119:6261:7875:7903:8603:8634:10004:11026:11473:11658:11914:12043:12296:12297:12438:12555:12895:13069:13161:13229:13311:13357:13894:14181:14384:14394:14721:21080:21451:21627:30029:30034:30054:30056:30070,0,RBL:148.163.156.1:@linux.ibm.com:.lbl8.mailshell.net-62.2.0.100 64.100.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:28,LUA_SUMMARY:none X-HE-Tag: town38_6ffa1c4626146 X-Filterd-Recvd-Size: 5025 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf12.hostedemail.com (Postfix) with ESMTP for ; Thu, 26 Sep 2019 12:26:09 +0000 (UTC) Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x8QCMP9k122730; Thu, 26 Sep 2019 08:26:07 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 2v8w0995ky-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Sep 2019 08:26:07 -0400 Received: from m0098393.ppops.net (m0098393.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.27/8.16.0.27) with SMTP id x8QCMgpx124165; Thu, 26 Sep 2019 08:26:06 -0400 Received: from ppma02wdc.us.ibm.com (aa.5b.37a9.ip4.static.sl-reverse.com [169.55.91.170]) by mx0a-001b2d01.pphosted.com with ESMTP id 2v8w0995jt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Sep 2019 08:26:06 -0400 Received: from pps.filterd (ppma02wdc.us.ibm.com [127.0.0.1]) by ppma02wdc.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id x8QCQ0k9003088; Thu, 26 Sep 2019 12:26:05 GMT Received: from b03cxnp08027.gho.boulder.ibm.com (b03cxnp08027.gho.boulder.ibm.com [9.17.130.19]) by ppma02wdc.us.ibm.com with ESMTP id 2v5bg7exj9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Sep 2019 12:26:05 +0000 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x8QCQ4pF52232598 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 26 Sep 2019 12:26:04 GMT Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9AB126E052; Thu, 26 Sep 2019 12:26:04 +0000 (GMT) Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 41C706E050; Thu, 26 Sep 2019 12:26:02 +0000 (GMT) Received: from skywalker.ibmuc.com (unknown [9.199.34.158]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 26 Sep 2019 12:26:01 +0000 (GMT) From: "Aneesh Kumar K.V" To: dan.j.williams@intel.com, akpm@linux-foundation.org, David Hildenbrand Cc: linux-nvdimm@lists.01.org, linux-mm@kvack.org, "Aneesh Kumar K.V" Subject: [PATCH 2/2] mm/memmap_init: Update variable name in memmap_init_zone Date: Thu, 26 Sep 2019 17:55:52 +0530 Message-Id: <20190926122552.17905-2-aneesh.kumar@linux.ibm.com> X-Mailer: git-send-email 2.21.0 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> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-09-26_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1909260118 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: The third argument is actually number of pages. Changes the variable name from size to nr_pages to indicate this better. No functional change in this patch. Signed-off-by: Aneesh Kumar K.V Reviewed-by: David Hildenbrand Reviewed-by: Pankaj Gupta --- mm/page_alloc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 3334a769eb91..df9e09a5359f 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5914,10 +5914,10 @@ void __meminit memmap_init_zone(unsigned long size, int nid, unsigned long zone, #ifdef CONFIG_ZONE_DEVICE void __ref memmap_init_zone_device(struct zone *zone, unsigned long start_pfn, - unsigned long size, + unsigned long nr_pages, struct dev_pagemap *pgmap) { - unsigned long pfn, end_pfn = start_pfn + size; + unsigned long pfn, end_pfn = start_pfn + nr_pages; struct pglist_data *pgdat = zone->zone_pgdat; struct vmem_altmap *altmap = pgmap_altmap(pgmap); unsigned long zone_idx = zone_idx(zone); @@ -5934,7 +5934,7 @@ void __ref memmap_init_zone_device(struct zone *zone, */ if (altmap) { start_pfn = altmap->base_pfn + vmem_altmap_offset(altmap); - size = end_pfn - start_pfn; + nr_pages = end_pfn - start_pfn; } for (pfn = start_pfn; pfn < end_pfn; pfn++) { @@ -5981,7 +5981,7 @@ void __ref memmap_init_zone_device(struct zone *zone, } pr_info("%s initialised %lu pages in %ums\n", __func__, - size, jiffies_to_msecs(jiffies - start)); + nr_pages, jiffies_to_msecs(jiffies - start)); } #endif