From patchwork Wed Jun 30 07:12:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 12351361 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=-16.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,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 77BD5C11F65 for ; Wed, 30 Jun 2021 07:12:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 25B9D61CC0 for ; Wed, 30 Jun 2021 07:12:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 25B9D61CC0 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 950148D0188; Wed, 30 Jun 2021 03:12:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 926578D017A; Wed, 30 Jun 2021 03:12:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7EEEB8D0188; Wed, 30 Jun 2021 03:12:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0033.hostedemail.com [216.40.44.33]) by kanga.kvack.org (Postfix) with ESMTP id 5E4C18D017A for ; Wed, 30 Jun 2021 03:12:25 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 35F9318232A12 for ; Wed, 30 Jun 2021 07:12:25 +0000 (UTC) X-FDA: 78309521850.02.E62181F Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf02.hostedemail.com (Postfix) with ESMTP id C09AD7001BBC for ; Wed, 30 Jun 2021 07:12:24 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 9BFC561CA1; Wed, 30 Jun 2021 07:12:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625037144; bh=8S/jBfuQqPw5Y9SjeyOmElG9wuJ/AnCGL+Y38mTgWSw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jPrqJ9elwiUu59yUGzRWjwOqgtiryjCb9+I5hv0C5j8k0p9IbjMiakMIRlbPyYp3M /eBXKjSoVvmhBcvGuxQx7dKJAl1EGWEUDvPQkRw4uZ1X/zfuJgYUtSXtthBFYzKiW7 OsK5uPqD0oOympl8T5XsctK3n+P29CWS4/YG6H4g6rtHVeX/XlRUeI3yCUsOjzcbTI FC0auyRdjEwMgTDhjtV3Z44n5ZOyCDG8a6ChugD2F6/9VNHEvPHfrmLaZfIQhQJMtb 3memoizj4Vyi1/0dYabvlMpCVZHo96iXPoWCdSfoKulVyvz3efbjCBgmtjrRDeSsQ/ zx5ssEZaHhsNw== 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 2/4] memblock: align freed memory map on pageblock boundaries with SPARSEMEM Date: Wed, 30 Jun 2021 10:12:09 +0300 Message-Id: <20210630071211.21011-3-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 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: C09AD7001BBC Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=jPrqJ9el; spf=pass (imf02.hostedemail.com: domain of rppt@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Stat-Signature: wcsfresf1xrqn683zxbmnwq893g65q46 X-HE-Tag: 1625037144-113739 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: 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 }