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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 451C4C48BEB for ; Wed, 14 Feb 2024 09:16:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C564A8D000E; Wed, 14 Feb 2024 04:16:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C06208D0001; Wed, 14 Feb 2024 04:16:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A7EF78D000E; Wed, 14 Feb 2024 04:16:30 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 92FF88D0001 for ; Wed, 14 Feb 2024 04:16:30 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 667B040C91 for ; Wed, 14 Feb 2024 09:16:30 +0000 (UTC) X-FDA: 81789853740.30.617DCEE Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf21.hostedemail.com (Postfix) with ESMTP id F2D751C000A for ; Wed, 14 Feb 2024 09:16:27 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=cSspDhts; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf21.hostedemail.com: domain of rppt@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707902188; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=PvXn3dHzGdg4oNIbIRR2XSONs4TuyFtms9dWO5dYLOs=; b=4a8W3qP4dbeG4SedXEaLG+GHzTmP+tYJfftcK3d70xtGulFKi8RjiTUDwab6MLia7ZBbOI e1Ny3M+281x9nb0+n6Wzs+Q2CGQWlkgoZfyGt11SW3zFDtwW6HqlSrokFBWawLA6owjV5q sNApePrUF6kfj5SWZAz9OtF6tukJd3E= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=cSspDhts; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf21.hostedemail.com: domain of rppt@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707902188; a=rsa-sha256; cv=none; b=WhQrZyBDu/siVuc0tvQRSD/mupchOPP8F1LKBpMktBEO4/+967kRL8Yi9GbksRLOC0I6Li OISRpooaYz3+tIMbbh3V6LNLsFqC/PDNZQmmYALbHoNSg82BiSNUDqbsWkgRjtXXOdjGjD 3JHOfov6Qzm58y/rfaYlHDqFZwULtBQ= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 96DC4CE2112; Wed, 14 Feb 2024 09:16:24 +0000 (UTC) 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: F2D751C000A X-Stat-Signature: ynhs5zygjomi6dwg9ja74md88qtnjwdr X-HE-Tag: 1707902187-97022 X-HE-Meta: U2FsdGVkX1/+MBcC4jhaM4lxeTDVd5S49cOMrdXZrAGZtXbwQrwnTa9gJL2RFro3iVmvlScyJRNowxU2SCMlGaTY/OqV4GsCRwky5EoVpNS/1Rk6uIpBsEszXxEjYUu7Cs2c3V/S+zgZGlw5/uVVUWoE02yDb658kcIfBelgXLMt4UhNfNiiWgI14OKzIa1mrsZfmBIgchE4ZCpHKK97UgDdEiPSg5jQuNmEK8Zle3Afw5uLbClVwBpzmRGDZJD+fbDyFE/IEvP1z/rIjPcGBTl3jh6E498lTwclk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ity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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.