From mboxrd@z Thu Jan 1 00:00:00 1970 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=-11.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 A1FC5C4708F for ; Mon, 31 May 2021 12:31:12 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 500EA6135C for ; Mon, 31 May 2021 12:31:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 500EA6135C 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 D38F98D0002; Mon, 31 May 2021 08:31:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CE8736B007B; Mon, 31 May 2021 08:31:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B88E18D0002; Mon, 31 May 2021 08:31:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0135.hostedemail.com [216.40.44.135]) by kanga.kvack.org (Postfix) with ESMTP id 83D7E6B0078 for ; Mon, 31 May 2021 08:31:11 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 21E09B79E for ; Mon, 31 May 2021 12:31:11 +0000 (UTC) X-FDA: 78201461142.17.C12F95A Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf07.hostedemail.com (Postfix) with ESMTP id DFC2CA000262 for ; Mon, 31 May 2021 12:30:58 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 8BC6B6124B; Mon, 31 May 2021 12:31:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1622464269; bh=E3NY0Wohhst6B5rpjC28lQS7joUqhV9RJrr3gZggAGg=; h=From:To:Cc:Subject:Date:From; b=F9bNs/FYGLl1aRdwAhR61z29+Kzxoye4ebjI0n9W6ClGUlcg06NzsIRMpIjJ8d32G MwiCCmrEWR/H+mZnEtNQ13kKEcaQDN+fODqUwWZ1UEczzZBGXKst3/6TMqIHKVKNxB LOM1ku9cXUGxQOBTy+aabtQVJQITGUH5LJog20AFwD8nAetKqtTHflac1cPuxe6lgc 0EO8w9ty7Q9jQ8VHcIM4ZL0aybLJn2JvW0A3IKb7pR7pu7Xo3cBrvmjwfDcFZsmwWd xz46CQW3zSe0lNFUGyMbe7/xhMtIt3bvvqYIepHdiEemQ0E2Jpi9dsiRxLFWWdxbyb k35L5I2Nw9V9w== From: Mike Rapoport To: linux-kernel@vger.kernel.org Cc: Andrew Morton , Catalin Marinas , Christian Borntraeger , David Hildenbrand , Heiko Carstens , Mike Rapoport , Mike Rapoport , Russell King , Thomas Bogendoerfer , Vasily Gorbik , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-s390@vger.kernel.org Subject: [RFC/RFT PATCH 0/5] consolidate "System RAM" resources setup Date: Mon, 31 May 2021 15:29:54 +0300 Message-Id: <20210531122959.23499-1-rppt@kernel.org> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 X-Rspamd-Queue-Id: DFC2CA000262 Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="F9bNs/FY"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf07.hostedemail.com: domain of rppt@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=rppt@kernel.org X-Rspamd-Server: rspam03 X-Stat-Signature: bnj56ruzt4jrmn1gyrdpwtbbobyxykxk X-HE-Tag: 1622464258-302200 Content-Transfer-Encoding: quoted-printable 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 Hi, There are several architectures that use very similar code for setup if "System RAM" resources under iomem_resource tree and requesting memory resources corresponding to the kernel code, data etc. The flow for resources setup iterates over memory regions registered in memblock, adds a resource for each region as "System RAM" and than registers the areas used by the kernel image and, optionally, the crash kernel area, as children of the "System RAM" resources. The notable differences are: * arm/arm64 use [__text, __init_begin] range for kernel code resource and [_sdata, _end] range for kernel data, while most other architectures us= e more fine grained ranges. * arm has "System RAM (boot alias)" that do not seem useful for any other architecture * arm64 has special treatment for NOMAP areas and all the areas reserved = in memblock * s390 has crashk_res in parallel with the "System RAM" resource, but it seems it was required some time ago but no longer actually needed. These patches use s390 implementation of the resource setup as the basis and then switch MIPS, arm and arm64 to use it with modifications required to support each architecture.=20 The generic code loops over all memblock.memory regions, adds the NOMAP regions as "reserved" iomem resources and "normal" regions as "System RAM= " iomem resrouces, reserves the areas occupied by the kernel code, rodata, data and bss, if there is crash kernel resource it is also reserved. In addition, if an architectures selects CONFIG_ARCH_WANT_RESERVE_MEMBLOCK_RESERVED_REGIONS (bad name, but I could not find a better one) the memblock.reserved regions are registered as "reserved" resources in iomem_resource. It would be also possible to convert other architectures (e.g, RISC-V and sh) to use the common infrastructure. Mike Rapoport (5): s390: make crashk_res resource a child of "System RAM" memblock: introduce generic memblock_setup_resources() arm: switch to generic memblock_setup_resources() MIPS: switch to generic memblock_setup_resources arm64: switch to generic memblock_setup_resources() arch/Kconfig | 7 ++ arch/arm/kernel/setup.c | 37 +---------- arch/arm64/Kconfig | 1 + arch/arm64/kernel/setup.c | 101 +---------------------------- arch/mips/kernel/setup.c | 78 ++-------------------- arch/s390/kernel/setup.c | 86 +------------------------ include/linux/memblock.h | 2 + mm/memblock.c | 132 ++++++++++++++++++++++++++++++++++++++ 8 files changed, 151 insertions(+), 293 deletions(-) base-commit: c4681547bcce777daf576925a966ffa824edd09d --=20 2.28.0