From mboxrd@z Thu Jan 1 00:00:00 1970 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 ADCB84F896; Sun, 28 Apr 2024 06:35:01 +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=1714286101; cv=none; b=g8cS6UV9bhU9XWWHAx/gFOG4GXbR8+ieu1+zhUFI3JsO6FRbKnQTh5ESzao2lmgCdLVgW0aJ1xUQWaJ8+hZ+mbrqZckxvLyUsh+hXNVEpGaWjtpZH7Srr0C3rzhGPRu47falJlISxzfOeoDMIDuOcc/Npku8ht3Bdy2Ar0IyYQY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714286101; c=relaxed/simple; bh=gGXNhBbfImPeZnJs87jnNoO7ISenhcnpz02YU249uJI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=s+zV0Xqof0yQ0g5d0oTY3GjQ4ctmDruxcaMl7ESuJeCyzYQqSpDnUs0bhF6Fau9MYqyUCK+J69RIHzMoDMj/IcFm49jG0vE6UbzhME5faQqsvrdAAQ+7CdaX3Pu66fKOtWBBtmoR4/Gwj+iIUTjYd2uN4WxZ8R4Of3f5JO3dasU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NFnNagcm; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NFnNagcm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7F36BC113CC; Sun, 28 Apr 2024 06:34:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714286101; bh=gGXNhBbfImPeZnJs87jnNoO7ISenhcnpz02YU249uJI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=NFnNagcm6mwvKrWAK4nCHAx6kZP7OMn+eXbymaE2qzgfL4Eu8FRe2T3I2o5JdVegP SD+p0sqUzMfMlmdlyCUiRSvlu7sziirtS90CNFYqI9+290U7IwdUayxgDEtu20Je35 chLVzrmtTYJDuVqj7n1woEfj5ao7LxKO4Gv+qscR8QMxoNHRqfaXbQbA9gPM9nhNfd 758bwHgWD1/eAXRXc144oEDdiES61AhWwPyOjVIATkyyE+ykbmb6s5SlfLmUS4O4I5 joKnhpTwp9ZbJtaGD8z95Zn3hZoTpsnU3RlxEFrUmq0kxoTqSko/jbRL8uaElRsbXY 7DWpWP27KBt/g== Date: Sun, 28 Apr 2024 09:33:37 +0300 From: Mike Rapoport To: DaeRo Lee Cc: robh@kernel.org, saravanak@google.com, akpm@linux-foundation.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Daero Lee Subject: Re: [PATCH v2] memblock: add no-map alloc functions Message-ID: References: <20240416120635.361838-1-skseofh@gmail.com> <20240416120635.361838-2-skseofh@gmail.com> Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Sat, Apr 27, 2024 at 07:24:23PM +0900, DaeRo Lee wrote: > 2024년 4월 27일 (토) 오후 5:50, Mike Rapoport 님이 작성: > > > > On Fri, Apr 19, 2024 at 10:59:52AM +0900, DaeRo Lee wrote: > > > 2024년 4월 19일 (금) 오전 10:46, DaeRo Lee 님이 작성: > > > > > > > > In memmap_init_reserved_pages, we mark memblock.reserved as > > > > PageReserved first and mark the memblock.reserved with nomap flag > > > > also. > > > Sorry. This is my mistake. 'memblock.memory with nomap flag' is right. > > > > > > > -> Isn't this duplicated work? (If we add no-map region to > > > > memblock.reserved 'and' mark in memblock.memory..) > > > > So, I think that for the no-map region, we don't need to add to the > > > > memblock.reserved. > > > > This is what we do now in early_init_dt_reserve_memory. the nomap > > > > region is not added to the memblock.reserved. > > > > > > > > In early_init_dt_alloc_reserved_memory_arch, if 'nomap' is true, we > > > > mark the memblock.memory region as _NOMAP. And if the return value > > > > 'err' is not zero(which is '-ENOMEM' from memblock_isolate_range), we > > > > free the region. > > > > - 'nomap' is true -> memblock_mark_nomap : success -> not free the region > > > > > > > > : fail -> free the region > > > > And it can be said that we add the region to the memblock.reserved > > > > using memblock_phys_alloc_range and if the region is nomap, then we > > > > can free the region from memblock.reserved. But is it necessary to add > > > > it to memblock.reserved? We just need the region in memblock.memory to > > > > mark nomap. > > > > > > > > So, here is what I think: > > > > - reserved-memory w/ nomap region -> mark only to memblock.memory > > > > - reserved-memory w/o nomap region -> add to the memblock.reserved > > > > NOMAP and memblock.reserved are semantically different, and at makes sense > > to have a "reserved nomap" node in fdt recorded in both memblock.memory and > > memblock.reserved. > > > > memblock.reserved represents the memory that is used by firmware or early > > kernel allocation, so reserved memory in fdt should be reserved in memblock > > as well. I believe it's an oversight that early_init_dt_reserve_memory() > > does not call memblock_reserve() for nomap memory. > > > > NOMAP is a property of a memory region that says that that region should > > not be mapped in the linear map, it's not necessarily in use. > > I agree that the NOMAP region should be added to memblock.reserved. > > So, I think we need to clean-up memmap_init_reserved_pages, because in > this function we call reserve_bootmem_region for memblock.reserved and > memblock.memory with nomap. We don't need to call > reserve_bootmem_region for nomap. Read the comment about memblock_mark_nomap() > Regards,. > DaeRo Lee -- Sincerely yours, Mike.