From patchwork Fri Aug 30 08:00:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rong Qianfeng X-Patchwork-Id: 13784497 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 4980BCA0EE8 for ; Fri, 30 Aug 2024 08:03:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding: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=y+tZjcVuyAmIzZ9so2SWUagSZfz89M/gkSj310EhV30=; b=qnkA5lWstJsH4y04yj8qo136N3 PJzTxrYWkd6h2fXjKZPpxqd0tkhmiyslccgxTFXfPjuFfAFSD+/1ROBBVJVqC/jvhb9BnFa7Vku5H Yu2YXTfIyctYYu92UxmmmPQs2IoqwWks+O2NmmD/48YpJ4bQ7Bt4fQ3KSTouJ1hPecALV/WMs1N7g q5mxPDM18a3a7gE91DBIHC/3YgPz+vp4uOP2u1noZ6wDDvugg9yr3OC2xbybqmIb+3ZgQmZyvr3H6 Fl4ApWXWnHHyy7g6Zpg6ZXSvAql8FXafyW4udm4WlS7ittZIwvloow5BiqWgoxXt26JBuXJKUZ1CP b9FMHZjw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sjwbD-00000005ESh-3Dij; Fri, 30 Aug 2024 08:03:16 +0000 Received: from mail-tyzapc01on20620.outbound.protection.outlook.com ([2a01:111:f403:2011::620] helo=APC01-TYZ-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sjwYo-00000005Du4-0GXp for linux-arm-kernel@lists.infradead.org; Fri, 30 Aug 2024 08:00:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ovDvBF9/EFP6Y0LguQ+sP4QIbexcpia+YHdji9eoz8Xuh32NWsAbXGCcALdHXDRVb15sydlopoZsbx+pAY2rQDCVZaK4ezCYTWToeBUTdGRV1UdW7XDmm8nLFfOuqJvq/GKdz2ln11orT9ysZMU68GYM+oDQqyJv7ugv/7zU9X4RtzDgopjGcfEe4Kyv1OKtGDVAY3dw9C+dnes4ztjy4o++t1jl9ugCNnPeBU4pspbiO72yp83AEC1QVb9xDBws3tn4sZ4RC96l9WfRV+j23pzAletgRR+vYQ3wWR0dzTaWPickGld/fD84ZWG6f+H9VifrzJ1HGsrbPR7D9khHkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=y+tZjcVuyAmIzZ9so2SWUagSZfz89M/gkSj310EhV30=; b=FV1YxODc6LEecoxUkZ68qkydsuhEawM9pIfyCrfu4s1n/ewH2TC9huw2hoaAeRzeJckEnvb7fe7u7L3EZN0AU/mgJTcc9eaq3KQupI3TarPV5dWpjsrV9CmSAGORbQYdCbb6msU4HxvA1jvp4xvZ2IvNMavaZ1834vIjIq3WTXa/wiuStsAv9WnR1IypkYO0LT0FR1X9KmnE2mtiGz1nYxyT6yuOyGoOwVmg9gxNrGe8OvoUEejVmu4XkDpKneDvJ6sSbpSz36KyHCHuzagLEuguWtvZ8ZYVr9avzbJah9Leg+wqAdplfLLrdN7ltC8DT4U9P4epqw5AkBt382GOnw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=y+tZjcVuyAmIzZ9so2SWUagSZfz89M/gkSj310EhV30=; b=Om08QLBXh/91t8iSWN4Ju7rm1rcTwP0BIxh9y+mgzuOqWZ89zK6WHi0YrNuR1kEZJpPqpn2GrhICmtX1BtltU2xMkQUUIVMWZ0Ap8mrhZ1knXQGPpxhuCZjx7scZLeJVxfXc6Gerw1N2fcASAEHgaVMJaLSREa4URDdoTCIJPlRR1lTxVyX15xnK42ZBJ0hTfRIHzk0bpADXoabZ6zKo9J94rvXmyTMOqfOG750bvH1fARh9d58rF1kR+o+YgAmVtYbRTl0l+pV8WHmcxqvtJk9QtV2U9rtRAu4+cmNQJq1fj/oMtVSMjiZgGOgjiT6gvYykiErOK/CLivZks3gK1A== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SI2PR06MB5140.apcprd06.prod.outlook.com (2603:1096:4:1af::9) by JH0PR06MB6704.apcprd06.prod.outlook.com (2603:1096:990:37::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.21; Fri, 30 Aug 2024 08:00:35 +0000 Received: from SI2PR06MB5140.apcprd06.prod.outlook.com ([fe80::468a:88be:bec:666]) by SI2PR06MB5140.apcprd06.prod.outlook.com ([fe80::468a:88be:bec:666%6]) with mapi id 15.20.7897.021; Fri, 30 Aug 2024 08:00:35 +0000 From: Rong Qianfeng To: Catalin Marinas , Will Deacon , Andrew Morton , Baoquan He , Petr Tesarik , Baruch Siach , "Mike Rapoport (IBM)" , Ard Biesheuvel , Rong Qianfeng , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: opensource.kernel@vivo.com Subject: [PATCH] arm64/mm: Delete __init region from memblock.reserved Date: Fri, 30 Aug 2024 16:00:16 +0800 Message-Id: <20240830080020.33666-1-rongqianfeng@vivo.com> X-Mailer: git-send-email 2.39.0 X-ClientProxiedBy: TYCP286CA0190.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:382::10) To SI2PR06MB5140.apcprd06.prod.outlook.com (2603:1096:4:1af::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SI2PR06MB5140:EE_|JH0PR06MB6704:EE_ X-MS-Office365-Filtering-Correlation-Id: f17225ff-a400-4193-bb76-08dcc8c9d3e1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|366016|52116014|376014|1800799024|921020|38350700014; X-Microsoft-Antispam-Message-Info: AbaVVLbpfFFyDnB9ESrYcENZPKAh9+4Uw1LE2jYo4BjaXmuzDcspWODYJ2BMyUtgrBTX9n9HYlXwG4UKfD4Mu2OlwRghJUoXFO1UxGRDFqtcYp3WFgnqfJIN8LYFwz7DOehagjN5ww1AyfOkaXHtI3p+jODfsi3mqVuPNLyMXf9mAI8+7JWZEJ6XIvp+T3UII3fyZ5slD9uloVpHt1pRxMbDd1XsG3zJ0JfpyQfglGnQiiA17PTmEKnAgKUFB9AOZS/IUJA+2z4t57er7WB5S5/eiENtOCy3tYVdkoClIY5X/VonQpeJgHoUdwVBINpHJEuj9j0XY8XPhu1rP5GKa/fVnkj2wK9KYOOvUHSVLVcSF8bSsX2zZkQCnCL6WQnvRQFtuq1qj2FVJhtLuVRWPLgEKCVKTM7DEeur47lphhbtNIrR8rsRgm9Dc6l2D4vTpTh2Ltmk1hKEqq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MB5140.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(366016)(52116014)(376014)(1800799024)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Yvr/Ie98Cc/+cBfVSHQOHZQ6ZkKs5r75cH+GQUq/3ykPKlYGL34uTM/8BvGWkcjuTAkXImRfcXuRQbvNM5WcTx8Ml8JNr8y4AVk5Jhuweq7V4wz1O6bW+VxT4n9kiQdzyQjKLSZLQ6LGd8xef0DqAbWhFUy52bSO9GNP/mgsLOZdOGeEPVC+28ew+BQgoRFiFwOI8vH7j8mOAHPM4mlOSaOXLBnhX6zzG/53RtuwGB9XJ3VrRSyVTMyKeZMoB6uTriQ2I9bJT/OET/Zj0EVCjA+L7TRTFtV366smTukBb1gHOsW5gFB/cP/Dh9UZh1W5STJRQ1TA5QGt3peo0+iKuA3McMKsAUXMCjku9hP81aMygZY/CrvNHgt0antXmqzv/uAR8Fi7omK3YyTvw8EKVJAufh7ExSwa1X6JPSs8StThh3c6X0mBGDVKlixRAggVBcEZvUuw04onnQGNi0nH0vOU94B4ff2oPJcQYKLV8Mz+g++BK7rVz7HMAZzLujAE5nOWRTsDB8GfKaHK2a/FOOrLGEDlln/+2Fne8KUtefwapHsWxRICDlM/jcila4h23brM6A4TS+AdYpugzxwmgEmzrCQP6yOhdis9EJU+426S0z5a5Tl5YVuO/VxSAuylqURRLxHqTDykxRgkjlPPCcYI8ORnfm0Oei1U1nOCLt0MOP7UXTiy+IcDZhsIJ+anmx87EPm9yfOX1mMc5lR3pUCcTmTRKwU1v1NDWn2t7Epu22OT57+GUXaPKXPgoAdBQdxEBZ2DyHN/X1HD/N9vocwKGX/bzT0IPr1KYIW9q5H5bRD4NPwZcf4//8Bk+cPx5bYjlH+aAS1jPrjXxqVU4OWTfA2N186gAaPPY8ZsmVG20ks0GFgd279I4dHOk/TcWQM81PBu0w2cqXerHWDqv2HcoXXGfD1GJBzKzHWZej8nRuxgTALMY8vEkOvSSKJxdegBOrscfg2d9Y5KYst+Dl43pQe1bOC3Wyd2rpWHgRQbIghieqDd30zzpuqe2GZATnDa7phYuebM4oMQ09xJur5H02iE1XnvFOmg3LbRDY2kiC9z+NAN23QLU+UiqAneTnTZMuEHRqONh+/SZIGL6Z4UE1bj2dZlhFjPLwD0guvLLblyhqgQDAl5wCrRABx1Nh1Y9l6Ke4bvMD3C6Gs5O4n8yi9+hGzAJ8kiT9CFuRb2LqjS8YSgqTtyPKumpBF833pRtNaSH93zqVXn56nu+fd8EBx9FzcKKFO37ghGaniaCk1VoeLOJR2oxy5Q+bM2q57M8sSTmKYKaWQc66kQ+lRhMygRepgt2OgD2LHNr4ZS+tjQAYeeo6wa0gsQekK5B/yV5VGCXC08NFwbcWsb77tNvg4ergUhxUx5fgfpAs6gQgdFgLdP4ZIcg5Z6K9OUOQMdKpI5EsP2JuPBvibtvJbASH0k3Op2Z3tH/uZASAjadEYJUq2O/tCxlpHrfU9I9hIHEDkOGp9olf6JhgB4aFW9mEGN8wK6Rw8n1/6OQqQtSDLL2F/5D7UPbJv2XW5O0cTrUILcqnXYdek8brJPdfrD1QGrGz94psSD1Pvwg2NLwS7oRM2p8BR8BljJa1M3 X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: f17225ff-a400-4193-bb76-08dcc8c9d3e1 X-MS-Exchange-CrossTenant-AuthSource: SI2PR06MB5140.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2024 08:00:35.1785 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: cst0VOBy/687vgZR3XlQGHEMXJ8pDRu+sL61PVTEKjoz1LghWZLD812Af7wX5ZTU8EKmacQvIa743ErxsT8EOg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: JH0PR06MB6704 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240830_010046_128246_DDC5A868 X-CRM114-Status: UNSURE ( 8.68 ) X-CRM114-Notice: Please train this message. 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 If CONFIG_ARCH_KEEP_MEMBLOCK is enabled, the memory information in memblock will be retained. We release the __init memory here, and we should also delete the corresponding region in memblock.reserved. Signed-off-by: Rong Qianfeng --- arch/arm64/mm/init.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index bfb10969cbf0..99cfa217e905 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -402,6 +402,13 @@ void __init mem_init(void) void free_initmem(void) { + if (IS_ENABLED(CONFIG_ARCH_KEEP_MEMBLOCK)) { + unsigned long aligned_begin = ALIGN_DOWN((u64)__init_begin, PAGE_SIZE); + unsigned long aligned_end = ALIGN((u64)__init_end, PAGE_SIZE); + + memblock_free((void *)aligned_begin, aligned_end - aligned_begin); + } + free_reserved_area(lm_alias(__init_begin), lm_alias(__init_end), POISON_FREE_INITMEM, "unused kernel");