Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arm64: mm: drop redundant remap of FDT first page
@ 2026-05-13 17:01 Sang-Heon Jeon
  2026-05-14 17:15 ` Sang-Heon Jeon
  2026-05-26 18:57 ` Catalin Marinas
  0 siblings, 2 replies; 3+ messages in thread
From: Sang-Heon Jeon @ 2026-05-13 17:01 UTC (permalink / raw)
  To: catalin.marinas, will; +Cc: linux-arm-kernel, Sang-Heon Jeon

fixmap_remap_fdt() calls create_mapping_noalloc() to map the first
page of the FDT to read its magic and totalsize from the header. If
the FDT does not fit in a single page, it calls create_mapping_noalloc()
again to map the rest.

The second mapping redundantly covers the first page that was just
mapped by the first mapping.

Start the second mapping at dt_phys_base + PAGE_SIZE so it only covers
the pages that have not been mapped yet. No functional change.

Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
---
QEMU-based test results

$ qemu-system-aarch64 -M virt -singlestep -d nochain,exec ...

Count log lines from fixmap_remap_fdt() entry to return
- entry PC : address of the <fixmap_remap_fdt> symbol
- return PC : next address of each bl ... <fixmap_remap_fdt>

1) AS-IS
  - 1st call (KERNEL) : 4935
  - 2nd call (KERNEL_RO) : 14151
2) TO-BE
  - 1st call : 4888
  - 2nd call : 14104

---
Hello,

While looking into boot information, I found a minor cleanup point.
If I misunderstood anything, please feel free to let me know.

Thank you for taking valuable time to review this work.

Best Regards,
Sang-Heon Jeon
---
 arch/arm64/mm/fixmap.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/mm/fixmap.c b/arch/arm64/mm/fixmap.c
index c5c5425791da..f8aea5572f7c 100644
--- a/arch/arm64/mm/fixmap.c
+++ b/arch/arm64/mm/fixmap.c
@@ -167,8 +167,9 @@ void *__init fixmap_remap_fdt(phys_addr_t dt_phys, int *size, pgprot_t prot)
 		return NULL;
 
 	if (offset + *size > PAGE_SIZE) {
-		create_mapping_noalloc(dt_phys_base, dt_virt_base,
-				       offset + *size, prot);
+		create_mapping_noalloc(dt_phys_base + PAGE_SIZE,
+			dt_virt_base + PAGE_SIZE,
+			offset + *size - PAGE_SIZE, prot);
 	}
 
 	return dt_virt;
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] arm64: mm: drop redundant remap of FDT first page
  2026-05-13 17:01 [PATCH] arm64: mm: drop redundant remap of FDT first page Sang-Heon Jeon
@ 2026-05-14 17:15 ` Sang-Heon Jeon
  2026-05-26 18:57 ` Catalin Marinas
  1 sibling, 0 replies; 3+ messages in thread
From: Sang-Heon Jeon @ 2026-05-14 17:15 UTC (permalink / raw)
  To: catalin.marinas, will; +Cc: linux-arm-kernel

