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=-3.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no 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 0ADE9C432C0 for ; Sat, 30 Nov 2019 23:13:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BFD9420725 for ; Sat, 30 Nov 2019 23:13:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="aOymBJ9A" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BFD9420725 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6BF5A6B0006; Sat, 30 Nov 2019 18:13:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 66EE76B0007; Sat, 30 Nov 2019 18:13:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 584B46B0008; Sat, 30 Nov 2019 18:13:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0142.hostedemail.com [216.40.44.142]) by kanga.kvack.org (Postfix) with ESMTP id 410286B0006 for ; Sat, 30 Nov 2019 18:13:19 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id E78E83AB6 for ; Sat, 30 Nov 2019 23:13:18 +0000 (UTC) X-FDA: 76214496876.20.book29_571db3a112212 X-HE-Tag: book29_571db3a112212 X-Filterd-Recvd-Size: 4155 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf19.hostedemail.com (Postfix) with ESMTP for ; Sat, 30 Nov 2019 23:13:18 +0000 (UTC) Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B334F20725; Sat, 30 Nov 2019 23:13:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575155597; bh=KjTRgnnKv5nRR0iakt1HRuFDQSVpEM0jTzxlSBvTBzI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=aOymBJ9AgRdskRjuRDNogI8A5WERX5ISlUGpJ0YX3tGkEGLb4lLM0tzyxrNkaUyyn 1yoKizlJnBu35IG52Q95jfxG1uEg68cySzFVH2nHBTG2h5S2nduj2ROZRCGCePkW2v bYpxF7H978SAcf2TJrm1Tzx2ftDTpzM1ZxWblJPc= Date: Sat, 30 Nov 2019 15:13:17 -0800 From: Andrew Morton To: "Aneesh Kumar K.V" Cc: dan.j.williams@intel.com, linux-nvdimm@lists.01.org, linux-mm@kvack.org Subject: Re: [PATCH v6] mm/pgmap: Use correct alignment when looking at first pfn from a region Message-Id: <20191130151317.26c69ef711dba28ff642cca3@linux-foundation.org> In-Reply-To: <8736glowyh.fsf@linux.ibm.com> References: <20190917153129.12905-1-aneesh.kumar@linux.ibm.com> <20190919122501.df660f0d23806a3f46d11b61@linux-foundation.org> <8736glowyh.fsf@linux.ibm.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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: On Wed, 25 Sep 2019 09:21:02 +0530 "Aneesh Kumar K.V" wrote: > Andrew Morton writes: > > > On Tue, 17 Sep 2019 21:01:29 +0530 "Aneesh Kumar K.V" wrote: > > > >> 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); > > > > What are the user-visible runtime effects of this change? > > This was found by code inspection. If the pmem region is not correctly > section aligned we can skip pfns while iterating device pfn using > for_each_device_pfn(pfn, pgmap) > > > I still would want Dan to ack the change though. > Dan? From: "Aneesh Kumar K.V" Subject: mm/pgmap: use correct alignment when looking at first pfn from a region vmem_altmap_offset() adjusts 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); This was found by code inspection. If the pmem region is not correctly section aligned we can skip pfns while iterating device pfn using for_each_device_pfn(pfn, pgmap) [akpm@linux-foundation.org: coding style fixes] Link: http://lkml.kernel.org/r/20190917153129.12905-1-aneesh.kumar@linux.ibm.com Signed-off-by: Aneesh Kumar K.V Cc: Ralph Campbell Cc: Dan Williams Signed-off-by: Andrew Morton --- mm/memremap.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) --- a/mm/memremap.c~mm-pgmap-use-correct-alignment-when-looking-at-first-pfn-from-a-region +++ a/mm/memremap.c @@ -55,8 +55,16 @@ static void pgmap_array_delete(struct re 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) _