Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2563597pxj; Mon, 31 May 2021 05:32:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0akk+DHkuZTLWxRWeBoSBOAgiXZ6/Lnd1NryQBNDkgqK9+ORXyz0lPEmMvU+n4+sBq+6p X-Received: by 2002:a17:907:96a4:: with SMTP id hd36mr22825007ejc.519.1622464354499; Mon, 31 May 2021 05:32:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622464354; cv=none; d=google.com; s=arc-20160816; b=vxR2lAz0OdU6RF1W94PF08A3AXdxA9gGUQrTDY57RmFEcChksjxy4Th9yNNUinXxM8 0D6i3m9Li9msh1yp5xU2cN0Hw0KqiVaoPl0g7N5OTljOHz+zivzW1Dz64xInrDXk+qBC U4SZPoEGWwuGHN4Nmk0lJAM+8pob0Rd9AhW1aTzWpaAyiQH5l8v7R8CzzQOTWZwoIkuO ptL1rvLU7HHHjofsZKFvMhMCVW+jpK3YzocAvJPfM1ATJ65RE4xQQWbPpeb/K2fcLfPl cg/JQIyJv4MVLntTgM3rnYBB8orsTKmqp6VW6lVV23k4OpIfmEE6bYgt8PD7KsOc7Gsx FnmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=uzP8BIJM8r53CgWkUTdMoDBSSMKxVcTqdrtGB6eLTlY=; b=sKARtydcPIcTAI/shw/4x2ONmm9VZwPE17QTIqQtw19qT0WNqpPEOP37VmyGYu2V0N i7WN6Ca12rM2EinI936Tcg2ThacIdxsimko1uewsxLE6WkX3RiAJIuCYjqA9VX64WFiH lnOgIlWJkMDgH8K8a1WZAt58ZXFK6B56Ij/6seJ8557GbL0eEwexsoI+JJSvOmmVGsYw BLfDsTF0vlli7wW6HfiWXBV7QNAjv6I5lLaI4oo7BESpgMBZMD1rTVN9DlirwcIs02cg 2snUdz4BsLNdSle7Sa7Bfg3CHYYaRap/kNbOGpg/XTwQPj74zG48MWcmfiqp7bQtb/gJ ys0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="F9bNs/FY"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cw15si12328572ejb.537.2021.05.31.05.32.11; Mon, 31 May 2021 05:32:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="F9bNs/FY"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231488AbhEaMcv (ORCPT + 99 others); Mon, 31 May 2021 08:32:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:38372 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231450AbhEaMct (ORCPT ); Mon, 31 May 2021 08:32:49 -0400 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 -- 2.28.0