From patchwork Mon Aug 1 08:04:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 12933605 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E64A4C3F6B0 for ; Mon, 1 Aug 2022 08:04:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 81BFD8E0006; Mon, 1 Aug 2022 04:04:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7CBE48E0001; Mon, 1 Aug 2022 04:04:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6BB088E0006; Mon, 1 Aug 2022 04:04:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 548078E0001 for ; Mon, 1 Aug 2022 04:04:47 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id E8F0DC0846 for ; Mon, 1 Aug 2022 08:04:46 +0000 (UTC) X-FDA: 79750287372.06.632D4C2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf01.hostedemail.com (Postfix) with ESMTP id 7955A400FF for ; Mon, 1 Aug 2022 08:04:46 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C9EEF60F68; Mon, 1 Aug 2022 08:04:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47132C43142; Mon, 1 Aug 2022 08:04:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1659341085; bh=SyAn2OHlBoyp4SJs3YcoSeH4zAJTR/slnZqVIScbiks=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lb4X4JP+kNTAv0eGRJhEMXlCO1mRzMi4zoNFWWJleYiOLzI/Wai1ETeVIr/3h0u/3 mI0r14pSSP/C04M+CHkHZL72Kvdhw86NOTOPnf+Y7dDf/2kHtBc/9WGP/gUlEGx5Eb xBz1XfEwKYldWQBSs14yy31vvtxQgjDmY9rHHq23iAS8DDmTQNhKN9lwJL8M+uGHV2 iWqdH0u6tdfYyCqn6a0SOjKkI1xoIS2P5OHQcDKafsAbtXO7KMotIJk8JoAIF25Zgj pzqueuu6VcfX8p56Likx83mfhhgbO8grf3KLwf+x0QDt1N4qz21buo+0tXcffqJXP8 4Q2uYr35AtWLw== From: Mike Rapoport To: linux-arm-kernel@lists.infradead.org Cc: Ard Biesheuvel , Catalin Marinas , Guanghui Feng , Mark Rutland , Mike Rapoport , Mike Rapoport , Will Deacon , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH 3/4] arm64/mmu: move helpers for hotplug page tables freeing close to callers Date: Mon, 1 Aug 2022 11:04:17 +0300 Message-Id: <20220801080418.120311-4-rppt@kernel.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220801080418.120311-1-rppt@kernel.org> References: <20220801080418.120311-1-rppt@kernel.org> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Lb4X4JP+; spf=pass (imf01.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659341086; a=rsa-sha256; cv=none; b=Z0JnsCnyrn+r6WAvwvnhP8YfAT1DN/9FZnCIlMmPXhaks5KISgxwzSsoKy6H3odATWWQ7L lIiUy2Yc1TY6bKyVVSdm2zwC0DPzCys3eYvd4kImE4xs2nyDIbRkYzwm5E5xhOGl/wZWjr DHnIVEFCl8lAJItJY45DGkDNNFTw/A0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659341086; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=2JM20ERNBDNlVabw7LOGj0pEtp8iFUm368VXtQOhY8w=; b=UdSIqjnSbrICpNrNvbY8KmUf+m4P3EoSfAx5B5B9FSSon0YIIjioTADIRO5IRB0bacNoRL c7/mvO29aaA9DNNNVgHt6PhOmS0fvAMG9KdcSQTdC3xshvYP8e1LWiMn/7eGnoiZ9q+lI6 /7UupioWA/Lfoj/rmQFZoDJN+bXKcos= X-Stat-Signature: bs7unssi5rdo1bb5mwdijq9o3xpkexow X-Rspamd-Queue-Id: 7955A400FF X-Rspam-User: Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Lb4X4JP+; spf=pass (imf01.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Rspamd-Server: rspam04 X-HE-Tag: 1659341086-284275 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 to minimize extra ifdefery when unmap_*() methods will be used to remap crash kernel. Signed-off-by: Mike Rapoport --- arch/arm64/mm/mmu.c | 50 ++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index baa2dda2dcce..2f548fb2244c 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -837,30 +837,6 @@ static void free_hotplug_page_range(struct page *page, size_t size, } } -static void free_hotplug_pgtable_page(struct page *page) -{ - free_hotplug_page_range(page, PAGE_SIZE, NULL); -} - -static bool pgtable_range_aligned(unsigned long start, unsigned long end, - unsigned long floor, unsigned long ceiling, - unsigned long mask) -{ - start &= mask; - if (start < floor) - return false; - - if (ceiling) { - ceiling &= mask; - if (!ceiling) - return false; - } - - if (end - 1 > ceiling - 1) - return false; - return true; -} - static void unmap_pte_range(pmd_t *pmdp, unsigned long addr, unsigned long end, bool free_mapped, struct vmem_altmap *altmap) @@ -993,6 +969,30 @@ static void unmap_range(unsigned long addr, unsigned long end, } while (addr = next, addr < end); } +static bool pgtable_range_aligned(unsigned long start, unsigned long end, + unsigned long floor, unsigned long ceiling, + unsigned long mask) +{ + start &= mask; + if (start < floor) + return false; + + if (ceiling) { + ceiling &= mask; + if (!ceiling) + return false; + } + + if (end - 1 > ceiling - 1) + return false; + return true; +} + +static void free_hotplug_pgtable_page(struct page *page) +{ + free_hotplug_page_range(page, PAGE_SIZE, NULL); +} + static void free_empty_pte_table(pmd_t *pmdp, unsigned long addr, unsigned long end, unsigned long floor, unsigned long ceiling) @@ -1146,7 +1146,7 @@ static void free_empty_tables(unsigned long addr, unsigned long end, free_empty_p4d_table(pgdp, addr, next, floor, ceiling); } while (addr = next, addr < end); } -#endif +#endif /* CONFIG_MEMORY_HOTPLUG */ #if !ARM64_KERNEL_USES_PMD_MAPS int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node,