From patchwork Mon May 31 12:29:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 12289311 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=unavailable 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 BFB03C47082 for ; Mon, 31 May 2021 12:32:56 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 83A1261287 for ; Mon, 31 May 2021 12:32:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 83A1261287 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=bombadil.20210309; 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=XUkVEzMyoCUWHlC5SxxPGRYf2dzIR0oA5sMkOVXGyXg=; b=QKjG9b8WwRe4Ml o1k7q94uFOymkG+kvLqdhwD06zeFkBnBZXiJBnmPvLPolGYUtLgu/CvaJi83iUTBRwGmNKxQHtqCh 9Tr6vQfWiPH+43aJ0vYFjfEaYGSWRBgid90cLpwp6zJSpqsquo6WioxFfwqeHH2ww0H8rXwZZ00Pe hSRppna4t9GT0QkZZ+nP9kpi0G/SnBFZowlGdQaHOuZvBlom3u9Ou2A6+oiMTEWqiCC9LR9IhT2Cc s1ddw4Q55zGLOC1VWHxilPQ76YCIW31UP9xSdoJkMZz6tN9/V4p2RnTmk/FNc0IZhROexPV8CT0Le 6pf8OCErngFZrK+6MFSA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lnh4d-00C9dT-9y; Mon, 31 May 2021 12:31:15 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lnh4Z-00C9cO-31 for linux-arm-kernel@lists.infradead.org; Mon, 31 May 2021 12:31:12 +0000 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210531_053111_201537_BC118180 X-CRM114-Status: GOOD ( 12.50 ) 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, 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 use 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. 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