From: Marek Szyprowski <m.szyprowski@samsung.com>
To: Wandun <chenwandun1@gmail.com>,
robh@kernel.org, saravanak@kernel.org, rppt@kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org
Cc: akpm@linux-foundation.org
Subject: Re: [PATCH v2 1/5] of: reserved_mem: skip init for regions whose early reservation failed
Date: Fri, 4 Sep 2026 10:49:34 +0200 [thread overview]
Message-ID: <7a964778-adc3-4186-9122-3858bb61c372@samsung.com> (raw)
In-Reply-To: <af87036b-0809-4880-b088-545780b4d963@gmail.com>
On 31.08.2026 15:04, Wandun wrote:
> On 8/26/26 21:14, Marek Szyprowski wrote:
>> On 18.08.2026 11:24, Wandun Chen wrote:
>>> From: Wandun Chen <chenwandun@lixiang.com>
>>>
>>> __reserved_mem_reserve_reg() discards the error from
>>> early_init_dt_reserve_memory() and returns 0 unconditionally, so the
>>> caller counts the node in total_reserved_mem_cnt and the late scan
>>> initializes it without checking whether the early reservation actually
>>> succeeded. A region whose reservation failed is then handed to a
>>> device assuming the memory is protected.
>>>
>>> Propagate the error so failed reservations are no longer counted, and
>>> record the failed nodes so fdt_scan_reserved_mem_late() can skip them.
>>>
>>> Recording the failed nodes explicitly is necessary because
>>> fdt_scan_reserved_mem_late() rescans the DT independently. It cannot
>>> tell from memblock whether early reservation succeeded.
>>>
>>> The failed-node array is bounded by MAX_RESERVED_REGIONS, the number
>>> of static regions is not bounded by it, so on overflow the extra nodes
>>> fall back to being initialized, which is the current behavior.
>> I'm not very keen on such partial solution. Indeed we have no place to
>>
>> store the result of the early init call, but we can check if the given
>>
>> region has been earlier marked in memblock as reserved or no-map in
>>
>> fdt_scan_reserved_mem_late(). If those attributes don't match the
>>
>> region can be simply skipped then.
> Considering the later patches that reject reservations for overlapping
> nodes, checking the memblock state in fdt_scan_reserved_mem_late() may
> produce false positives.
>
> For example, if region A is reserved first and region B is a subset of
> A, reserving B will fail because it overlaps with A (in patch 02/03).
> However, during fdt_scan_reserved_mem_late(), B will still appear to
> be reserved because its range is already covered by A. As a result,
> B would be initialized even though its own reservation failed, which
> is contrary to the intended behavior.
Imho the overlapping reserved regions are some kind of configuration
mismatch and it is enough to detect them. fdt_scan_reserved_mem_late()
can first store all regions to dynamic reserved_mem array, then check
for overlaps, and only then initialize those, which don't overlap and
have proper memblock attributes?
Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland
next prev parent reply other threads:[~2026-09-04 8:49 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-18 9:24 [PATCH v2 0/5] of: reserved_mem: several fixes about reserved memory Wandun Chen
2026-08-18 9:24 ` [PATCH v2 1/5] of: reserved_mem: skip init for regions whose early reservation failed Wandun Chen
2026-08-26 13:14 ` Marek Szyprowski
2026-08-31 13:04 ` Wandun
2026-09-04 8:49 ` Marek Szyprowski [this message]
2026-08-18 9:24 ` [PATCH v2 2/5] of: reserved_mem: reject static regions overlapping no-map memory Wandun Chen
2026-08-18 9:40 ` sashiko-bot
2026-08-19 2:26 ` Wandun
2026-08-26 13:16 ` Marek Szyprowski
2026-08-18 9:24 ` [PATCH v2 3/5] of: reserved_mem: reject statically placed regions overlapping existing reservations Wandun Chen
2026-08-18 9:41 ` sashiko-bot
2026-08-19 3:00 ` Wandun
2026-08-26 13:16 ` Marek Szyprowski
2026-08-18 9:24 ` [PATCH v2 4/5] of: reserved_mem: release dynamically allocated no-map region on init failure Wandun Chen
2026-08-18 9:38 ` sashiko-bot
2026-08-19 3:14 ` Wandun
2026-08-26 13:17 ` Marek Szyprowski
2026-08-18 9:24 ` [PATCH v2 5/5] of: reserved_mem: retain static no-map memory " Wandun Chen
2026-08-18 9:34 ` sashiko-bot
2026-08-19 3:16 ` Wandun
2026-08-26 13:18 ` Marek Szyprowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7a964778-adc3-4186-9122-3858bb61c372@samsung.com \
--to=m.szyprowski@samsung.com \
--cc=akpm@linux-foundation.org \
--cc=chenwandun1@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=robh@kernel.org \
--cc=rppt@kernel.org \
--cc=saravanak@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox