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 0F8E5C4345F for ; Fri, 19 Apr 2024 01:46:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 513C06B007B; Thu, 18 Apr 2024 21:46:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4C3BE6B0082; Thu, 18 Apr 2024 21:46:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 363E86B0083; Thu, 18 Apr 2024 21:46:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 179E86B0082 for ; Thu, 18 Apr 2024 21:46:26 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id BF16414011C for ; Fri, 19 Apr 2024 01:46:25 +0000 (UTC) X-FDA: 82024591530.28.6FFAA47 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) by imf03.hostedemail.com (Postfix) with ESMTP id EA2BC20006 for ; Fri, 19 Apr 2024 01:46:23 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=BvxT5HWt; spf=pass (imf03.hostedemail.com: domain of skseofh@gmail.com designates 209.85.221.52 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=1713491184; a=rsa-sha256; cv=none; b=hBNmNt4y5nw9g0DCrLmXgT0cK2AJo8zPvOF7mQl+j7h7QVDXoP6hDJA3FyB7Hv1BdVwQaT C6tTXTrQEx6mb/hhf/XFltg0gSqvofNq0ucpx6JU55z0eUSkrBhutQMQ1Q3UJs4Q4zYoHz Vi9Sw6Td4w+9+lePsqLZqshaGerSVio= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=BvxT5HWt; spf=pass (imf03.hostedemail.com: domain of skseofh@gmail.com designates 209.85.221.52 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=1713491184; 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=nhN2ooBVErN5htWBuXgzgNQ9MRrVRm4yKvVjJ6Nzxos=; b=oFET5s+eDRqejTTMXfs5Lj8l76Vvxzd3NnUlNkM9KFwIRPylyBsOjgsf/MlMHkCNibhez0 LTR5oGImLGKqVB4VcLl4z7hRHoK3dw1UsWv7TcTaxzHjmfEr1lkvzU6zCyGwK9t4yBo2En bSnSf77OO6gul2k8RJFyw/hlWQSsmNI= Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-34a4772d5easo441244f8f.0 for ; Thu, 18 Apr 2024 18:46:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713491182; x=1714095982; 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=nhN2ooBVErN5htWBuXgzgNQ9MRrVRm4yKvVjJ6Nzxos=; b=BvxT5HWtKwDmW6gTJVmHacRdGPO1UVzUHi3PkeaWoMLVEWVSvegboX9FelypIdUQ+o 7F1kSQRyWKL/tN26ZPoeJI+WcWQ3gasgnNPP1AznkT92RqEf5F5Nvlx4a/pKiaoDuM/K /U9cpF5LoqUrS659Z1WrleboDPqiilQeovGqIQxHJLPSm4xYuw3PO05yUScJaZzcqGBs hljIcS/77Zw7nrsmiDCOJEMkj3Kx0GZBgX9oICNH1KEKK6iAFZBemhlg/6XGd1abB37Y faN5RUVpSBFXvW5UcVY6lttQvjMPY8hf2pmwi5diMb0sthofkqwiWNvYRBXXa0MNfJq1 eIkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713491182; x=1714095982; 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=nhN2ooBVErN5htWBuXgzgNQ9MRrVRm4yKvVjJ6Nzxos=; b=H9qwTw5ofLnJdj94UWnbAWjyhqDnfiO/kdpeWsX4thKGdB3POS5VhyEKJk0v5GpOb9 uc9AsDOnKB2MVKEPwZDVrpRuLp9TurWPGPr1qf9eRsONZJiaIiMt7ayPL0nmV7KUwaA7 t/5yGFh6Bc7l2bN2VgWdg+jf6ptnUrLC1wsbaRrUnAsB2oFqNve/BTHIYZI2B+whifa+ f2F+4j4ZWZxvDQT8CAqEQhpyFAM5pLcV/l9GrUL1wauSjEZdfoHvjIl1UvNCXlbF6kk+ QRQoknT+KOlvnZCsvwnUtsP7XED4ozNJZuS3M9cjhTfCsf60Ptu7JpWOzJ4K6lCrNpGd Zb0A== X-Forwarded-Encrypted: i=1; AJvYcCW98YIb2DvxGm3kRtMFGVdpD/wKYpmCkgnISjHWRLkivsVAmBLag7+R85eMFZFFZwKvyR7iRmaUHYmxgmNnUoEKzWM= X-Gm-Message-State: AOJu0Yyfc9I+9rBsXG2okcVu82rFGraf6HEMS7oM6wl0kO1RWhPskKAV G6Fw0ZlD4Lo6bPdqhkjdq2I0G72BvkmCqudZuHMMtdSp9Rzrjdzb9A7ziavvm2hEcR/um+XqFC8 S3CH/QmSpJZ8hbI5okPJyMPxAlo0= X-Google-Smtp-Source: AGHT+IGMM6WvEeHCFsP0durYALfdmEcqAVN7qtB7KCkQGpoHepqjoPVrIuLoFwp9cfouiTjqt/vPONXazz/nSwS3fao= X-Received: by 2002:a5d:678e:0:b0:349:d7dd:9e4d with SMTP id v14-20020a5d678e000000b00349d7dd9e4dmr284626wru.48.1713491182132; Thu, 18 Apr 2024 18:46:22 -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:46:10 +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-Server: rspam03 X-Rspamd-Queue-Id: EA2BC20006 X-Stat-Signature: weuswc6nnwxiyeghkbza37eqq8esih1y X-Rspam-User: X-HE-Tag: 1713491183-705251 X-HE-Meta: U2FsdGVkX18LmAjTf1KYklRXzudFjXhu6Fbhi3NvAjAvOMpwV6kIVfxFICaeW76fwA8eZmCifYp8AKR0HVshwD7CaTmAkhSb9PE1gkBFLm1fDFfKbP5QZo/U/6sEte2oKkPvX7G7FLHWEDjJiGSow48l0aRpgl+JR7axK3ZhJrFqd9YYzWAw3LehDkxAYwCX2cgGYX1VCPOy28+rN4RMn3PgQXn/xChD0IB3qtVFSvnatp1w4NbhrPai08Jt/Qn64el2JKTETu399v0ZLzFi2tofxJDI9goT2YMsXePLNtOayBnUBcB7Omal9ZnCvdbt760W/Lv9sr6LjS9/YKTVILuPNFUp+vxGQesOwfpFEsEoZ8J6JzGu2snntV4lja/WpskCC1LHETuDfZ5+cd5myzzHgRYXD5IsnbDS5k4V/hz2TEyb0dFZOMavQjAlqZGbvug5bg0pfOqwmTo6e4W7kqzwOdYb24ZEC0jqNRqToyXpLcltq0sFCs6v03r6WFeE++8csQB8QD0Ufe87xYxm/0BFAlec+5kf9JJhPEBqPo/w9mS9w247aHL0I66kABMO5xDlhDWNue1h2cmbLoLt5vpqmpuNAClV95TsTY4yf/KBMkt1W0+36LmnkrzgKXCiR2qoboiJxzuroy8nwn7IGZQgwNNW+uQvWwk3HsVaHbX3X2G7Zgyx0dT3kIP7lUleMK8wPkTSRVSeGrxaNLvXbocpp9dvvj2EEo2xCwZRLbgg3v5pnj+o8qiQy00GJjrKGEhgSLUJmFF8DBmG0Ivq+UnoYdlP7lO9LzD8g4RUijvlMHpClsqB5DPe6it6dsWwwoWVCXgg3QKlB/AZnljXY2UmQX9DeohFaZ/tTGApuT77YHNlngl6f5DbjIvACqNgPIGHXE+9mXGijyvxFNGyxCE3RXXxwfR4n/86V69CjoW7bpm8blIbfRNaj02ECkhSmDg75w8rwGaE9PLz2fr 42dIOUx4 lfq3KXdgRy+exwJpWSm/iWBsmYDq0xbJBDBl/QSOEzGxuWGO66DRY4ipdqETFDW9BqhW7KazDPtgAWMt5H0sHV5oW30tv5PZoUGOjm4wXlytF36YrAgbyLvTX+USF7fX6JLc1AEaA0lCil1lUhm78jirgZMEn3kAgRQ4kBDjnor+AV7hhhta4pOHdFVYTpS4vyyE6Xsbb2XYJRTlX172MsQ93tJMfAmxGGPy292x9tC/6bsaWnnixgOI2zXNTs0xZVO/TsjL56utvnSYa/lqxrhpSYWf6y4iWBdLntcVGhE4w4+MlC6nJNKV1OqoqrEj9xYHKybHUIStd71+L8l5NlIQu/Nv6jJVJd0LTrPr3qKZoI1wWbt8T0NGfCla9CjJoPfGTSmfm76V+FBfrM6vklk+yp1WolPAEwYL9/EFz3RhMDYjlpGK2g+scheWLFQ3SJgFP4DGOUQ4Oe1I= X-Bogosity: Ham, tests=bogofilter, spamicity=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: 2024=EB=85=84 4=EC=9B=94 19=EC=9D=BC (=EA=B8=88) =EC=98=A4=EC=A0=84 3:04, M= ike 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:0= 3, 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' pro= perty > > > > (w/o 'reg' property), there are memory regions need to be allocated= in > > > > memblock.memory marked with the MEMBLOCK_NOMAP flag, but should not= 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 that= 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.re= served. > > > > > > > > If you have a region that's _NOMAP in memblock.memory and is absent i= n > > > memblock.reserved it will not be mapped by the kernel page tables, bu= t 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. -> 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