[PATCH] mm/early_ioremap: Combine two loops to improve performance

From: Yajun Deng
Date: Tue Sep 27 2022 - 03:53:22 EST


The first loop will waring once if prev_map is init, we can add a
boolean variable to do that. So those two loops can be combined to
improve performance.

Signed-off-by: Yajun Deng <yajun.deng@xxxxxxxxx>
---
mm/early_ioremap.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/mm/early_ioremap.c b/mm/early_ioremap.c
index 9bc12e526ed0..3076fb47c685 100644
--- a/mm/early_ioremap.c
+++ b/mm/early_ioremap.c
@@ -70,14 +70,15 @@ static unsigned long slot_virt[FIX_BTMAPS_SLOTS] __initdata;

void __init early_ioremap_setup(void)
{
+ bool init_prev_map = false;
int i;

- for (i = 0; i < FIX_BTMAPS_SLOTS; i++)
- if (WARN_ON(prev_map[i]))
- break;
+ for (i = 0; i < FIX_BTMAPS_SLOTS; i++) {
+ if (!init_prev_map && WARN_ON(prev_map[i]))
+ init_prev_map = true;

- for (i = 0; i < FIX_BTMAPS_SLOTS; i++)
slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
+ }
}

static int __init check_early_ioremap_leak(void)
--
2.25.1