On Thu, May 14, 2026 at 2:01 AM Sang-Heon Jeon <ekffu200098@gmail.com> wrote:
>
> fixmap_remap_fdt() calls create_mapping_noalloc() to map the first
> page of the FDT to read its magic and totalsize from the header. If
> the FDT does not fit in a single page, it calls create_mapping_noalloc()
> again to map the rest.
>
> The second mapping redundantly covers the first page that was just
> mapped by the first mapping.
>
> Start the second mapping at dt_phys_base + PAGE_SIZE so it only covers
> the pages that have not been mapped yet. No functional change.
>
> Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
> ---
> QEMU-based test results
>
> $ qemu-system-aarch64 -M virt -singlestep -d nochain,exec ...
>
> Count log lines from fixmap_remap_fdt() entry to return
> - entry PC : address of the <fixmap_remap_fdt> symbol
> - return PC : next address of each bl ... <fixmap_remap_fdt>
>
> 1) AS-IS
>   - 1st call (KERNEL) : 4935
>   - 2nd call (KERNEL_RO) : 14151
> 2) TO-BE
>   - 1st call : 4888
>   - 2nd call : 14104
>
> ---
> Hello,
>
> While looking into boot information, I found a minor cleanup point.
> If I misunderstood anything, please feel free to let me know.
>
> Thank you for taking valuable time to review this work.
>
> Best Regards,
> Sang-Heon Jeon
> ---
>  arch/arm64/mm/fixmap.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm64/mm/fixmap.c b/arch/arm64/mm/fixmap.c
> index c5c5425791da..f8aea5572f7c 100644
> --- a/arch/arm64/mm/fixmap.c
> +++ b/arch/arm64/mm/fixmap.c
> @@ -167,8 +167,9 @@ void *__init fixmap_remap_fdt(phys_addr_t dt_phys, int *size, pgprot_t prot)
>                 return NULL;
>
>         if (offset + *size > PAGE_SIZE) {

Based on sashiko review [1], I made another patch [2].
Please check that patch as well. Thank you.

[1] https://sashiko.dev/#/patchset/20260513170101.1858213-1-ekffu200098%40gmail.com
[2] https://lore.kernel.org/all/20260514171304.2034930-1-ekffu200098@gmail.com/

Best Regards,
Sang-Heon Jeon



> -               create_mapping_noalloc(dt_phys_base, dt_virt_base,
> -                                      offset + *size, prot);
> +               create_mapping_noalloc(dt_phys_base + PAGE_SIZE,
> +                       dt_virt_base + PAGE_SIZE,
> +                       offset + *size - PAGE_SIZE, prot);
>         }
>
>         return dt_virt;
> --
> 2.43.0
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] arm64: mm: drop redundant remap of FDT first page
  2026-05-13 17:01 [PATCH] arm64: mm: drop redundant remap of FDT first page Sang-Heon Jeon
  2026-05-14 17:15 ` Sang-Heon Jeon
@ 2026-05-26 18:57 ` Catalin Marinas
  1 sibling, 0 replies; 3+ messages in thread
From: Catalin Marinas @ 2026-05-26 18:57 UTC (permalink / raw)
  To: Sang-Heon Jeon; +Cc: will, linux-arm-kernel

On Thu, May 14, 2026 at 02:01:01AM +0900, Sang-Heon Jeon wrote:
> fixmap_remap_fdt() calls create_mapping_noalloc() to map the first
> page of the FDT to read its magic and totalsize from the header. If
> the FDT does not fit in a single page, it calls create_mapping_noalloc()
> again to map the rest.
> 
> The second mapping redundantly covers the first page that was just
> mapped by the first mapping.
> 
> Start the second mapping at dt_phys_base + PAGE_SIZE so it only covers
> the pages that have not been mapped yet. No functional change.
> 
> Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
[...]
> diff --git a/arch/arm64/mm/fixmap.c b/arch/arm64/mm/fixmap.c
> index c5c5425791da..f8aea5572f7c 100644
> --- a/arch/arm64/mm/fixmap.c
> +++ b/arch/arm64/mm/fixmap.c
> @@ -167,8 +167,9 @@ void *__init fixmap_remap_fdt(phys_addr_t dt_phys, int *size, pgprot_t prot)
>  		return NULL;
>  
>  	if (offset + *size > PAGE_SIZE) {
> -		create_mapping_noalloc(dt_phys_base, dt_virt_base,
> -				       offset + *size, prot);
> +		create_mapping_noalloc(dt_phys_base + PAGE_SIZE,
> +			dt_virt_base + PAGE_SIZE,
> +			offset + *size - PAGE_SIZE, prot);
>  	}

Is it actually worth it? It's not that we allocate memory here or take a
noticeable time to reach the first pte. I find the current easier to
read.

-- 
Catalin


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-05-26 18:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-13 17:01 [PATCH] arm64: mm: drop redundant remap of FDT first page Sang-Heon Jeon
2026-05-14 17:15 ` Sang-Heon Jeon
2026-05-26 18:57 ` Catalin Marinas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox