From patchwork Wed May 19 14:14:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 12267537 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=-12.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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 B9748C433B4 for ; Wed, 19 May 2021 14:16:33 +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 4729061004 for ; Wed, 19 May 2021 14:16:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4729061004 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: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:In-Reply-To:References:List-Owner; bh=37mIjUvWxFgu1ZQ52rVinNY0q7eZ44PZK7pUvi8b5zI=; b=ixAQFC/B+6e9gFcbEQ9O4aAc6z 4A5ZnEdomSUOZDquF+A+GYaqRmwGkkauACTDYsPPr7HgUO15dmKBdf0PFt+RCsToAaJHQiCWY9RU9 2RVpqZqm9vVQ4dbYmBKqIYqNH10DoJMJPqoAXfrUuvSzJ1AlJ+I3tCeb9udng/ybfWMQJkcKvy+F8 ChE6E9HAAtcRTbVn2P4x0IhnvLZOx7GegGMB85XKFajCXJ2nG0tunccRksBUFpGHL2z4BLPtHWywb K9YHbxOfdkbNx0wDdtocX5wkFvFo1kZZPpgfIQxApQ6SwJoQEsstWD9IZ+dU0KWAxdS+0Rq/AtAE9 zKvF5vfw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1ljMyG-004Dmz-HN; Wed, 19 May 2021 14:14:48 +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 1ljMyD-004DmW-Jn for linux-arm-kernel@desiato.infradead.org; Wed, 19 May 2021 14:14:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:MIME-Version:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-ID:Content-Description:In-Reply-To:References; bh=2AAsV3zyWtPM52De89V145JKa71qZXowP/SPdx85BH4=; b=dayPQ2OkcSS0As49W8a0pzXArf /c4ILer9Tmg9mmsgFB7wAMPjOm3qpKX6ncmso68QHZ6tS4h4eaYsxT0fLsD28koxxYOs9FJ7DzoNu oOjCFNWQ/QFCj50jlgEjVWiAjI+TFhoPxBp9jBIeVgXgBDTgAxMnYn+9iHZI/oBRQRXy4/BlkXeOM jrrSLLL0nvLt04IQrxm/ILUrlDsSt5hr5/fhDGOXTGeY74LitmkoIWxd6c2puv9ekYl+QVfM0vDt9 KlPOccsYzWywwUuwekukXXYlz3xETd7pXe3vGDPEmPN6HAWClDCtph+K+SqrUvAUQldrEiWSasgKJ bRrMKckQ==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ljMyA-00FWrS-R7 for linux-arm-kernel@lists.infradead.org; Wed, 19 May 2021 14:14:44 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5413361002; Wed, 19 May 2021 14:14:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621433682; bh=fHqldBFRMS+fmzLe1m4GydU7vDZX1DTbIOljHTFkg4c=; h=From:To:Cc:Subject:Date:From; b=K4tZ7BoZRKoHgEQXptMuPRGrEupaXtj2aDudDfvfRpBKlImkTSSWSdRpJG41/3Qb4 jE7V9eiD4AlBwuihgt/6vXhJ4UGiXTFLSuyxOADiBTnY61nE3Ka/P9lbpGU4tAarRd 1yffQK0NqP0mXEL4EdqiL5uUf2k/qaPRzr+UhF47eYN9DlXnuuen8UXkq4FnAEkmb9 qAF7mpuXgdYFrNJE5inCiufRrQheVIjRI3FDA7izvNx3UkXu3D6Dk9Oc+OKtlE0+4o W/HPBs+zypXQt0wlnA9YbQ9vxRoLIVbHyAE/D6Uf0S1FaVTPYJxsDExU5k/MkDtZGi XSyuucPDn6EhQ== 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 0/3] memblock, arm: fixes for freeing of the memory map Date: Wed, 19 May 2021 17:14:33 +0300 Message-Id: <20210519141436.11961-1-rppt@kernel.org> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210519_071442_920423_DB0C6608 X-CRM114-Status: GOOD ( 12.55 ) 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 Hi, 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:   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] The crashes can be mitigated by enabling CONFIG_HOLES_IN_ZONE and essentially turning pfn_valid_within() to pfn_valid() instead of having it hardwired to 1. Alternatively, we can 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. I can take the entire series via memblock tree. @Kefen, I didn't add your Tested-by yet because the patch is slightly different from the version you've tested. v2: * Use single memblock_overlaps_region() instead of several memblock_is_map_memory() lookups. This makes this series depend on update of MEMBLOCK_NOMAP handling in the memory map [2] v1: Link: https://lore.kernel.org/lkml/20210518090613.21519-1-rppt@kernel.org [1] https://lore.kernel.org/lkml/2a1592ad-bc9d-4664-fd19-f7448a37edc0@huawei.com [2] https://lore.kernel.org/lkml/20210511100550.28178-1-rppt@kernel.org Mike Rapoport (3): memblock: free_unused_memmap: use pageblock units instead of MAX_ORDER memblock: align freed memory map on pageblock boundaries with SPARSEMEM arm: extend pfn_valid to take into accound freed memory map alignment arch/arm/mm/init.c | 13 ++++++++++++- mm/memblock.c | 23 ++++++++++++----------- 2 files changed, 24 insertions(+), 12 deletions(-) base-commit: d07f6ca923ea0927a1024dfccafc5b53b61cfecc