Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp86872pxv; Wed, 30 Jun 2021 00:15:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwavlR+2LuKVs8sMsrP/RVnipkK7YvOMeXwnyq58n6ss8EGtp+nMCpflVqaSpVshbCItNNj X-Received: by 2002:a92:c0ca:: with SMTP id t10mr26987466ilf.241.1625037312743; Wed, 30 Jun 2021 00:15:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625037312; cv=none; d=google.com; s=arc-20160816; b=XiOUU0xG45Cr6Oy8sCX8Bmyx7nnp/0Ek3lvU4Hz/Qlt0DtrfZvdS1PfBlC+DVf3Z4u nuRgpeh6TaAdtkPaiC7QedRPs+M3xRZN5H9Xm4dRY9bW1A+xBFAU4IsI9WwyU1mvsYQR m75cEw1nX5zqohVT8oAthEToStt/wFBmmu7iF+N+kGAmsOyZJCPE9qABIsFTdQOpvRTH 8+MZggTxfNll43mBZxB1FV6/j1wKtO8BcfsSRTJmEvKfWsyVOArDAz2SDQLzP+XeloCC yb1tycUHFBfKyipKMAR3ELIjx8Yr17yKgIx92V0agFQJ8tmUhSy3bER9/Jagc5rGD7xM o8gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qHbpBcOslDA3nN5XoeQthqxA3hLZpLat9tOros7wxiU=; b=N5uZqiZRQU9JL/DYYfBOyHMIj8wqymD3csE8zBLym2464D1Jy4HhLwu7MLKJzPYG+n 8UowfvZ4NFwpxsfWSKEI9YKAtJuM2MLpH2acg1BQNM5ajWF+yruLTFGucJzPEOZHraZl K0jJ/3whTPhjkA/rYcJ2TOrv9k/o6w6zwoCLpapDqZujzYVGjiXlfj7JHU1VWpUJG9cO S+/DeKUGEPxWvPoKM99AYEMt5OVEHcwVSOnkn3CmeUshbeLADDdit0kpXaWhQQDUshjP DmIeMIYHxcrZmyZ3jXISDE9q7lsV/g7bfd2uNceGYZyrFXAn/5R+J/qdA5/hPHmkcLSP KDdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZBvVmkTL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w4si27856683jad.121.2021.06.30.00.15.00; Wed, 30 Jun 2021 00:15:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZBvVmkTL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232874AbhF3HPF (ORCPT + 99 others); Wed, 30 Jun 2021 03:15:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:52372 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232870AbhF3HO6 (ORCPT ); Wed, 30 Jun 2021 03:14:58 -0400 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 -- 2.28.0