[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20231207131658.225815-1-ytcoode@gmail.com>
Date: Thu, 7 Dec 2023 21:16:58 +0800
From: Yuntao Wang <ytcoode@...il.com>
To: linux-kernel@...r.kernel.org, x86@...nel.org
Cc: Dave Hansen <dave.hansen@...ux.intel.com>,
Andy Lutomirski <luto@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
"H. Peter Anvin" <hpa@...or.com>, Yuntao Wang <ytcoode@...il.com>
Subject: [PATCH] x86/mm: Optimize the for loop in numa_nodemask_from_meminfo()
Since only the first `mi->nr_blks` elements of the `mi->blk` array contain
valid data, we do not need to iterate over the entire array.
Signed-off-by: Yuntao Wang <ytcoode@...il.com>
---
arch/x86/mm/numa.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
index b29ceb19e46e..e84f14a9462d 100644
--- a/arch/x86/mm/numa.c
+++ b/arch/x86/mm/numa.c
@@ -339,7 +339,7 @@ static void __init numa_nodemask_from_meminfo(nodemask_t *nodemask,
{
int i;
- for (i = 0; i < ARRAY_SIZE(mi->blk); i++)
+ for (i = 0; i < mi->nr_blks; i++)
if (mi->blk[i].start != mi->blk[i].end &&
mi->blk[i].nid != NUMA_NO_NODE)
node_set(mi->blk[i].nid, *nodemask);
--
2.43.0
Powered by blists - more mailing lists