Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp702409lqa; Sat, 27 Apr 2024 23:35:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVwaeClax1BVWnFuSHjnmzz/7cjhKZngWA5okE6oN0pv8SUjXIrVgQa7Cz2RDmzxQ8/Ydrc46Q2l2n/3Oyx7zIdRfwGzA7nk+nWPmUG2A== X-Google-Smtp-Source: AGHT+IGEtGHFK94hc54+O1rVfFKlUSykTq2mCrh5bNuruh74By5VaI30LcWA1vlCsNzMj2bWl7/P X-Received: by 2002:a17:90b:3d86:b0:2af:4f4e:79a7 with SMTP id pq6-20020a17090b3d8600b002af4f4e79a7mr7032299pjb.30.1714286114682; Sat, 27 Apr 2024 23:35:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714286114; cv=pass; d=google.com; s=arc-20160816; b=T1hvY4cDRMwqAPoY/HrcTCnAPOqbFYsKNFhntTbyMlbopoJXhziC0nd4k4rYoB0PgW +8aqRn5F5krYj7AOt9HIpZkAFqH2cb0o8oqps4ZqPgQwDj27sNBQ5iek5XJnatARZQ3A Y6iD7YwXqmoVovORn5X2xcqo5dsQZiSANqxfc5V28htYBudpaCBwZ8iSFHOSsdEBcW6O npC93DfBWShc2pmQlNO41ESLxD3uRF5ps6sH5DzX6dbP0tiY+IFUzyk6ZVmPqI+XvVcX h7bSVTZsA2pklId2VblLoU/DAi+JgqhK1eLj0R44D6yRQYoC4zJdgK6MhWFCRz9BlpGX VRYA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=/rehWXDbrDqU2i0HtTtHjlpE6sUQIdUPiwbyK7CIlaI=; fh=dCmvRD8QZ+oB4zwFLVkiv3/Bm/R8FGsEQ2nLZVNz7Lk=; b=HwTvhNqT2ICnJEAmKxU7KSsY+W35WKdPsXHEf4qxsknFS7tHfyxg5TIMSDyQTc/1QB BjtKxZV1l8EF5YgEBESEHAAz+HWteY9tNio+JPnyxUgLG0WswkJcvQOEr5Z0nafBjMsn Zye+o5ilxs5KpL9oM+eX5FqsdaycAIYBUUesG8gd+dIRuAO/N4M9iS2xKXbZb08rGNsq TbDEYeM+YO6z5zAI5Q7V7qTu1YO44RRjsQJNyX26EtD7AQ2GUxEmdRMKLRHvxf7Oww/g Ph7/05SIMrW0PeRtKraQ4pld7rwDKoE3FY+GmpvqE+bOIik3c0DNIz2dXhrS6Qwo6VWf SwoQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NFnNagcm; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-161288-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-161288-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id w23-20020a17090a8a1700b002b0766e065fsi3957591pjn.35.2024.04.27.23.35.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Apr 2024 23:35:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-161288-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NFnNagcm; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-161288-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-161288-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 542E42826B9 for ; Sun, 28 Apr 2024 06:35:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8D3524EB44; Sun, 28 Apr 2024 06:35:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NFnNagcm" 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 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: linux-kernel@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.