* [PATCH] mm/early_ioremap: Print the starting physical address in __early_ioremap()
@ 2026-01-09 13:31 Hou Wenlong
2026-01-10 23:57 ` Andrew Morton
2026-01-11 9:14 ` Mike Rapoport
0 siblings, 2 replies; 4+ messages in thread
From: Hou Wenlong @ 2026-01-09 13:31 UTC (permalink / raw)
To: linux-kernel
Cc: Hou Wenlong, Andrew Morton, David Hildenbrand, Lorenzo Stoakes,
Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko, linux-mm
The debug WARN() printing occurs after the while loop, so the
'phys_addr' reflects the last physical address rather than the actual
starting physical address, which is not useful for debugging. To
simplify, the WARN() statement could be moved up before the loop instead
of introducing a new variable to record the original 'phys_addr' value.
Additionally, swap the print order of 'slot_virt[slot]' and 'offset', as
this will enhance output readability.
Signed-off-by: Hou Wenlong <houwenlong.hwl@antgroup.com>
---
mm/early_ioremap.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/mm/early_ioremap.c b/mm/early_ioremap.c
index ff35b84a7b50..3fdde074c9da 100644
--- a/mm/early_ioremap.c
+++ b/mm/early_ioremap.c
@@ -139,6 +139,9 @@ __early_ioremap(resource_size_t phys_addr, unsigned long size, pgprot_t prot)
if (WARN_ON(nrpages > NR_FIX_BTMAPS))
return NULL;
+ WARN(early_ioremap_debug, "%s(%pa, %08lx) [%d] => %08lx + %08lx\n",
+ __func__, &phys_addr, size, slot, slot_virt[slot], offset);
+
/*
* Ok, go for it..
*/
@@ -152,8 +155,6 @@ __early_ioremap(resource_size_t phys_addr, unsigned long size, pgprot_t prot)
--idx;
--nrpages;
}
- WARN(early_ioremap_debug, "%s(%pa, %08lx) [%d] => %08lx + %08lx\n",
- __func__, &phys_addr, size, slot, offset, slot_virt[slot]);
prev_map[slot] = (void __iomem *)(offset + slot_virt[slot]);
return prev_map[slot];
--
2.31.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mm/early_ioremap: Print the starting physical address in __early_ioremap()
2026-01-09 13:31 [PATCH] mm/early_ioremap: Print the starting physical address in __early_ioremap() Hou Wenlong
@ 2026-01-10 23:57 ` Andrew Morton
2026-01-11 9:15 ` Mike Rapoport
2026-01-11 9:14 ` Mike Rapoport
1 sibling, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2026-01-10 23:57 UTC (permalink / raw)
To: Hou Wenlong
Cc: linux-kernel, David Hildenbrand, Lorenzo Stoakes,
Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko, linux-mm
On Fri, 9 Jan 2026 21:31:51 +0800 Hou Wenlong <houwenlong.hwl@antgroup.com> wrote:
> The debug WARN() printing occurs after the while loop, so the
> 'phys_addr' reflects the last physical address rather than the actual
> starting physical address, which is not useful for debugging. To
> simplify, the WARN() statement could be moved up before the loop instead
> of introducing a new variable to record the original 'phys_addr' value.
> Additionally, swap the print order of 'slot_virt[slot]' and 'offset', as
> this will enhance output readability.
>
yep, thanks.
> --- a/mm/early_ioremap.c
> +++ b/mm/early_ioremap.c
> @@ -139,6 +139,9 @@ __early_ioremap(resource_size_t phys_addr, unsigned long size, pgprot_t prot)
> if (WARN_ON(nrpages > NR_FIX_BTMAPS))
> return NULL;
>
> + WARN(early_ioremap_debug, "%s(%pa, %08lx) [%d] => %08lx + %08lx\n",
> + __func__, &phys_addr, size, slot, slot_virt[slot], offset);
> +
> /*
> * Ok, go for it..
> */
> @@ -152,8 +155,6 @@ __early_ioremap(resource_size_t phys_addr, unsigned long size, pgprot_t prot)
> --idx;
> --nrpages;
> }
> - WARN(early_ioremap_debug, "%s(%pa, %08lx) [%d] => %08lx + %08lx\n",
> - __func__, &phys_addr, size, slot, offset, slot_virt[slot]);
It's strange that this code uses WARN when nothing is wrong. The rest
of the function uses WARN appropriately. But that's off-topic!
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mm/early_ioremap: Print the starting physical address in __early_ioremap()
2026-01-10 23:57 ` Andrew Morton
@ 2026-01-11 9:15 ` Mike Rapoport
0 siblings, 0 replies; 4+ messages in thread
From: Mike Rapoport @ 2026-01-11 9:15 UTC (permalink / raw)
To: Andrew Morton
Cc: Hou Wenlong, linux-kernel, David Hildenbrand, Lorenzo Stoakes,
Liam R. Howlett, Vlastimil Babka, Suren Baghdasaryan,
Michal Hocko, linux-mm
On Sat, Jan 10, 2026 at 03:57:21PM -0800, Andrew Morton wrote:
> On Fri, 9 Jan 2026 21:31:51 +0800 Hou Wenlong <houwenlong.hwl@antgroup.com> wrote:
>
> > The debug WARN() printing occurs after the while loop, so the
> > 'phys_addr' reflects the last physical address rather than the actual
> > starting physical address, which is not useful for debugging. To
> > simplify, the WARN() statement could be moved up before the loop instead
> > of introducing a new variable to record the original 'phys_addr' value.
> > Additionally, swap the print order of 'slot_virt[slot]' and 'offset', as
> > this will enhance output readability.
> >
>
> yep, thanks.
>
> > --- a/mm/early_ioremap.c
> > +++ b/mm/early_ioremap.c
> > @@ -139,6 +139,9 @@ __early_ioremap(resource_size_t phys_addr, unsigned long size, pgprot_t prot)
> > if (WARN_ON(nrpages > NR_FIX_BTMAPS))
> > return NULL;
> >
> > + WARN(early_ioremap_debug, "%s(%pa, %08lx) [%d] => %08lx + %08lx\n",
> > + __func__, &phys_addr, size, slot, slot_virt[slot], offset);
> > +
> > /*
> > * Ok, go for it..
> > */
> > @@ -152,8 +155,6 @@ __early_ioremap(resource_size_t phys_addr, unsigned long size, pgprot_t prot)
> > --idx;
> > --nrpages;
> > }
> > - WARN(early_ioremap_debug, "%s(%pa, %08lx) [%d] => %08lx + %08lx\n",
> > - __func__, &phys_addr, size, slot, offset, slot_virt[slot]);
>
> It's strange that this code uses WARN when nothing is wrong. The rest
> of the function uses WARN appropriately. But that's off-topic!
It seems an historic thing. A nice cleanup would be to replace
WARN(early_ioremap_debug) with pr_warn() + dump_stack().
> Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
>
--
Sincerely yours,
Mike.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mm/early_ioremap: Print the starting physical address in __early_ioremap()
2026-01-09 13:31 [PATCH] mm/early_ioremap: Print the starting physical address in __early_ioremap() Hou Wenlong
2026-01-10 23:57 ` Andrew Morton
@ 2026-01-11 9:14 ` Mike Rapoport
1 sibling, 0 replies; 4+ messages in thread
From: Mike Rapoport @ 2026-01-11 9:14 UTC (permalink / raw)
To: Hou Wenlong
Cc: linux-kernel, Andrew Morton, David Hildenbrand, Lorenzo Stoakes,
Liam R. Howlett, Vlastimil Babka, Suren Baghdasaryan,
Michal Hocko, linux-mm
On Fri, Jan 09, 2026 at 09:31:51PM +0800, Hou Wenlong wrote:
> The debug WARN() printing occurs after the while loop, so the
> 'phys_addr' reflects the last physical address rather than the actual
> starting physical address, which is not useful for debugging. To
> simplify, the WARN() statement could be moved up before the loop instead
> of introducing a new variable to record the original 'phys_addr' value.
> Additionally, swap the print order of 'slot_virt[slot]' and 'offset', as
> this will enhance output readability.
>
> Signed-off-by: Hou Wenlong <houwenlong.hwl@antgroup.com>
Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
> ---
> mm/early_ioremap.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/mm/early_ioremap.c b/mm/early_ioremap.c
> index ff35b84a7b50..3fdde074c9da 100644
> --- a/mm/early_ioremap.c
> +++ b/mm/early_ioremap.c
> @@ -139,6 +139,9 @@ __early_ioremap(resource_size_t phys_addr, unsigned long size, pgprot_t prot)
> if (WARN_ON(nrpages > NR_FIX_BTMAPS))
> return NULL;
>
> + WARN(early_ioremap_debug, "%s(%pa, %08lx) [%d] => %08lx + %08lx\n",
> + __func__, &phys_addr, size, slot, slot_virt[slot], offset);
> +
> /*
> * Ok, go for it..
> */
> @@ -152,8 +155,6 @@ __early_ioremap(resource_size_t phys_addr, unsigned long size, pgprot_t prot)
> --idx;
> --nrpages;
> }
> - WARN(early_ioremap_debug, "%s(%pa, %08lx) [%d] => %08lx + %08lx\n",
> - __func__, &phys_addr, size, slot, offset, slot_virt[slot]);
>
> prev_map[slot] = (void __iomem *)(offset + slot_virt[slot]);
> return prev_map[slot];
> --
> 2.31.1
>
--
Sincerely yours,
Mike.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-01-11 9:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-09 13:31 [PATCH] mm/early_ioremap: Print the starting physical address in __early_ioremap() Hou Wenlong
2026-01-10 23:57 ` Andrew Morton
2026-01-11 9:15 ` Mike Rapoport
2026-01-11 9:14 ` Mike Rapoport
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox