From patchwork Sun Jul 4 15:08:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 12357535 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=-13.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_PATCH,INCLUDES_PULL_REQUEST,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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 5DF65C07E95 for ; Sun, 4 Jul 2021 15:08:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CFF1F613E2 for ; Sun, 4 Jul 2021 15:08:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CFF1F613E2 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 1002F6B0011; Sun, 4 Jul 2021 11:08:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0B0BE6B0036; Sun, 4 Jul 2021 11:08:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E92856B005D; Sun, 4 Jul 2021 11:08:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0187.hostedemail.com [216.40.44.187]) by kanga.kvack.org (Postfix) with ESMTP id C02B46B0011 for ; Sun, 4 Jul 2021 11:08:13 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 4613E1695E for ; Sun, 4 Jul 2021 15:08:13 +0000 (UTC) X-FDA: 78325236066.01.4EE68B2 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf23.hostedemail.com (Postfix) with ESMTP id DC2BF90000B0 for ; Sun, 4 Jul 2021 15:08:12 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 9AEE7613BA; Sun, 4 Jul 2021 15:08:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625411291; bh=kJrhh6BxzSNFGHYJ+mlmwYJIYNaq1EtlJUumheQZPao=; h=Date:From:To:Cc:Subject:From; b=IW/0QBXAUkmSO7TuKZvWoE4iUg3mf6DsEp2WDDZFw7Klt3LLWP1IZUVTv56ksS2Ka 0VPqP7UohT/wy1NfzAezLFV7OEcsk1L07mm1BfkV+lVIc5w9i9dQ2l9Kcgcq0P7yXo Gu7njoftfGKtL+61K6w7x3kISJnPpJZJTIrYgHbuFN/Ht6vqCcT02Q/3eDhHxieq6B pJzdMLfrzGdyBlFrAff/snNR62uTpx2j9D0IzpB5RJRPoK8+w1j2v+wAD0SgUYwvJF dlDHjpN0frUMkzz42JxcV9DWxB2Tv99KKePvUL0Y+p2FdrYqjwU7SDFkauPqI3HgVj GpKgreh6b4xvQ== Date: Sun, 4 Jul 2021 18:08:03 +0300 From: Mike Rapoport To: Linus Torvalds Cc: Andrew Morton , Kefeng Wang , Mike Rapoport , Mike Rapoport , Russell King , Tony Lindgren , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [GIT PULL] memblock, arm: fix crashes caused by holes in the memory map Message-ID: MIME-Version: 1.0 Content-Disposition: inline Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="IW/0QBXA"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf23.hostedemail.com: domain of rppt@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=rppt@kernel.org X-Stat-Signature: br9oy8nggfqxqzzyxsp9iwfdtakfonhz X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: DC2BF90000B0 X-HE-Tag: 1625411292-247475 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: Hi Linus, The following changes since commit c4681547bcce777daf576925a966ffa824edd09d: Linux 5.13-rc3 (2021-05-23 11:42:48 -1000) are available in the Git repository at: ssh://git@gitolite.kernel.org/pub/scm/linux/kernel/git/rppt/memblock.git tags/memblock-v5.14-rc1 for you to fetch changes up to a4d5613c4dc6d413e0733e37db9d116a2a36b9f3: arm: extend pfn_valid to take into account freed memory map alignment (2021-06-30 11:39:00 +0300) ---------------------------------------------------------------- memblock, arm: fix crashes caused by holes in the memory map The coordination between freeing of unused memory map, pfn_valid() and core mm assumptions about validity of the memory map in various ranges was not designed for complex layouts of the physical memory with a lot of holes all over the place. Kefen Wang reported crashes in move_freepages() on a system with the following memory layout [1]:   node   0: [mem 0x0000000080a00000-0x00000000855fffff]   node   0: [mem 0x0000000086a00000-0x0000000087dfffff]   node   0: [mem 0x000000008bd00000-0x000000008c4fffff]   node   0: [mem 0x000000008e300000-0x000000008ecfffff]   node   0: [mem 0x0000000090d00000-0x00000000bfffffff]   node   0: [mem 0x00000000cc000000-0x00000000dc9fffff]   node   0: [mem 0x00000000de700000-0x00000000de9fffff]   node   0: [mem 0x00000000e0800000-0x00000000e0bfffff]   node   0: [mem 0x00000000f4b00000-0x00000000f6ffffff]   node   0: [mem 0x00000000fda00000-0x00000000ffffefff] These crashes can be mitigated by enabling CONFIG_HOLES_IN_ZONE on ARM and essentially turning pfn_valid_within() to pfn_valid() instead of having it hardwired to 1 on that architecture, but this would require to keep CONFIG_HOLES_IN_ZONE solely for this purpose. A cleaner approach is to update ARM's implementation of pfn_valid() to take into accounting rounding of the freed memory map to pageblock boundaries and make sure it returns true for PFNs that have memory map entries even if there is no physical memory backing those PFNs. [1] https://lore.kernel.org/lkml/2a1592ad-bc9d-4664-fd19-f7448a37edc0@huawei.com ---------------------------------------------------------------- Mike Rapoport (4): memblock: free_unused_memmap: use pageblock units instead of MAX_ORDER memblock: align freed memory map on pageblock boundaries with SPARSEMEM memblock: ensure there is no overflow in memblock_overlaps_region() arm: extend pfn_valid to take into account freed memory map alignment arch/arm/mm/init.c | 13 ++++++++++++- mm/memblock.c | 26 ++++++++++++++------------ 2 files changed, 26 insertions(+), 13 deletions(-)