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: 12357533 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=-15.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,INCLUDES_PULL_REQUEST, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 DFE64C07E95 for ; Sun, 4 Jul 2021 15:09:53 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 821EB613B7 for ; Sun, 4 Jul 2021 15:09:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 821EB613B7 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=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:Cc:To: From:Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=2E/iztbhedntMwFev08hxU8Cr3wycsn+OtG9B/SxGBY=; b=Mfe7cbgw4/jE6d vbUyxp2t2pmnjPQjNXvhxgAJh1Ty6uwvnq3//0pGtBy9nZYaPcXzYca8l6uo46/Uvk9/P0EuM4MB3 h2U0bzqVp6/ViCBG2DuC6b93xPiAL8pvGwvTIyEhI/bCIR/x/YS7Nf/tDZZH0YYM1KAGQEIFPE22W aZMIxwXRkpAbYcBu95jmcRXaAsDi3US9SOcQuONU+zsSw49FR00zmMY9H3fcQSgtFwfVJGIuL5adG LrRdwOSXNpmS3/VKmuXG+F4tKw9z0TvUstGAOn0Q2tWKRQnVfQmk92Rf/qozJf0uzF2q9Phv2mDq1 NGDaQ+WCX42wiVvCfSYA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m03jF-006RDZ-80; Sun, 04 Jul 2021 15:08:17 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m03jA-006RCw-JD for linux-arm-kernel@lists.infradead.org; Sun, 04 Jul 2021 15:08:14 +0000 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210704_080812_706905_C94366F7 X-CRM114-Status: GOOD ( 11.63 ) 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 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(-)