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 5BC0BC4345F for ; Fri, 19 Apr 2024 02:00:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CC0D96B0083; Thu, 18 Apr 2024 22:00:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C71466B0085; Thu, 18 Apr 2024 22:00:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B388F6B0087; Thu, 18 Apr 2024 22:00:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 967B06B0083 for ; Thu, 18 Apr 2024 22:00:09 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 42222160213 for ; Fri, 19 Apr 2024 02:00:09 +0000 (UTC) X-FDA: 82024626138.19.998B330 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) by imf02.hostedemail.com (Postfix) with ESMTP id 2733880008 for ; Fri, 19 Apr 2024 02:00:06 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Orm2K7H0; spf=pass (imf02.hostedemail.com: domain of skseofh@gmail.com designates 209.85.221.51 as permitted sender) smtp.mailfrom=skseofh@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713492007; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=myK5cv7xJ6bkxPtg1bm9hdmjPYBSUqgEBd63LDUYwz4=; b=arN49RE2zcW36mugiH44+Pyst6sROXl2ALSbaZ2SyAeCbvNkGHj6hU5Isg4EMPbjcd7M/W 6KpxKRVegCv0X9pzR6Z2RijdvkSF5lt5cGnCpx2t0yIfN2ZIvgFZHizpjzgY72Xig56z1K z62HgCdII8S94SZQyJ+9L9xPYXn9iFo= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Orm2K7H0; spf=pass (imf02.hostedemail.com: domain of skseofh@gmail.com designates 209.85.221.51 as permitted sender) smtp.mailfrom=skseofh@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713492007; a=rsa-sha256; cv=none; b=a82BQCvcYVoLMw+w+1TQGPETfgqzKM2vcbyV09HEBXxH9N+NVpRIAOQ/6WqsABgcCvtbMO EWbOHTVqoTxDXkg6b2tGvEaautHBjAIFSjgpaV/6dRUSmpjBjS2b9Hdr3hb4/ObykPFChY qVjr7j+gsO1o5pBsTALky9Mo9QyqiUk= Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-343f1957ffcso855191f8f.0 for ; Thu, 18 Apr 2024 19:00:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713492006; x=1714096806; darn=kvack.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=myK5cv7xJ6bkxPtg1bm9hdmjPYBSUqgEBd63LDUYwz4=; b=Orm2K7H0whatibuyQ/5sXCpVS+6dN7k567QQCnkVukTBeJgJ622O2ZfD8LqHkrwvtV 70HT9Cnkg3NyGmXWoYsU7Vv3Emxx/FmLIR6FnScQQkmNZAR0xhfAEcTpRvo8N28GXpke UoZA2Jf8y+xfM+79K7dZ7NUFxjm5QWjHzGd1a/HCidMabZGHI5qShyYmQP4jNNovSsDK tm3MVveGoLXt32c+Pe06Vw3O8P0HeYZ+Ann7YOG6egloQApavF294XvkGWDWI7WoYKZ3 niNM6oR12+DcxvvmKy32FD6yysyGvRfjo3wo5/hMdikzbUmIr+TsW8q/t0kaLnBm5vOr 9SNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713492006; x=1714096806; 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=myK5cv7xJ6bkxPtg1bm9hdmjPYBSUqgEBd63LDUYwz4=; b=cf55a33d1a0DRye39ZjJ7VOP18TwR+EIfvm9PoegKwFu87RWnEYl8w4tpqkr9zfqZy 1KTpo7r/c9+2jhclEDFLdOn9tGxlv+b3FfVl3bXBSYce9oWBIWlVEe0vUF3/IDO5QfgI l4PTQ32mdDbDjkfx9oUK4YvrKGknq1RJFYIG0eAnRi5kUdBeq1sGg5QSUimt20iml9oD lENtOPExeeLpMPD5VWDlOnzLwPUW31FX5EFnHj7Izv6Rfgmb4/a9gOalyBn4jqhVYKPN vBIpFX5GHSTfx0aVC5EGBRsKrhK4/Q5vLBW/6iPIy7AoWsWN2Rb2PyGydToxmqkwwlE3 SCaA== X-Forwarded-Encrypted: i=1; AJvYcCUZNkG1U42wHkDG78/6aOnrsO73cbk4ObSv6bTxRa4cdyYwMWH2af+U9KutRGPQG8G+tB1KbO0xGiWLD+zxmRYpRjE= X-Gm-Message-State: AOJu0Yy9Ik5m5WWv1+VGBTrBAJbByl0ccloLZwxI6Z2k6wpWB5pwE6JR F1wcYuOtNrvf1197uWZsOvT442cqHbzXTcDvPfK40ibLyyVEzidymDeGbiZpeULgeiKyqkrKoUO 1Do8LAyVXkUbtH+xnMEP7yL/SDE8= X-Google-Smtp-Source: AGHT+IHzBB5BE4wkdjBcQa3vtvJxJMwjioX8sSJ6Iq2xnP7W5vs4ebeFf+Ne1PlWH+u4CtNF05ij9hGjddgmpD9xqYo= X-Received: by 2002:a5d:67c6:0:b0:346:46cf:9b3 with SMTP id n6-20020a5d67c6000000b0034646cf09b3mr469613wrw.27.1713492003891; Thu, 18 Apr 2024 19:00:03 -0700 (PDT) MIME-Version: 1.0 References: <20240416120635.361838-1-skseofh@gmail.com> <20240416120635.361838-2-skseofh@gmail.com> In-Reply-To: From: DaeRo Lee Date: Fri, 19 Apr 2024 10:59:52 +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 X-Rspamd-Queue-Id: 2733880008 X-Stat-Signature: f75r7ka4ai5pmha3b4cxb9kdmrwo7wth X-Rspam-User: X-Rspamd-Server: rspam07 X-HE-Tag: 1713492006-924964 X-HE-Meta: U2FsdGVkX1+7zKYt0CYeAbPgsoJJOwvj5wk7mWMmSJfXCjgmfGNvuz0smo1ZldMsI3ZkUYiy3Me6tLIQuWelAEmdKt1CKBZNW8gBAnfoVnm9FBltTdozr6tZwQSlVZUiOy1wONaOx4qUnLLPHfE6iXPkb1JZFOwmaNLNCzz8RprXq79vOqD4AqBgUgrbJD4u7vIQl8A1nhheqjw/7BsejEwhGQUX1e2ztcJL4/nZm/E8M1nkUg/w3E2bd0kwmi2iNEtRQ8JcBeB2ym5VfYZY9lXfl4JsWam/LplijxlgLK/VzEEGGxaeOKcEJzu47HAkp/ffimKPyPrGkvUs+6RqZeeRQd9rpcSW4Xab5h2eYcLiur6L9fhXIcRwjscgTgfrwpFJoptFqGkcRXZ2msQ3dtLFjh/H5e5KqGgEvFgpJBXygnE5mM+/nOTY0nzmOdiXKF6gQV2XwDZ2KPHO++iITLgEpQ3YFcIn+0PnAIRu9NxzuPGLUQ8ZNY0DR5uoFohxM1qOUvGdSQ7Lzo2YCtEwz6wywxAHnZhoxVGPLz7bPu0iP5Kjgj1+r7J0JOb5n32Fx6tjXhY7eBZSdTeM/nTnzu57ktHFeewlemaRyhrwBGJ474WfGoJH/qGiel/FwQOTjxbFLM2yr0tWbUUGGybpAoO+fVR68U4JC7jV4X9och4SrjPR9llxeXiLl0nmrV+wQvfHR9RlkRw4Zc0jI/zN5kfCE7vWNm33w7pfZuYw+elxiMMtlAbgOYvj8JPKTA3Dz8ZfxMjIsiwdnGw0GwxR9P4jHuPfgZ63JLO+DxVnUHHU2TFbwRaBa5k44yZlnzZV/ikGcWntEbrPbaYExdUDdvOzGovEiIs9ceG/44hwgYjRtOaS7b8ECs0BR4CveJCDefIJe81qNLtw6CbS37laAcaBuxVnOtsFrpV3zcqE3/H4LOofmJ09U7Do2kG5CqZhqIkzWP3h+0OPSQ9vMI6 SPB9neYJ +ETgde3ntECPlDG0i5QP43pn6xMEshpAOiQYH X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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: > > 2024=EB=85=84 4=EC=9B=94 19=EC=9D=BC (=EA=B8=88) =EC=98=A4=EC=A0=84 3:04,= Mike Rapoport =EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84=B1: > > > > On Thu, Apr 18, 2024 at 11:54:15PM +0900, DaeRo Lee wrote: > > > 2024=EB=85=84 4=EC=9B=94 17=EC=9D=BC (=EC=88=98) =EC=98=A4=ED=9B=84 3= :03, Mike Rapoport =EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84=B1: > > > > > > > > On Tue, Apr 16, 2024 at 09:06:35PM +0900, skseofh@gmail.com wrote: > > > > > From: Daero Lee > > > > > > > > > > Like reserved-memory with the 'no-map' property and only 'size' p= roperty > > > > > (w/o 'reg' property), there are memory regions need to be allocat= ed in > > > > > memblock.memory marked with the MEMBLOCK_NOMAP flag, but should n= ot be > > > > > allocated in memblock.reserved. > > > > > > > > This still does not explain why you need such regions. > > > > > > > > As Wei Yang explained, memblock does not allocate memory from > > > > memblock.reserved. The memblock.reserved array represents memory th= at is in > > > > use by firmware or by early kernel allocations and cannot be freed = to page > > > > allocator. > > > Thank you for your comments. I used the wrong word. > > > When I use 'allocate', I mean that the region 'adds' to the memblock.= reserved. > > > > > > > > > > > If you have a region that's _NOMAP in memblock.memory and is absent= in > > > > memblock.reserved it will not be mapped by the kernel page tables, = but it > > > > will be considered as free memory by the core mm. > > > > > > > > Is this really what you want? > > > If my understanding is right, before freeing (memory && !reserved) > > > area, we marked the memblock.reserved regions and memblock.memory > > > regions with no-map flag. And when we free (memory && !reserved) area= , > > > we skip the memblock.memory regions with no-map(see > > > should_skip_region). So, I think that the memory regions with no-map > > > flag will not be considered as free memory. > > > > You are right here. > > > > But I still don't understand *why* do you want to change the way > > early_init_dt_alloc_reserved_memory_arch() works. > > 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 > > Regards, > DaeRo Lee