From patchwork Wed Jun 30 07:12:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 12351365 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=-16.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 093F3C11F65 for ; Wed, 30 Jun 2021 07:12:32 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B3D7761C8D for ; Wed, 30 Jun 2021 07:12:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B3D7761C8D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2E6978D018A; Wed, 30 Jun 2021 03:12:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 296478D017A; Wed, 30 Jun 2021 03:12:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 15E578D018A; Wed, 30 Jun 2021 03:12:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0088.hostedemail.com [216.40.44.88]) by kanga.kvack.org (Postfix) with ESMTP id E841F8D017A for ; Wed, 30 Jun 2021 03:12:30 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id C1A471808894D for ; Wed, 30 Jun 2021 07:12:30 +0000 (UTC) X-FDA: 78309522060.16.2197715 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf09.hostedemail.com (Postfix) with ESMTP id 7CD3E3000349 for ; Wed, 30 Jun 2021 07:12:30 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 6071461CC0; Wed, 30 Jun 2021 07:12:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625037149; bh=4lZi2ByWBD8jlDCnRUevXMAgObek5/VFvTH3/bPm2EU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZBvVmkTL7uSEHD2WwVlJBNvtGcC3Nz2xDzvqmK6ZcNj5hRA6FngfMVPlL0aibIm8u uEPDLDjmIIdw9FQn+/aU0YvjiLRUNocqpEEDIuwSwldZsMnTaU8lVtEUR5JvU0zEcG nObX//WWjwB6evvr3tDnXVSsyH0pe5ZY2IO8HR9NCxuaHy1RYl2xrk9PaQGSfCdVxE +qmmiZf0i7VDXIlUsNYq67zVblQV30eInCyDmURwF+PeAlq2IHi8y6PGm9Co7K/MtZ +NREM9+ObdR7OyR+ZAPwk+7ltrC5w2qxCIRvSEpsFkG9NZ3y34h8MPqmFlUu7T+89T IWQQ7Mh5z9itw== From: Mike Rapoport To: linux-arm-kernel@lists.infradead.org Cc: Andrew Morton , Kefeng Wang , Mike Rapoport , Mike Rapoport , Russell King , Tony Lindgren , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v3 4/4] arm: extend pfn_valid to take into account freed memory map alignment Date: Wed, 30 Jun 2021 10:12:11 +0300 Message-Id: <20210630071211.21011-5-rppt@kernel.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210630071211.21011-1-rppt@kernel.org> References: <20210630071211.21011-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 7CD3E3000349 X-Stat-Signature: cfhn1p7f864r9cshtbjk11r7q7fs371c Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ZBvVmkTL; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf09.hostedemail.com: domain of rppt@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=rppt@kernel.org X-HE-Tag: 1625037150-239105 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: From: Mike Rapoport When unused memory map is freed the preserved part of the memory map is extended to match pageblock boundaries because lots of core mm functionality relies on homogeneity of the memory map within pageblock boundaries. Since pfn_valid() is used to check whether there is a valid memory map entry for a PFN, make it return true also for PFNs that have memory map entries even if there is no actual memory populated there. Signed-off-by: Mike Rapoport Tested-by: Kefeng Wang Reported-by: Guenter Roeck Signed-off-by: Mike Rapoport Tested-by: Guenter Roeck --- arch/arm/mm/init.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 9d4744a632c6..6162a070a410 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -125,11 +125,22 @@ static void __init zone_sizes_init(unsigned long min, unsigned long max_low, int pfn_valid(unsigned long pfn) { phys_addr_t addr = __pfn_to_phys(pfn); + unsigned long pageblock_size = PAGE_SIZE * pageblock_nr_pages; if (__phys_to_pfn(addr) != pfn) return 0; - return memblock_is_map_memory(addr); + /* + * If address less than pageblock_size bytes away from a present + * memory chunk there still will be a memory map entry for it + * because we round freed memory map to the pageblock boundaries. + */ + if (memblock_overlaps_region(&memblock.memory, + ALIGN_DOWN(addr, pageblock_size), + pageblock_size)) + return 1; + + return 0; } EXPORT_SYMBOL(pfn_valid); #endif