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 A64F6C4345F for ; Sun, 28 Apr 2024 10:36:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 05FC46B007B; Sun, 28 Apr 2024 06:36:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 00F586B0083; Sun, 28 Apr 2024 06:36:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DF1E16B0085; Sun, 28 Apr 2024 06:36:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id C022A6B007B for ; Sun, 28 Apr 2024 06:36:56 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 11B3DC09B6 for ; Sun, 28 Apr 2024 10:36:56 +0000 (UTC) X-FDA: 82058587632.02.AA1BA5D Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) by imf13.hostedemail.com (Postfix) with ESMTP id 3BEE22000F for ; Sun, 28 Apr 2024 10:36:53 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Z1ITshTW; spf=pass (imf13.hostedemail.com: domain of skseofh@gmail.com designates 209.85.167.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=1714300614; 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=A3nivpRe23n35pamaYeQ0NQo4GANL/bYE1cAUfQv3ns=; b=J8LIprZtwh6l1cWg+O84J27JgFiainSnCaS36rL7kkCPnt4bPkNxGD34VaTUkS9WshYnlH HyhgVh3f3bC7s81gusHXf+qQizUdan/cKdce6nKakAta4zqP/Dxms5AgQF5ipSV+YntfwW QJnG2sPcPvdr1KwAivDnXk+iGzORqgc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714300614; a=rsa-sha256; cv=none; b=JrgUieS/b5CCv6bH63EKDt3uW1NEJ0N4pw4jk5KRo39ShDK73dnNbKaGow9ZObOXsBxmdm 7ztBR9W6pVjO3wFLj9oB2V913VqEtD5IcRkMf0vydan15OSiBuuatUGvLtqe3H27X0eKzd HAQdqzMBtQs+UPKBC6P5Aa2DkkUifCg= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Z1ITshTW; spf=pass (imf13.hostedemail.com: domain of skseofh@gmail.com designates 209.85.167.51 as permitted sender) smtp.mailfrom=skseofh@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-518931f8d23so3706743e87.3 for ; Sun, 28 Apr 2024 03:36:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714300612; x=1714905412; 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=A3nivpRe23n35pamaYeQ0NQo4GANL/bYE1cAUfQv3ns=; b=Z1ITshTWPUFP8elC3a1XJqwQdKr7lxMKCQSlIHPzkhhdji6Mlg1qpl2zoZ5lNqLQdC bDuF00UzjKTopQfmk69ySXCxXHdiwbBrH+CvmgW1dj8kotB95eOaUmk5yAGmebRDPWdr RcDJHuYlozPrg2Z02LsTH3zl3XHyiN37Y6IHexNKqdrLRyL5xNpYENQZYq28c2tdf7IY Bp1hnrJ4B8PNLjYuXVH7VktcXLuULlKPXRqrT2KdQQEpHKzgcgg3xYQUzz/79HMrnaMV 89vIqerDIM0GlWWSBAhse2IlOIDxr2kiK66Hq2B9c3pwQoP5Vfc0QBoLKFaEgpVjfmhE s7Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714300612; x=1714905412; 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=A3nivpRe23n35pamaYeQ0NQo4GANL/bYE1cAUfQv3ns=; b=fJB++Cs+vqXVDP9nmkHbdDCq+qtF0V6t1voCIsId4w8jdpvg9BZLwRhE7HvEaZGEd8 jx/TjawZqs84ZEylMDtqCAi04EHa8TYderCTJOeoZKlvSLe68jE1goZSv6ID7IslHS6G bm/t5VK0fdjgm7B9382MmflAQ91uRPohRJb6Ndv2aC5ZVWEhSpJLAzle9Ch9gRYb60Wx XgzZmhMP+PYLk1w2G7VgDVXm6m5GxY4drpBwFs4Vzx1vUrvuCxY8k2jA7F3rlss43Nxz DqmEAK2HhurWmqqwYNc1e8RIXqqP0XNir5d8FuoPzW9vl+543DDip20IPv/V6ZnLzKQx LydQ== X-Forwarded-Encrypted: i=1; AJvYcCVcTtoGUqk2PbXO9J1z3BDwV8jLERMLnSOZc2B9l78RVXUc8RbFoGwuTHHhIas25vN8e81Wp5qYT85nZfaQE7S9I1I= X-Gm-Message-State: AOJu0Yx72PJbZINlih7yGk03ojoKmAIaVx94i7emYuIN77RZ0NleQihR cS8XVkfpF44QAw6kfS5pNYalIzixZXjuYJBNCQ0/0bpc76vnZCvyjCVIFDOKBFIW7pzO7xho6an HeTyNnScnH4KOYbqcAGNpRh6vYmI= X-Google-Smtp-Source: AGHT+IH/DaS669Bmyaz9/X/48TD9TThgeNs7jYyoIAffpLAI+oq1Xd0RSZ+Q9R5j/jQkIkEOPbhalxhibL/MZSvUjXQ= X-Received: by 2002:a05:6512:3f17:b0:51a:a400:785e with SMTP id y23-20020a0565123f1700b0051aa400785emr5299909lfa.43.1714300612066; Sun, 28 Apr 2024 03:36:52 -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: Sun, 28 Apr 2024 19:36:40 +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-Rspam-User: X-Stat-Signature: oyxf5xsk81jq8scj9aiwgyu5mckxq13c X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 3BEE22000F X-HE-Tag: 1714300613-428424 X-HE-Meta: U2FsdGVkX1/r8OJhozvRlDBJlsM7EEJp0yMo9xJYeROvoS1ex8cKjixYdUvXdgV6LjKUdSFLHXgt0kZxU1tT76kwcRuvO1znD5oiuRdTObhn75sIGh1Iyc8RAsEUJzn+hAShpR4yRtzWNzNJTXQKew3yYjMHFSdqf9z/F7+unZoSQdUrp+DXNana4iNwQBNxVnPJnG0vN0+QBmwokZdhtj7UrmvjKArr5tDk1zPuY4TSjs7uEQqo05aCGFIG2rie2nuWyJkNwhYutgjauGlyFD5Q4uMpzYn189jBHW4KKpOzDMi30UYKV82rNIMdkvxen0vcO6sTun3ItC/zpd9a44aidsRPyuMQy0bdcZ4t0swWEX2YOaUjij6RTrwIZjDB2Lc3lf6rtb8koYjbrAi9b7mWAsL3IU8qM0z3H99/AQzont7nH9nOkFfFquttk+aBLtH89QGmmyzo6YWpVBd7kqFA9vCCugA5wavw3nm0WzMK6F6j/b6a9oTto/HVSNuoICEZ6s/xrsSH65DlMMvhJzanKbF0Gth2CX+SD2f1sGRtOU5YRK2Lsh7z/s3BkDRaSYOJ4UiKgG14ajPXS22Zf1f+pR3VMOAmU8c+I9MQsrIepugxyNO2vwfQ/S11vquOQcD/Yc6xEqN1422yYRaVQDgeVp0kmum5YwCDTneYQB9soA1rHCa3Wo+oTyeoOh7X21KECWsDdN3v+2N+M9xgfXBFr4cVzD/NlQ3kdsoZhstrvWMiZD36AdtPOJC3TumLkGA1DnFgL9MaPQfrZomUYIOme33z/AIZYJnaytverzcfDC0naeiRk1FUY17LzXXKnmgasLvTpN3WckX53kLRp5/s+bsG3g3A9ZizmL+nRb4n+LAwQ4YlycSrU1Y0Pqtu0PfpEU2Mu7oi37U3AyB2hhQRoXuQ13El+k4YAo8f1JonaMUKHZEcGJNB5+EGRu2LRqXwEPfmnfKLSrrwA+u w3z+5Vq7 g5oNJ8iZkjoFRrFlPvARSHjKHe8fAjuNosoJq+l1ua/13lA/aE4bswdLO6STGoExQ+jg/ooep8t2O6d1c8/i4BjfOR7GHHWj6O2hChrVF2N1mCnC1mqhvhwhMZ0xjs9CdcyLSXB4QQ3sZCRpgXy1OQUXF2DWuzwsihMz+AmTwRXros48lU9UOFKbCibrVjtIygbh9AXq0hrsNLsNpcsdQWeFXpaZOk7NhYWX2CRnIWafkcM0BnNgMCT+W0tiBT25aO1IOuE72NzXqM3zAPX0zhKutMfmC4yIv72ADDR7gE5KeFdO92QiC6UWp21NmdqPhv2uuDxqWOqirge6eQQLSmYFy/Bo5VMLzm4kTyIoWX5U3Iuuzd4jPQoe4hjUgWCyegLyYrYJXd2/IGk9Lr62Zq0aTGWo6zuzSnWodASCmKD+fdwYxJ5FrhzLeNw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000019, 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 28=EC=9D=BC (=EC=9D=BC) =EC=98=A4=ED=9B=84 3:35, M= ike Rapoport =EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84=B1: > > On Sat, Apr 27, 2024 at 07:24:23PM +0900, DaeRo Lee wrote: > > 2024=EB=85=84 4=EC=9B=94 27=EC=9D=BC (=ED=86=A0) =EC=98=A4=ED=9B=84 5:5= 0, Mike 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 rig= ht. > > > > > > > > > -> 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 t= he > > > > > 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 valu= e > > > > > 'err' is not zero(which is '-ENOMEM' from memblock_isolate_range)= , we > > > > > free the region. > > > > > - 'nomap' is true -> memblock_mark_nomap : success -> not free th= e region > > > > > > > > > > : fail -> free the region > > > > > And it can be said that we add the region to the memblock.reserve= d > > > > > using memblock_phys_alloc_range and if the region is nomap, then = we > > > > > can free the region from memblock.reserved. But is it necessary t= o add > > > > > it to memblock.reserved? We just need the region in memblock.memo= ry 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.reserve= d > > > > > > NOMAP and memblock.reserved are semantically different, and at makes = sense > > > to have a "reserved nomap" node in fdt recorded in both memblock.memo= ry and > > > memblock.reserved. > > > > > > memblock.reserved represents the memory that is used by firmware or e= arly > > > kernel allocation, so reserved memory in fdt should be reserved in me= mblock > > > as well. I believe it's an oversight that early_init_dt_reserve_memor= y() > > > does not call memblock_reserve() for nomap memory. > > > > > > NOMAP is a property of a memory region that says that that region sho= uld > > > 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() I read the comment about memblock_mark_nomap() and understood that regions with nomap flags should be treated as PageReserved. But, if we add this nomap region to memblock.reserved, the region with nomap flag will be processed in the first for-loop in memmap_init_reserved_pages. Am I thinking wrong? Regards, DaeRo Lee