From patchwork Wed May 19 14:14:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 12267541 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=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 1D04EC43462 for ; Wed, 19 May 2021 14:16:39 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A209761184 for ; Wed, 19 May 2021 14:16:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A209761184 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=CPF2QRU5r/ED7+oUgvGknDWDO6TsWDNVEVxh82JSHcg=; b=GRaY9a5VPJT5yBl7VApBq3pOR 270lFEFI7kkGAmwglayE2uyl6nXp0J1USy8mMEJikgsdnhp5cbBxd92kFOPxzfXx//lG02ZoPOdFV dp5ndCTGUQvIRKjAZx8i15hOP5lQ14JNivdrXqoU+/5Szpmfu1+a74MOZxZkna1dF87ZOvo8d1Jf4 BSw6FsShi3JL2y4kghKYGfyOzPekUv2qRsxjsQMyKjJV2N3o54YpTMaMdJ8lgGDNuC0hDQDjVawuB JhghnBYX6FVlw7ladfUimkaP7ude7vl+iJz1W8RhKemJE41vp81GMtw7sviUBqbCQUIysHS8ypbZh HdzO3Up6g==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1ljMyQ-004Do6-5q; Wed, 19 May 2021 14:14:59 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ljMyF-004Dmu-Tf for linux-arm-kernel@desiato.infradead.org; Wed, 19 May 2021 14:14:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=4smYcTa15UYqyc9U7xtsvhzdUIi7+SqKvfQW3p1ngQE=; b=H0Az9kNyBgT8tzYWCdhD7AIgyx e9xE+H3dH/LXiImzuhb/lvtuHQfSnZJ71kFYUskKv4KNj/e+w7rRHDrSLVv4QBhZ6rwOXCL/7uE3x 5yGn1XfDNqqlXV58I6mlCV0sA3S2Om5UmHizOwP5Xt3wVnNhA5YwjWD7qT392/V96YF0WvNIN0ISS 9Ht5z+c6+VbJtarg3iXVfFZzk26z/Dq+63HF4FG6wXKaPn+swqtyh+H9NSRh4RKIOar5/mzmDmCNz 3NDitstxUemHB0HPlAYIy56cphtWGSJsqwT6MV1NK//DWHw0OZJH6fmjLcBpOelrTSTnUHqGvsBt4 yodae+Fg==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ljMyD-00FWrn-Cl for linux-arm-kernel@lists.infradead.org; Wed, 19 May 2021 14:14:46 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id EEC186135F; Wed, 19 May 2021 14:14:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621433685; bh=qrNdjflpUvLivu9UtSwHedId14adKJHrYDNOU0/V3Hs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=twpD1awFlktxWTVN0ZSO9g/5G2LwDY1xG5cwscVPLce3W4s8JvjuQTEtxOKugVKdV PoIcsIY2p9KwnI/fNJM6xY4k4SzRIx/o66q8/QgWfHGwLO4H2gs3f3nuXxnDgVXbXt DaDuYo2Um8m9zvB85WrNU9tb/Abg2ST94m6QQURW/9Affw1kJLbj4T3bGB7I3I1JEN +HhLr67wiekH6h2K30YEM6PPLRaDxgy1E7R4I6u5u35EPGCk4IRIEkx1ZHbcMgMscb zUrxAn+0elcSRvMzBfGNTB4LAWlIFM4ywTs2gCCuhV5cSqg7wP7NgcJ1/idK6FIhKK 7VooDZZF8gTyw== From: Mike Rapoport To: linux-arm-kernel@lists.infradead.org Cc: Andrew Morton , Kefeng Wang , Mike Rapoport , Mike Rapoport , Russell King , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 1/3] memblock: free_unused_memmap: use pageblock units instead of MAX_ORDER Date: Wed, 19 May 2021 17:14:34 +0300 Message-Id: <20210519141436.11961-2-rppt@kernel.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210519141436.11961-1-rppt@kernel.org> References: <20210519141436.11961-1-rppt@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210519_071445_475256_96070563 X-CRM114-Status: GOOD ( 14.54 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Mike Rapoport The code that frees unused memory map uses rounds start and end of the holes that are freed to MAX_ORDER_NR_PAGES to preserve continuity of the memory map for MAX_ORDER regions. Lots of core memory management functionality relies on homogeneity of the memory map within each pageblock which size may differ from MAX_ORDER in certain configurations. Although currently, for the architectures that use free_unused_memmap(), pageblock_order and MAX_ORDER are equivalent, it is cleaner to have common notation thought mm code. Replace MAX_ORDER_NR_PAGES with pageblock_nr_pages and update the comments to make it more clear why the alignment to pageblock boundaries is required. Signed-off-by: Mike Rapoport --- mm/memblock.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mm/memblock.c b/mm/memblock.c index afaefa8fc6ab..97fa87541b5f 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -1943,11 +1943,11 @@ static void __init free_unused_memmap(void) start = min(start, ALIGN(prev_end, PAGES_PER_SECTION)); #else /* - * Align down here since the VM subsystem insists that the - * memmap entries are valid from the bank start aligned to - * MAX_ORDER_NR_PAGES. + * Align down here since many operations in VM subsystem + * presume that there are no holes in the memory map inside + * a pageblock */ - start = round_down(start, MAX_ORDER_NR_PAGES); + start = round_down(start, pageblock_nr_pages); #endif /* @@ -1958,11 +1958,11 @@ static void __init free_unused_memmap(void) free_memmap(prev_end, start); /* - * Align up here since the VM subsystem insists that the - * memmap entries are valid from the bank end aligned to - * MAX_ORDER_NR_PAGES. + * Align up here since many operations in VM subsystem + * presume that there are no holes in the memory map inside + * a pageblock */ - prev_end = ALIGN(end, MAX_ORDER_NR_PAGES); + prev_end = ALIGN(end, pageblock_nr_pages); } #ifdef CONFIG_SPARSEMEM From patchwork Wed May 19 14:14:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 12267539 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=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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 B6564C433ED for ; Wed, 19 May 2021 14:16:38 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 887B3611AE for ; Wed, 19 May 2021 14:16:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 887B3611AE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=vs+Yh1aq2QkIEuYeYYuKKx2R5/pDLmOe9MCxJRpJ3cM=; b=aNGPIHS4eQrk/lZQO94UYpQWS wrioeA1CoFM/KITKw3ZTqQCyrlAYNqw2E/aeRPXgPqXf/E9lM67jIxlmXp6e39AnD+4o6roiY2b5F nNGqhD421UgPmJXdAvyD8ZHwt73xoJDGiZNRqSqiN8Z1cK/ql9PXVTMv7Dv/kIIgUdZ4dnGu/O/Gj iyDvmUvhfvLd7UvI65jqHuBhxHRYCv2w8+hPQgZPkm29fybJ0gif5Fpm0ZhJqU3S83rzkptCqqhZy R9fSLBGxlRMiP44yMFOCr7ihizO2F1kUXg2JMb3iWOXrmqJ//iBKuSW62BSczil3Tmre/K7k1E62/ Y+unqFTcQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1ljMye-004Dpo-9F; Wed, 19 May 2021 14:15:12 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ljMyI-004DnL-OZ for linux-arm-kernel@desiato.infradead.org; Wed, 19 May 2021 14:14:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=6B4X+w0gstcYRgmA/S9+I4BaeY2ESvlDWN9mSom1Hqo=; b=oemaYauoMOs8gwqwMIIqVva5Oi vXH3cLUbwDw4X/l2fkKtLBoeI14+92xi3T1um2oPbV2UIUDYoHR2S0JLfd4D4SMRcgL47hvTdJGC9 NLZxCMda4znO7lzPnGraUSW0Wr3NsdLOEcWFTHaDGs07d4nE8sISzFln4AkZaW105de5kRERxp9Yo JhtWnZF//C0tBlyqE/ZftAMdiulMrxgfTbVBxjJscjSXmSRdKgM10/Gj9V+3JtASaiEwoG9yU+eK4 HUs8IEt/diXX573+3JJbrKmqEJBY2UZH00pyixE03NTvKcvg77Chev/pcbn0zMX4YfoF9aRhWpcq0 nGKWP6IA==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ljMyG-00FWsv-1Z for linux-arm-kernel@lists.infradead.org; Wed, 19 May 2021 14:14:49 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 98BEE611AE; Wed, 19 May 2021 14:14:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621433687; bh=8S/jBfuQqPw5Y9SjeyOmElG9wuJ/AnCGL+Y38mTgWSw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hTCE1ElGd8RQUsYpH10tZHH8+JrbvHD8gDqQ3oiQsubqDJKdm5uGMtoKd9AG4tcu0 F46Nu1C9cdBQvHyH+17uUbdB0KIl7QDKZBPoHUsAoRkhPcUXx4lRPV1afjIhbdKLkJ +TKjoZhXcRPAN2oaldHMhj23eKI753CfmaJcVqGeSCyrVW+PRIqV0nMBCUWC3LNRx2 dtJPLCuG60q+NAmamqwgOs6EgZLv8m5tJmF4dVkgiqn/EL7j6AZwxj2qU+YHOleN3B 6OXmcc4prO3YituX+8Ap8WhwBXkdVrz2/Cq/UuGRExK5pgPNCleR/oHPSCJ/FqMLZ9 NnC8WZrXn5SPg== From: Mike Rapoport To: linux-arm-kernel@lists.infradead.org Cc: Andrew Morton , Kefeng Wang , Mike Rapoport , Mike Rapoport , Russell King , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 2/3] memblock: align freed memory map on pageblock boundaries with SPARSEMEM Date: Wed, 19 May 2021 17:14:35 +0300 Message-Id: <20210519141436.11961-3-rppt@kernel.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210519141436.11961-1-rppt@kernel.org> References: <20210519141436.11961-1-rppt@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210519_071448_124700_A1DDF174 X-CRM114-Status: GOOD ( 13.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Mike Rapoport When CONFIG_SPARSEMEM=y the ranges of the memory map that are freed are not aligned to the pageblock boundaries which breaks assumptions about homogeneity of the memory map throughout core mm code. Make sure that the freed memory map is always aligned on pageblock boundaries regardless of the memory model selection. Signed-off-by: Mike Rapoport --- mm/memblock.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mm/memblock.c b/mm/memblock.c index 97fa87541b5f..2e25d69739e0 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -1941,14 +1941,13 @@ static void __init free_unused_memmap(void) * due to SPARSEMEM sections which aren't present. */ start = min(start, ALIGN(prev_end, PAGES_PER_SECTION)); -#else +#endif /* * Align down here since many operations in VM subsystem * presume that there are no holes in the memory map inside * a pageblock */ start = round_down(start, pageblock_nr_pages); -#endif /* * If we had a previous bank, and there is a space @@ -1966,8 +1965,10 @@ static void __init free_unused_memmap(void) } #ifdef CONFIG_SPARSEMEM - if (!IS_ALIGNED(prev_end, PAGES_PER_SECTION)) + if (!IS_ALIGNED(prev_end, PAGES_PER_SECTION)) { + prev_end = ALIGN(end, pageblock_nr_pages); free_memmap(prev_end, ALIGN(prev_end, PAGES_PER_SECTION)); + } #endif } From patchwork Wed May 19 14:14:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 12267543 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=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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 C11BEC433ED for ; Wed, 19 May 2021 14:16:47 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8DBE5611AE for ; Wed, 19 May 2021 14:16:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8DBE5611AE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=EaH6NVgX5P4gmsqhDmjWqI8wMfmOC5t13UTz65i9OdQ=; b=XbzID1JC9snWoeCeN8cN0UNaY b67ZAMTs0io8I7+vqyicwx2iuKU7gKIOlId3gnahZzQruJ0ymJlI8EmpwEYCXwuUQlWTFEwpIh08e UQyOzS1oFn91GdZ+BQ0gpulR4iZYjUTbmQ8KpwU7YfqfO6JMhgObYF313Qf+Ewu5BHXRgGVsi5qJn v1pZ0X7KqbI/fB+/2zGVet4NzMyNn10uu8eaxDep4d2I1J2030aUspxuvOvr9W9FNUkBgFZkSvvA6 QiAh+DnRSnSeNMA+tJl+HwgA/hGyEfDpOwOHl6BFpro5EhqHxTT10BvxRJyV6g0jiRDeR4MbI96Bb SSaS//ZRg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1ljMyp-004Dra-7f; Wed, 19 May 2021 14:15:23 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ljMyL-004Dnc-4S for linux-arm-kernel@desiato.infradead.org; Wed, 19 May 2021 14:14:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=BMEzzCUG/Ab0susexTFMtbiGrjOSscrYH78UhOqy5L0=; b=eOVgmVV5n4iPumD7jJ0ROkE0HJ O8JFKROrc9iDL3H+ljed8P4gfEfdllxwy0m/74K/mJru4WBotr6LNs1psLdUl+2Z8AOx0saD420N1 JJXTkAaP3/2w+fqNekiYG0llUpdvazVg1aMB54UIoPQjPo5bzhj5up0QXJPNnsVg3RMAhcq3k9c60 jwV9HQSltUZvg+uGc5rcoREACJhK2XvchUBXztiFD7b2Bg/396IVq+A6xLp+ZEPjek4u4c/nCnURm 6TDF20sBxzs7RaoFB9uu5jKpKnfT65qj/IXRaU+66ZxdN1rnf2AhDpMLTx0LLw/v8TUGZXtL31RmO aVDQpAyQ==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ljMyI-00FWtY-Mi for linux-arm-kernel@lists.infradead.org; Wed, 19 May 2021 14:14:51 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3E70C61363; Wed, 19 May 2021 14:14:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621433690; bh=rRFc0ILonpYJdVr2TDsn36MJ5mLmgIkTfeLqsV9zN18=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BA6uFoGr6PP2RAvPnkryuSxFifPl/Ue7ySDROfWzKgKQq3GkQKW9rq19ourCeWb3A EVJMLpe52ov/1XQQRzdo/VMfIwHU3UIiKVOc/e0zRsSODYzLbhnNMsgknLdyUdKnJv q4iJsh/+6FOA/smUL0yOT0rWAfbHqgYQ7/UZWFsOziOXkd5aB0b+rDKfw/oX9/s7r+ sB+ROfVm0ePvuMaE86faSHvNK6NUa3W5f8n0Znzu2JG7TXH+VqTR9UacVSZVeUQ7XC iIt3V/eHuYSB9QaVMwoY6ly0izSm/TjTkBDb2sD6JCQKoGFKh1fKzEVoVuex31/Pok JvLmqqr6QESjA== From: Mike Rapoport To: linux-arm-kernel@lists.infradead.org Cc: Andrew Morton , Kefeng Wang , Mike Rapoport , Mike Rapoport , Russell King , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 3/3] arm: extend pfn_valid to take into accound freed memory map alignment Date: Wed, 19 May 2021 17:14:36 +0300 Message-Id: <20210519141436.11961-4-rppt@kernel.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210519141436.11961-1-rppt@kernel.org> References: <20210519141436.11961-1-rppt@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210519_071450_780438_32CA0A2F X-CRM114-Status: GOOD ( 16.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 --- 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