Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp308041lqa; Sat, 27 Apr 2024 03:24:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVrtAKTX+qenUZpsLS8TdYghb3dfZtwwgys6VdPyYnRSBhiIRzSZlPoLGQZ7qi028uRo8i/8aoFgBEJd6IRt8+Wr2+2OWXzDBJkhEFT7g== X-Google-Smtp-Source: AGHT+IHI5SDGoUbz0jJ8AWA34bpi9pHOpJeXdlAj0i+Vdyr7xkr2vjHiryz2io/rCd5sqTHxUgRw X-Received: by 2002:a05:6a20:158f:b0:1ad:7f8d:1235 with SMTP id h15-20020a056a20158f00b001ad7f8d1235mr3245370pzj.13.1714213486042; Sat, 27 Apr 2024 03:24:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714213486; cv=pass; d=google.com; s=arc-20160816; b=GpQjqWU21QusGBpApMvkannyxzwAKEwU7tY6e5vVJAuG6Pq3Nomuavdekc4l1uru72 KRuSmv5m8pjBM1mhpydcNM6ljvzmEJZ5HHwT2iDttVJIbZtSld5mz5WrBIJ6uYWA4bLa Dfftf32mZdWl0lCnVHCsVwCTuHlD/wr1oipz51mQ6m2ei9ZnMQIWsZYaxcpxkvkWKPdS mMxXin7EhmPz4k+wEYOhae/PCfUSMVKdQj7CsxxFyfjhgnWz9N2jIgP4cRqSbB6rix82 X3T/AY6LzgKJq8kzi8TUPrzgjNVZVtgC1jqAsyXOJ4qpMyls2qgxO0zttCFoBx/p5vlk zOKg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=l2oCs009FNTFic+6/Bn8POOKtUyuT0t/au2Vi8nWiyk=; fh=leBbtBX8hjBNv6J1vRqt9iBfde6YyWLdHfID8eZwPQs=; b=Cmqk+NCKxJQQb6HtU9Kg8yxv1TGWyRs/4yqnlPtOav4xW7AIP821HUAlr/HtN7VfXr vJ8U8ktFdfIrLMCUwEEm0fpI9zewNthJiWbyhenfsZUQDuJHCRxnoRFSy5jT8zcAF1Wk 7D4/LrPY8HZhai30X77mw5bsq1ZQA8mkV/d5SJtM/vkKTFQTYDJvjQcb9t1BLfBbGQ87 vKUTWbjqlC7RlIMZYFj4MH77hDjrDL9VZ84fgzghriuRSIIwxEVVVZWVS/EcnjCiH/j7 q7SMSWbAmOitBF+ljl+9wEIFgOdq+s3eoXyIKWaZ4ur77EfDh/HKGBmUCDJlEnfQef7V daxA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=EDFe72rW; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-160991-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160991-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id g38-20020a635666000000b005dc8a59e303si16228808pgm.111.2024.04.27.03.24.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Apr 2024 03:24:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-160991-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=@gmail.com header.s=20230601 header.b=EDFe72rW; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-160991-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160991-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 A614C282E7A for ; Sat, 27 Apr 2024 10:24:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D3EA3481D8; Sat, 27 Apr 2024 10:24:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EDFe72rW" Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7BFDC44C8B; Sat, 27 Apr 2024 10:24:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714213479; cv=none; b=DX6z/zxDBLUyoki9+DAtEmXlPfDxhR+FdimH/jWfHXaIB2ibPQQQF7KXcO+CFpu9ACdShobMlAIkBCt4ArLF8CWgkn4AAvDUaYeKXKxMB9xjC9sD5oC4exeQpFgXasMnnlDUyxjTNNm0mQf6fKgVrst7Qakh+9jqRepoytWcS9I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714213479; c=relaxed/simple; bh=l2oCs009FNTFic+6/Bn8POOKtUyuT0t/au2Vi8nWiyk=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=BqFlsanCn+ALH/HyVdp6VF/yJhQCI1im7cv5XsTRnQe1dNw3FEwoCgy92RMRJZPNsWEoNnF4R8aMiAlQPM4mQK1fgUezcfmbcJQQNqf1ybp4zDm8TLeyotM65QUV0iLTPgbsUTZ1Spt03kVUTcwfaNKm4I7ua+P6wRWOdNTFpVo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=EDFe72rW; arc=none smtp.client-ip=209.85.221.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-349c4505058so2158466f8f.3; Sat, 27 Apr 2024 03:24:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714213476; x=1714818276; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=l2oCs009FNTFic+6/Bn8POOKtUyuT0t/au2Vi8nWiyk=; b=EDFe72rWHUOT/z5QCFJznssUdeFLdS6GBnSg3ouPbn7X5YggRAkT5vtsoP4Mch0u2c iRPdEEDf20/0SFKYVerR52w5LvkoMtcOjvMOLgtm7gkJUBSawNKuCfbCBOBwo2kjHGv5 cPRU6BjS55Ki5wOYRjdbwYy8e9m3nN3td2BTvbZ3c0pY1inYIG/CZMz6faEryE3bM+Nw DziI8qvs7t6sMYwZcqQEKhdmcJg3NMZ3shUMaNshLoZyZZJt9tAW0D+JpS/CJ6GVWjng +8hpVajPc8YFr+j4hl0fDIZUFe5MH7it5FaKY4Ei6hCve/s7z1I8Nzof4M/9FLBRYa7D bCYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714213476; x=1714818276; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=l2oCs009FNTFic+6/Bn8POOKtUyuT0t/au2Vi8nWiyk=; b=pBRuWj/wqhV30NCDcA8lSgy8u4T4mqrb2+DEFvk9BmIAwP6r01YEwluIwZmKo1gnOA 0kyZD1lfGgjRO5ZbFaWMBNU3/NYOiPB4hWJO1eeSqaUqPH2pIIYyuWps+Z8J5xTjoex+ wR2J77q5nUhYdf+6KbQfj+G/TMIYAuqZkHi+n5HXeNwzwPIAhhXKBflwvEe1FgYGnQbo GExyddLyAj7qrwD1A77/a5ZsQS0naSQEHqOiUoJ1YXLqBkqBqOIOZ8Th7jEvzFMFiqpE 1FQGcwlAmzi1cnZoJU+O+/IHoO9QGmgMSfTrt7bGSWLGg4B6UMMMRwlDzMjuSVd7VmUt +/lA== X-Forwarded-Encrypted: i=1; AJvYcCUT2f6rP0ybfMeml4V+OKKPcDfEWPAOJ0Bb8KiqONouUpQh8SBG21cRef3WI40zBIquGZvad9UABBfllcFq2ZLsBeUZ6AeAGRNIsnW/0gNV0tgztJ+5waqE+vTj3aN24a9YJutEcQNaWw== X-Gm-Message-State: AOJu0YwKmisxhNUY+tAzttEJ4nfn6jTtKlDWwKbAoSe2vK+7xcmBJ2Nx XehRb+X1pWE8sz9tYWhvmD/TR0qrdjwOMtLJQV6d4fIEkdSm0jgKRemb0ILvGEG+/wF/XaM8Uet d76+EPmGW5aUlEacgF/mavyFU0vM= X-Received: by 2002:a5d:58d8:0:b0:34a:1cc5:ee0c with SMTP id o24-20020a5d58d8000000b0034a1cc5ee0cmr312655wrf.26.1714213475436; Sat, 27 Apr 2024 03:24:35 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240416120635.361838-1-skseofh@gmail.com> <20240416120635.361838-2-skseofh@gmail.com> In-Reply-To: From: DaeRo Lee Date: Sat, 27 Apr 2024 19:24:23 +0900 Message-ID: Subject: Re: [PATCH v2] memblock: add no-map alloc functions To: Mike Rapoport 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 2024=EB=85=84 4=EC=9B=94 27=EC=9D=BC (=ED=86=A0) =EC=98=A4=ED=9B=84 5:50, M= ike Rapoport =EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84=B1: > > On Fri, Apr 19, 2024 at 10:59:52AM +0900, DaeRo Lee wrote: > > 2024=EB=85=84 4=EC=9B=94 19=EC=9D=BC (=EA=B8=88) =EC=98=A4=EC=A0=84 10:= 46, DaeRo Lee =EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84=B1: > > > > > > 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 re= gion > > > > > > : 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 ad= d > > > it to memblock.reserved? We just need the region in memblock.memory t= o > > > 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 sens= e > to have a "reserved nomap" node in fdt recorded in both memblock.memory a= nd > 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 memblo= ck > 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. Regards,. DaeRo Lee