From patchwork Tue Sep 17 15:31:29 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: 11148999 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 63807112B for ; Tue, 17 Sep 2019 15:31:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2FB09206C2 for ; Tue, 17 Sep 2019 15:31:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2FB09206C2 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 61D4E6B0006; Tue, 17 Sep 2019 11:31:46 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5CAB36B0008; Tue, 17 Sep 2019 11:31:46 -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 4BA206B000A; Tue, 17 Sep 2019 11:31:46 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0102.hostedemail.com [216.40.44.102]) by kanga.kvack.org (Postfix) with ESMTP id 2F6C96B0006 for ; Tue, 17 Sep 2019 11:31:46 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id BF850181AC9AE for ; Tue, 17 Sep 2019 15:31:45 +0000 (UTC) X-FDA: 75944802570.28.soap50_2c6962b762d53 X-Spam-Summary: 2,0,0,d1594f66c390b999,d41d8cd98f00b204,aneesh.kumar@linux.ibm.com,:dan.j.williams@intel.com:akpm@linux-foundation.org: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:1431:1437:1515:1534:1541:1711:1730:1747:1777:1792:2393:2559:2562:2890:2895:3138:3139:3140:3141:3142:3352:3865:3867:3868:4042:4321:5007:6119:6120:6261:7901:10004:11026:11658:11914:12043:12296:12297:12555:12895:13069:13255:13311:13357:13894:14096:14181:14384:14394:14721:21080:21450:21451:21627:30001:30054:30070,0,RBL:148.163.158.5:@linux.ibm.com:.lbl8.mailshell.net-62.14.0.100 64.201.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:25,LUA_SUMMARY:none X-HE-Tag: soap50_2c6962b762d53 X-Filterd-Recvd-Size: 3982 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf20.hostedemail.com (Postfix) with ESMTP for ; Tue, 17 Sep 2019 15:31:45 +0000 (UTC) Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x8HFMYUB172692; Tue, 17 Sep 2019 11:31:43 -0400 Received: from ppma03wdc.us.ibm.com (ba.79.3fa9.ip4.static.sl-reverse.com [169.63.121.186]) by mx0a-001b2d01.pphosted.com with ESMTP id 2v30fsccvc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 17 Sep 2019 11:31:41 -0400 Received: from pps.filterd (ppma03wdc.us.ibm.com [127.0.0.1]) by ppma03wdc.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id x8HFPhnc018654; Tue, 17 Sep 2019 15:31:37 GMT Received: from b01cxnp22035.gho.pok.ibm.com (b01cxnp22035.gho.pok.ibm.com [9.57.198.25]) by ppma03wdc.us.ibm.com with ESMTP id 2v0t3d9r6u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 17 Sep 2019 15:31:37 +0000 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x8HFVaL054460834 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 17 Sep 2019 15:31:36 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D8B93AE060; Tue, 17 Sep 2019 15:31:36 +0000 (GMT) Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2796CAE063; Tue, 17 Sep 2019 15:31:35 +0000 (GMT) Received: from skywalker.ibmuc.com (unknown [9.199.41.201]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP; Tue, 17 Sep 2019 15:31:34 +0000 (GMT) From: "Aneesh Kumar K.V" To: dan.j.williams@intel.com, akpm@linux-foundation.org Cc: linux-nvdimm@lists.01.org, linux-mm@kvack.org, "Aneesh Kumar K.V" Subject: [PATCH v6] mm/pgmap: Use correct alignment when looking at first pfn from a region Date: Tue, 17 Sep 2019 21:01:29 +0530 Message-Id: <20190917153129.12905-1-aneesh.kumar@linux.ibm.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-09-17_07:,, 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=900 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1909170149 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: vmem_altmap_offset() adjust the section aligned base_pfn offset. So we need to make sure we account for the same when computing base_pfn. ie, for altmap_valid case, our pfn_first should be: pfn_first = altmap->base_pfn + vmem_altmap_offset(altmap); Signed-off-by: Aneesh Kumar K.V Signed-off-by: Aneesh Kumar K.V Signed-off-by: Andrew Morton --- * changes from v5 * update commit subject and use linux-mm for merge mm/memremap.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mm/memremap.c b/mm/memremap.c index ed70c4e8e52a..233908d7df75 100644 --- a/mm/memremap.c +++ b/mm/memremap.c @@ -54,8 +54,16 @@ static void pgmap_array_delete(struct resource *res) static unsigned long pfn_first(struct dev_pagemap *pgmap) { - return PHYS_PFN(pgmap->res.start) + - vmem_altmap_offset(pgmap_altmap(pgmap)); + const struct resource *res = &pgmap->res; + struct vmem_altmap *altmap = pgmap_altmap(pgmap); + unsigned long pfn; + + if (altmap) { + pfn = altmap->base_pfn + vmem_altmap_offset(altmap); + } else + pfn = PHYS_PFN(res->start); + + return pfn; } static unsigned long pfn_end(struct dev_pagemap *pgmap)