Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp443588rdh; Wed, 14 Feb 2024 01:16:34 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX7T/V1X7BjBZIbSQcT2bVQeZbjpN3Cu/7FVkBlQk3KASfNqUIs44jt0pAhalVwbyoTF0e2XkkURXuCE0zmim990dweXTeqDV0S0XoL+w== X-Google-Smtp-Source: AGHT+IGFVA9jQ/XoSZDLTTHJR2n7EiWVuA3blJ8JOQWb2FVQbCFDRymGhgnO5ROnN11YtGNjIIcz X-Received: by 2002:a81:6e0a:0:b0:604:3e53:758f with SMTP id j10-20020a816e0a000000b006043e53758fmr2057575ywc.7.1707902193893; Wed, 14 Feb 2024 01:16:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707902193; cv=pass; d=google.com; s=arc-20160816; b=ZgCHR35+ugPxqtV9kAxYZuuzTuUQo18MPgMCU6fWIFMzineXtWyZN9p9yStpHSayRj eZNgFIS3YFU664CdbP56iDZyC9vA4q6FmlyE3fJ2oLDGAhFK8fyayxYNgZNZHtAvqHtY ktmttm5acgiuOkkmvGfDV2TYAfsSo/wA9MOOmkCUmA+5uEIlBuiE/n3sJkI/jLBoASWd ZdVavop8kSZDPgmN+mkXOeqmvpgyO4+Y4txETN3tXDgoYIusvLq/bUI5Bh4y5fwo70kJ cFrHB75zRMjkY5ehn84DlBp9EjnPnJ8SlUb/JtX0eTSPL2akiO6yXpYNcok3fdi4W3bT nmbQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=PvXn3dHzGdg4oNIbIRR2XSONs4TuyFtms9dWO5dYLOs=; fh=v6keLIw11GrkPlJDG6GHc2Z/Qff01Lnei3sNGGpP2lo=; b=j4uRaA4l5FME+sfldpypUM/Y5ifMeD/Z+jnUaJ1EEv5tiinDMKA4McHmcdMKfAbrej /sEBrA8SWxAHm6IFrvLg4lm7xMTp1NAT1sC5MqEnNQ5VkAhgEdKnzREwbSzR8o804UvO o/bpHVTsJedFh3Onofz2pHMni0qBB/JLhpu7xQifSzUvB7yAGHumUbJ1oxVucBN1Dbwx u7tmV9CuI8sTi9yXNyeK27s89LMhh+50/WiCvJmkbcizbperOUwrcRW+ezEwkeNiwZgV FNYEqJCAfXiLOVD6Qf6HHnodvi+YPVRrZBdLRtykF3x7ugK4eYsjn6KNl36R8s/BAjEV 2gzg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cSspDhts; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-64934-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64934-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCUxP+J5imlbqVDHp3nyXjQ8w30axiE2sh2P7UKqQtv1dMzzvxwgW8B9SdtwUpRz2w/TIdrTeXcxtuB6BGlNY18Xzoka73ryLaIiGWjOzA== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id b19-20020ac86793000000b0042c66a8d6ccsi4617753qtp.218.2024.02.14.01.16.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 01:16:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64934-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cSspDhts; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-64934-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64934-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 854521C20643 for ; Wed, 14 Feb 2024 09:16:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 715421173D; Wed, 14 Feb 2024 09:16:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cSspDhts" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7483A2F2F; Wed, 14 Feb 2024 09:16:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707902184; cv=none; b=Bw28pSwvyRlCfa8+fQEnVHvzhAt3+03MkE0OGM+xQQj3JWvLXMnKkcXWqvmj6PCk33bYHFEarbBHEZjCoZuZSI3gNfHOk/w7maVLAeHP/QREQsc2wV6MWvOkBr6+TgoOQwzTRanBrGk/esLhFT74/n3YCB+Lzq0La24fJ5LL0kg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707902184; c=relaxed/simple; bh=PoGYFcOFFkj9oOeE16Nie+zQv1wodqinpX/UuF65zXA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=dhuloVYUEksn69BNd6Z5s4jHTQAraVDu8AkPWEn8q+dJgKpY9YIptFNJ5K81MyuP6ojhv9b2C1W7xXHA/+VM17Uni/EdQZLogllAaLHgb6saWWnsItvR+Zyh8kg//W/0lD69Z87v0H60eMiziJDfBu1uKUossg2TiPReBuTdaGc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cSspDhts; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CE697C433C7; Wed, 14 Feb 2024 09:16:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707902183; bh=PoGYFcOFFkj9oOeE16Nie+zQv1wodqinpX/UuF65zXA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=cSspDhts8XThLBU3SI2dYn63nWVUKuUwLCiIYS6E01ECt1s0v+6zlXix2bO1hm1z5 24ny+psf5PHItrEDLL3eAa9T8OhXKVvbJ9Zfr0FBCKtO/QenxM6ZjzhsvaNnlDO+tu JOuDmSfme2BKqexzspU/16ykdI6ZVP65S4DbqWvsAouCc2CdVJwtlNkAhS2DDidsY3 HnIsSKYeATcGyk3qraYK1GYnxlbAfo9dF0bvRznPoeC15TZ/XtPrOaMOQdykOtPoO6 yXbz/wOPhPXqfecKlhRasNayhLWK4X5dl7KlVQEGlLWGq+shZQhtKrA0mPvqf1KXYm kwTIoIGl6WwXA== Date: Wed, 14 Feb 2024 11:15:56 +0200 From: Mike Rapoport To: Dmitry Baryshkov Cc: "Aiqun Yu (Maria)" , Vijayanand Jitta , Faiyaz Mohammed , karahmed@amazon.de, qperret@google.com, robh@kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, robh+dt@kernel.org, frowand.list@gmail.com, devicetree@vger.kernel.org Subject: Re: [PATCH] mm: memblock: avoid to create memmap for memblock nomap regions Message-ID: References: <7b18bea8-b996-601d-f490-cb8aadfffa1b@quicinc.com> <42f28e7b-c001-7d01-1eb6-fe963491898e@quicinc.com> <22aca197-8d18-2c9e-b3c4-f6fdc893ceb1@quicinc.com> <76cb3b37-5887-404f-95b7-10a22a7ba65b@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Wed, Feb 14, 2024 at 10:11:40AM +0200, Dmitry Baryshkov wrote: > On Wed, 14 Feb 2024 at 09:44, Mike Rapoport wrote: > > > > On Thu, Feb 08, 2024 at 02:37:25PM +0800, Aiqun Yu (Maria) wrote: > > > > > > On 8/6/2022 3:22 AM, Mike Rapoport wrote: > > > > Hi Vijay, > > > > > > > > On Wed, Aug 03, 2022 at 04:27:33PM +0530, Vijayanand Jitta wrote: > > > > > > > > > > On 5/9/2022 5:12 PM, Mike Rapoport wrote: > > > > > > On Mon, May 09, 2022 at 04:37:30PM +0530, Faiyaz Mohammed wrote: > > > > > > > > > > > > > > On 5/5/2022 10:24 PM, Mike Rapoport wrote: > > > > > > > > On Thu, May 05, 2022 at 08:46:15PM +0530, Faiyaz Mohammed wrote: > > > > > > > > > On 4/12/2022 10:56 PM, Mike Rapoport wrote: > > > > > > > > > > On Tue, Apr 12, 2022 at 12:39:32AM +0530, Faiyaz Mohammed wrote: > > > > > > > > > > > This 'commit 86588296acbf ("fdt: Properly handle "no-map" field in the > > > > > > > > > > > memory region")' is keeping the no-map regions in memblock.memory with > > > > > > > > > > > MEMBLOCK_NOMAP flag set to use no-map memory for EFI using memblock api's, > > > > > > > > > > > but during the initialization sparse_init mark all memblock.memory as > > > > > > > > > > > present using for_each_mem_pfn_range, which is creating the memmap for > > > > > > > > > > > no-map memblock regions. To avoid it skiping the memblock.memory regions > > > > > > > > > > > set with MEMBLOCK_NOMAP set and with this change we will be able to save > > > > > > > > > > > ~11MB memory for ~612MB carve out. > > > > > > > > > > The MEMBLOCK_NOMAP is very fragile and caused a lot of issues already. I > > > > > > > > > > really don't like the idea if adding more implicit assumptions about how > > > > > > > > > > NOMAP memory may or may not be used in a generic iterator function. > > > > > > > > > Sorry for delayed response. > > > > > > > > > Yes, it is possible that implicit assumption can create > > > > > > > > > misunderstanding. How about adding command line option and control the > > > > > > > > > no-map region in fdt.c driver, to decide whether to keep "no-map" region > > > > > > > > > with NOMAP flag or remove?. Something like below > > > > > > > > I really don't like memblock_remove() for such cases. > > > > > > > > Pretending there is a hole when there is an actual DRAM makes things really > > > > > > > > hairy when it comes to memory map and page allocator initialization. > > > > > > > > You wouldn't want to trade system stability and random memory corruptions > > > > > > > > for 11M of "saved" memory. > > > > > > > > > > > > > > Creating memory map for holes memory is adding 11MB overhead which is > > > > > > > huge on low memory target and same time 11MB memory saving is good enough > > > > > > > on low memory target. > > > > > > > > > > > > > > Or we can have separate list of NOMAP like reserved?. > > > > > > > > > > > > > > Any other suggestion to address this issue?. > > > > > > > > > > > > Make your firmware to report the memory that Linux cannot use as a hole, > > > > > > i.e. _not_ report it as memory. > > > > > > > > > > Thanks, Mike for the comments. > > > > > > > > > > Few concerns with this approach. > > > > > > > > > > 1) One concern is, even if firmware doesn't report these regions as > > > > > memory, we would need addresses for these to be part of device tree so > > > > > that the clients would be able to get these addresses. Otherwise there > > > > > is no way for client to know these addresses. > > > > > > > > > > 2) This would also add a dependency on firmware to be able to pass these > > > > > regions not as memory, though we know that these regions would be used > > > > > by the clients. Isn't it better to have such control within the kernel ? > > > > > > > > If it is memory that is used by the kernel it should be reported as memory > > > > and have the memory map. > > > > If this is a hole in the memory layout from the kernel perspective, then > > > > kernel should not bother with this memory. > > > Hi Mike, > > > > > > We've put effort on bootloader side to implement the similar suggestion of > > > os bootloader to convey the reserved memory by omit the hole from > > > /memory@0{reg=[]} directly. > > > While there is a concern from device tree spec perspective, link [1]: "A > > > memory device node is required for all devicetrees and describes the > > > physical memory layout for the system. " > > > Do you have any idea on this pls? > > > > I'm not sure I understand your concern. Isn't there a /memory node that > > describes the memory available to Linux in your devicetree? > > That was the question. It looks like your opinion on /memory was that > it describes "memory available to Linux", while device tree spec > defines it as "physical memory layout". I suggested a workaround that will allow to save memory map for the carveout. The memory map is a run time description of the physical memory layout and core mm relies on availability of struct page for every physical frame. Having only partial memory map will lead to subtle bugs and crashes, so it's not an option. > > > [1] https://github.com/devicetree-org/devicetree-specification/blob/main/source/chapter3-devicenodes.rst > > -- > With best wishes > Dmitry -- Sincerely yours, Mike.