* [PATCH v2 1/1] of: fdt: Scan /memreserve/ last
@ 2023-04-10 12:00 ` Lucas Tanure
0 siblings, 0 replies; 15+ messages in thread
From: Lucas Tanure @ 2023-04-10 12:00 UTC (permalink / raw)
To: Rob Herring, Frank Rowand, Mike Rapoport, Andrew Morton
Cc: devicetree, linux-kernel, linux-mm, jbrunet, linux-amlogic,
linux-arm-kernel, martin.blumenstingl, narmstrong, stefan,
Lucas Tanure
Change the order of scanning /memreserve/ and /reserved-memory node.
/reserved-memory node should go first, as it has a more updated
description of the memory regions and it can apply flags, like nomap.
Also, /memreserve/ should avoid reserving regions described in
/reserved-memory node.
Signed-off-by: Lucas Tanure <tanure@linux.com>
---
drivers/of/fdt.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index d1a68b6d03b3..26e608d8025d 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -635,16 +635,21 @@ void __init early_init_fdt_scan_reserved_mem(void)
if (!initial_boot_params)
return;
+ fdt_scan_reserved_mem();
+ fdt_reserve_elfcorehdr();
+
/* Process header /memreserve/ fields */
for (n = 0; ; n++) {
fdt_get_mem_rsv(initial_boot_params, n, &base, &size);
if (!size)
break;
+ if (memblock_overlaps_region(&memblock.memory, base, size) &&
+ memblock_is_region_reserved(base, size))
+ break;
+
memblock_reserve(base, size);
}
- fdt_scan_reserved_mem();
- fdt_reserve_elfcorehdr();
fdt_init_reserved_mem();
}
--
2.40.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v2 1/1] of: fdt: Scan /memreserve/ last
@ 2023-04-10 12:00 ` Lucas Tanure
0 siblings, 0 replies; 15+ messages in thread
From: Lucas Tanure @ 2023-04-10 12:00 UTC (permalink / raw)
To: Rob Herring, Frank Rowand, Mike Rapoport, Andrew Morton
Cc: devicetree, linux-kernel, linux-mm, jbrunet, linux-amlogic,
linux-arm-kernel, martin.blumenstingl, narmstrong, stefan,
Lucas Tanure
Change the order of scanning /memreserve/ and /reserved-memory node.
/reserved-memory node should go first, as it has a more updated
description of the memory regions and it can apply flags, like nomap.
Also, /memreserve/ should avoid reserving regions described in
/reserved-memory node.
Signed-off-by: Lucas Tanure <tanure@linux.com>
---
drivers/of/fdt.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index d1a68b6d03b3..26e608d8025d 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -635,16 +635,21 @@ void __init early_init_fdt_scan_reserved_mem(void)
if (!initial_boot_params)
return;
+ fdt_scan_reserved_mem();
+ fdt_reserve_elfcorehdr();
+
/* Process header /memreserve/ fields */
for (n = 0; ; n++) {
fdt_get_mem_rsv(initial_boot_params, n, &base, &size);
if (!size)
break;
+ if (memblock_overlaps_region(&memblock.memory, base, size) &&
+ memblock_is_region_reserved(base, size))
+ break;
+
memblock_reserve(base, size);
}
- fdt_scan_reserved_mem();
- fdt_reserve_elfcorehdr();
fdt_init_reserved_mem();
}
--
2.40.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH v2 1/1] of: fdt: Scan /memreserve/ last
2023-04-10 12:00 ` Lucas Tanure
(?)
@ 2023-04-10 12:52 ` Rob Herring
-1 siblings, 0 replies; 15+ messages in thread
From: Rob Herring @ 2023-04-10 12:52 UTC (permalink / raw)
To: Lucas Tanure
Cc: Frank Rowand, Mike Rapoport, Andrew Morton, devicetree,
linux-kernel, linux-mm, jbrunet, linux-amlogic, linux-arm-kernel,
martin.blumenstingl, narmstrong, stefan
On Mon, Apr 10, 2023 at 7:00 AM Lucas Tanure <tanure@linux.com> wrote:
>
> Change the order of scanning /memreserve/ and /reserved-memory node.
> /reserved-memory node should go first, as it has a more updated
> description of the memory regions and it can apply flags, like nomap.
> Also, /memreserve/ should avoid reserving regions described in
> /reserved-memory node.
Like I said on v1, I think doing this has a high chance of causing
regressions on other platforms. It should probably not go to stable
for some time after a kernel release.
> Signed-off-by: Lucas Tanure <tanure@linux.com>
> ---
> drivers/of/fdt.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index d1a68b6d03b3..26e608d8025d 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -635,16 +635,21 @@ void __init early_init_fdt_scan_reserved_mem(void)
> if (!initial_boot_params)
> return;
>
> + fdt_scan_reserved_mem();
> + fdt_reserve_elfcorehdr();
> +
> /* Process header /memreserve/ fields */
> for (n = 0; ; n++) {
> fdt_get_mem_rsv(initial_boot_params, n, &base, &size);
> if (!size)
> break;
> + if (memblock_overlaps_region(&memblock.memory, base, size) &&
> + memblock_is_region_reserved(base, size))
Just to make sure, a partial overlap will still get reserved?
> + break;
Shouldn't we continue to the next entry rather than stopping.
> +
> memblock_reserve(base, size);
> }
>
> - fdt_scan_reserved_mem();
> - fdt_reserve_elfcorehdr();
> fdt_init_reserved_mem();
> }
>
> --
> 2.40.0
>
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH v2 1/1] of: fdt: Scan /memreserve/ last
@ 2023-04-10 12:52 ` Rob Herring
0 siblings, 0 replies; 15+ messages in thread
From: Rob Herring @ 2023-04-10 12:52 UTC (permalink / raw)
To: Lucas Tanure
Cc: Frank Rowand, Mike Rapoport, Andrew Morton, devicetree,
linux-kernel, linux-mm, jbrunet, linux-amlogic, linux-arm-kernel,
martin.blumenstingl, narmstrong, stefan
On Mon, Apr 10, 2023 at 7:00 AM Lucas Tanure <tanure@linux.com> wrote:
>
> Change the order of scanning /memreserve/ and /reserved-memory node.
> /reserved-memory node should go first, as it has a more updated
> description of the memory regions and it can apply flags, like nomap.
> Also, /memreserve/ should avoid reserving regions described in
> /reserved-memory node.
Like I said on v1, I think doing this has a high chance of causing
regressions on other platforms. It should probably not go to stable
for some time after a kernel release.
> Signed-off-by: Lucas Tanure <tanure@linux.com>
> ---
> drivers/of/fdt.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index d1a68b6d03b3..26e608d8025d 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -635,16 +635,21 @@ void __init early_init_fdt_scan_reserved_mem(void)
> if (!initial_boot_params)
> return;
>
> + fdt_scan_reserved_mem();
> + fdt_reserve_elfcorehdr();
> +
> /* Process header /memreserve/ fields */
> for (n = 0; ; n++) {
> fdt_get_mem_rsv(initial_boot_params, n, &base, &size);
> if (!size)
> break;
> + if (memblock_overlaps_region(&memblock.memory, base, size) &&
> + memblock_is_region_reserved(base, size))
Just to make sure, a partial overlap will still get reserved?
> + break;
Shouldn't we continue to the next entry rather than stopping.
> +
> memblock_reserve(base, size);
> }
>
> - fdt_scan_reserved_mem();
> - fdt_reserve_elfcorehdr();
> fdt_init_reserved_mem();
> }
>
> --
> 2.40.0
>
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH v2 1/1] of: fdt: Scan /memreserve/ last
@ 2023-04-10 12:52 ` Rob Herring
0 siblings, 0 replies; 15+ messages in thread
From: Rob Herring @ 2023-04-10 12:52 UTC (permalink / raw)
To: Lucas Tanure
Cc: Frank Rowand, Mike Rapoport, Andrew Morton, devicetree,
linux-kernel, linux-mm, jbrunet, linux-amlogic, linux-arm-kernel,
martin.blumenstingl, narmstrong, stefan
On Mon, Apr 10, 2023 at 7:00 AM Lucas Tanure <tanure@linux.com> wrote:
>
> Change the order of scanning /memreserve/ and /reserved-memory node.
> /reserved-memory node should go first, as it has a more updated
> description of the memory regions and it can apply flags, like nomap.
> Also, /memreserve/ should avoid reserving regions described in
> /reserved-memory node.
Like I said on v1, I think doing this has a high chance of causing
regressions on other platforms. It should probably not go to stable
for some time after a kernel release.
> Signed-off-by: Lucas Tanure <tanure@linux.com>
> ---
> drivers/of/fdt.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index d1a68b6d03b3..26e608d8025d 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -635,16 +635,21 @@ void __init early_init_fdt_scan_reserved_mem(void)
> if (!initial_boot_params)
> return;
>
> + fdt_scan_reserved_mem();
> + fdt_reserve_elfcorehdr();
> +
> /* Process header /memreserve/ fields */
> for (n = 0; ; n++) {
> fdt_get_mem_rsv(initial_boot_params, n, &base, &size);
> if (!size)
> break;
> + if (memblock_overlaps_region(&memblock.memory, base, size) &&
> + memblock_is_region_reserved(base, size))
Just to make sure, a partial overlap will still get reserved?
> + break;
Shouldn't we continue to the next entry rather than stopping.
> +
> memblock_reserve(base, size);
> }
>
> - fdt_scan_reserved_mem();
> - fdt_reserve_elfcorehdr();
> fdt_init_reserved_mem();
> }
>
> --
> 2.40.0
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH v2 1/1] of: fdt: Scan /memreserve/ last
2023-04-10 12:52 ` Rob Herring
(?)
@ 2023-04-10 14:58 ` Lucas Tanure
-1 siblings, 0 replies; 15+ messages in thread
From: Lucas Tanure @ 2023-04-10 14:58 UTC (permalink / raw)
To: Rob Herring
Cc: Frank Rowand, Mike Rapoport, Andrew Morton, devicetree,
linux-kernel, linux-mm, jbrunet, linux-amlogic, linux-arm-kernel,
martin.blumenstingl, narmstrong, stefan
On Mon, Apr 10, 2023 at 8:52 AM Rob Herring <robh+dt@kernel.org> wrote:
>
> On Mon, Apr 10, 2023 at 7:00 AM Lucas Tanure <tanure@linux.com> wrote:
> >
> > Change the order of scanning /memreserve/ and /reserved-memory node.
> > /reserved-memory node should go first, as it has a more updated
> > description of the memory regions and it can apply flags, like nomap.
> > Also, /memreserve/ should avoid reserving regions described in
> > /reserved-memory node.
>
> Like I said on v1, I think doing this has a high chance of causing
> regressions on other platforms. It should probably not go to stable
> for some time after a kernel release.
>
> > Signed-off-by: Lucas Tanure <tanure@linux.com>
> > ---
> > drivers/of/fdt.c | 9 +++++++--
> > 1 file changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> > index d1a68b6d03b3..26e608d8025d 100644
> > --- a/drivers/of/fdt.c
> > +++ b/drivers/of/fdt.c
> > @@ -635,16 +635,21 @@ void __init early_init_fdt_scan_reserved_mem(void)
> > if (!initial_boot_params)
> > return;
> >
> > + fdt_scan_reserved_mem();
> > + fdt_reserve_elfcorehdr();
> > +
> > /* Process header /memreserve/ fields */
> > for (n = 0; ; n++) {
> > fdt_get_mem_rsv(initial_boot_params, n, &base, &size);
> > if (!size)
> > break;
> > + if (memblock_overlaps_region(&memblock.memory, base, size) &&
> > + memblock_is_region_reserved(base, size))
>
> Just to make sure, a partial overlap will still get reserved?
A partial overlap will get reserved if not already reserved by the
/reserved-memory node.
>
> > + break;
>
> Shouldn't we continue to the next entry rather than stopping.
Yes, my mistake; I will send v3.
>
> > +
> > memblock_reserve(base, size);
> > }
> >
> > - fdt_scan_reserved_mem();
> > - fdt_reserve_elfcorehdr();
> > fdt_init_reserved_mem();
> > }
> >
> > --
> > 2.40.0
> >
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH v2 1/1] of: fdt: Scan /memreserve/ last
@ 2023-04-10 14:58 ` Lucas Tanure
0 siblings, 0 replies; 15+ messages in thread
From: Lucas Tanure @ 2023-04-10 14:58 UTC (permalink / raw)
To: Rob Herring
Cc: Frank Rowand, Mike Rapoport, Andrew Morton, devicetree,
linux-kernel, linux-mm, jbrunet, linux-amlogic, linux-arm-kernel,
martin.blumenstingl, narmstrong, stefan
On Mon, Apr 10, 2023 at 8:52 AM Rob Herring <robh+dt@kernel.org> wrote:
>
> On Mon, Apr 10, 2023 at 7:00 AM Lucas Tanure <tanure@linux.com> wrote:
> >
> > Change the order of scanning /memreserve/ and /reserved-memory node.
> > /reserved-memory node should go first, as it has a more updated
> > description of the memory regions and it can apply flags, like nomap.
> > Also, /memreserve/ should avoid reserving regions described in
> > /reserved-memory node.
>
> Like I said on v1, I think doing this has a high chance of causing
> regressions on other platforms. It should probably not go to stable
> for some time after a kernel release.
>
> > Signed-off-by: Lucas Tanure <tanure@linux.com>
> > ---
> > drivers/of/fdt.c | 9 +++++++--
> > 1 file changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> > index d1a68b6d03b3..26e608d8025d 100644
> > --- a/drivers/of/fdt.c
> > +++ b/drivers/of/fdt.c
> > @@ -635,16 +635,21 @@ void __init early_init_fdt_scan_reserved_mem(void)
> > if (!initial_boot_params)
> > return;
> >
> > + fdt_scan_reserved_mem();
> > + fdt_reserve_elfcorehdr();
> > +
> > /* Process header /memreserve/ fields */
> > for (n = 0; ; n++) {
> > fdt_get_mem_rsv(initial_boot_params, n, &base, &size);
> > if (!size)
> > break;
> > + if (memblock_overlaps_region(&memblock.memory, base, size) &&
> > + memblock_is_region_reserved(base, size))
>
> Just to make sure, a partial overlap will still get reserved?
A partial overlap will get reserved if not already reserved by the
/reserved-memory node.
>
> > + break;
>
> Shouldn't we continue to the next entry rather than stopping.
Yes, my mistake; I will send v3.
>
> > +
> > memblock_reserve(base, size);
> > }
> >
> > - fdt_scan_reserved_mem();
> > - fdt_reserve_elfcorehdr();
> > fdt_init_reserved_mem();
> > }
> >
> > --
> > 2.40.0
> >
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH v2 1/1] of: fdt: Scan /memreserve/ last
@ 2023-04-10 14:58 ` Lucas Tanure
0 siblings, 0 replies; 15+ messages in thread
From: Lucas Tanure @ 2023-04-10 14:58 UTC (permalink / raw)
To: Rob Herring
Cc: Frank Rowand, Mike Rapoport, Andrew Morton, devicetree,
linux-kernel, linux-mm, jbrunet, linux-amlogic, linux-arm-kernel,
martin.blumenstingl, narmstrong, stefan
On Mon, Apr 10, 2023 at 8:52 AM Rob Herring <robh+dt@kernel.org> wrote:
>
> On Mon, Apr 10, 2023 at 7:00 AM Lucas Tanure <tanure@linux.com> wrote:
> >
> > Change the order of scanning /memreserve/ and /reserved-memory node.
> > /reserved-memory node should go first, as it has a more updated
> > description of the memory regions and it can apply flags, like nomap.
> > Also, /memreserve/ should avoid reserving regions described in
> > /reserved-memory node.
>
> Like I said on v1, I think doing this has a high chance of causing
> regressions on other platforms. It should probably not go to stable
> for some time after a kernel release.
>
> > Signed-off-by: Lucas Tanure <tanure@linux.com>
> > ---
> > drivers/of/fdt.c | 9 +++++++--
> > 1 file changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> > index d1a68b6d03b3..26e608d8025d 100644
> > --- a/drivers/of/fdt.c
> > +++ b/drivers/of/fdt.c
> > @@ -635,16 +635,21 @@ void __init early_init_fdt_scan_reserved_mem(void)
> > if (!initial_boot_params)
> > return;
> >
> > + fdt_scan_reserved_mem();
> > + fdt_reserve_elfcorehdr();
> > +
> > /* Process header /memreserve/ fields */
> > for (n = 0; ; n++) {
> > fdt_get_mem_rsv(initial_boot_params, n, &base, &size);
> > if (!size)
> > break;
> > + if (memblock_overlaps_region(&memblock.memory, base, size) &&
> > + memblock_is_region_reserved(base, size))
>
> Just to make sure, a partial overlap will still get reserved?
A partial overlap will get reserved if not already reserved by the
/reserved-memory node.
>
> > + break;
>
> Shouldn't we continue to the next entry rather than stopping.
Yes, my mistake; I will send v3.
>
> > +
> > memblock_reserve(base, size);
> > }
> >
> > - fdt_scan_reserved_mem();
> > - fdt_reserve_elfcorehdr();
> > fdt_init_reserved_mem();
> > }
> >
> > --
> > 2.40.0
> >
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 1/1] of: fdt: Scan /memreserve/ last
2023-04-10 12:00 ` Lucas Tanure
(?)
@ 2023-04-10 16:40 ` Mike Rapoport
-1 siblings, 0 replies; 15+ messages in thread
From: Mike Rapoport @ 2023-04-10 16:40 UTC (permalink / raw)
To: Lucas Tanure
Cc: Rob Herring, Frank Rowand, Andrew Morton, devicetree,
linux-kernel, linux-mm, jbrunet, linux-amlogic, linux-arm-kernel,
martin.blumenstingl, narmstrong, stefan
On Mon, Apr 10, 2023 at 08:00:17AM -0400, Lucas Tanure wrote:
> Change the order of scanning /memreserve/ and /reserved-memory node.
> /reserved-memory node should go first, as it has a more updated
> description of the memory regions and it can apply flags, like nomap.
> Also, /memreserve/ should avoid reserving regions described in
> /reserved-memory node.
>
> Signed-off-by: Lucas Tanure <tanure@linux.com>
> ---
> drivers/of/fdt.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index d1a68b6d03b3..26e608d8025d 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -635,16 +635,21 @@ void __init early_init_fdt_scan_reserved_mem(void)
> if (!initial_boot_params)
> return;
>
> + fdt_scan_reserved_mem();
> + fdt_reserve_elfcorehdr();
> +
> /* Process header /memreserve/ fields */
> for (n = 0; ; n++) {
> fdt_get_mem_rsv(initial_boot_params, n, &base, &size);
> if (!size)
> break;
> + if (memblock_overlaps_region(&memblock.memory, base, size) &&
> + memblock_is_region_reserved(base, size))
> + break;
I don't think this is really needed, it's ok to reserve the same ranges
multiple times.
Both checks are not cheap, so it'll be better to just reserve everything
both from performance and simplicity points of view.
> +
> memblock_reserve(base, size);
> }
>
> - fdt_scan_reserved_mem();
> - fdt_reserve_elfcorehdr();
> fdt_init_reserved_mem();
> }
>
> --
> 2.40.0
>
--
Sincerely yours,
Mike.
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH v2 1/1] of: fdt: Scan /memreserve/ last
@ 2023-04-10 16:40 ` Mike Rapoport
0 siblings, 0 replies; 15+ messages in thread
From: Mike Rapoport @ 2023-04-10 16:40 UTC (permalink / raw)
To: Lucas Tanure
Cc: Rob Herring, Frank Rowand, Andrew Morton, devicetree,
linux-kernel, linux-mm, jbrunet, linux-amlogic, linux-arm-kernel,
martin.blumenstingl, narmstrong, stefan
On Mon, Apr 10, 2023 at 08:00:17AM -0400, Lucas Tanure wrote:
> Change the order of scanning /memreserve/ and /reserved-memory node.
> /reserved-memory node should go first, as it has a more updated
> description of the memory regions and it can apply flags, like nomap.
> Also, /memreserve/ should avoid reserving regions described in
> /reserved-memory node.
>
> Signed-off-by: Lucas Tanure <tanure@linux.com>
> ---
> drivers/of/fdt.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index d1a68b6d03b3..26e608d8025d 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -635,16 +635,21 @@ void __init early_init_fdt_scan_reserved_mem(void)
> if (!initial_boot_params)
> return;
>
> + fdt_scan_reserved_mem();
> + fdt_reserve_elfcorehdr();
> +
> /* Process header /memreserve/ fields */
> for (n = 0; ; n++) {
> fdt_get_mem_rsv(initial_boot_params, n, &base, &size);
> if (!size)
> break;
> + if (memblock_overlaps_region(&memblock.memory, base, size) &&
> + memblock_is_region_reserved(base, size))
> + break;
I don't think this is really needed, it's ok to reserve the same ranges
multiple times.
Both checks are not cheap, so it'll be better to just reserve everything
both from performance and simplicity points of view.
> +
> memblock_reserve(base, size);
> }
>
> - fdt_scan_reserved_mem();
> - fdt_reserve_elfcorehdr();
> fdt_init_reserved_mem();
> }
>
> --
> 2.40.0
>
--
Sincerely yours,
Mike.
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH v2 1/1] of: fdt: Scan /memreserve/ last
@ 2023-04-10 16:40 ` Mike Rapoport
0 siblings, 0 replies; 15+ messages in thread
From: Mike Rapoport @ 2023-04-10 16:40 UTC (permalink / raw)
To: Lucas Tanure
Cc: Rob Herring, Frank Rowand, Andrew Morton, devicetree,
linux-kernel, linux-mm, jbrunet, linux-amlogic, linux-arm-kernel,
martin.blumenstingl, narmstrong, stefan
On Mon, Apr 10, 2023 at 08:00:17AM -0400, Lucas Tanure wrote:
> Change the order of scanning /memreserve/ and /reserved-memory node.
> /reserved-memory node should go first, as it has a more updated
> description of the memory regions and it can apply flags, like nomap.
> Also, /memreserve/ should avoid reserving regions described in
> /reserved-memory node.
>
> Signed-off-by: Lucas Tanure <tanure@linux.com>
> ---
> drivers/of/fdt.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index d1a68b6d03b3..26e608d8025d 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -635,16 +635,21 @@ void __init early_init_fdt_scan_reserved_mem(void)
> if (!initial_boot_params)
> return;
>
> + fdt_scan_reserved_mem();
> + fdt_reserve_elfcorehdr();
> +
> /* Process header /memreserve/ fields */
> for (n = 0; ; n++) {
> fdt_get_mem_rsv(initial_boot_params, n, &base, &size);
> if (!size)
> break;
> + if (memblock_overlaps_region(&memblock.memory, base, size) &&
> + memblock_is_region_reserved(base, size))
> + break;
I don't think this is really needed, it's ok to reserve the same ranges
multiple times.
Both checks are not cheap, so it'll be better to just reserve everything
both from performance and simplicity points of view.
> +
> memblock_reserve(base, size);
> }
>
> - fdt_scan_reserved_mem();
> - fdt_reserve_elfcorehdr();
> fdt_init_reserved_mem();
> }
>
> --
> 2.40.0
>
--
Sincerely yours,
Mike.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 15+ messages in thread