Skip to contentSkip to conversation

LoongArch: warn when per-CPU TLB vector allocation fails

PATCH In review Song Hu 2 participants 3 messages Jul 17 LoongArch

lore
Share & tools
lore

Song Hu

author
#0 lore raw

PATCH 1/1 LoongArch: warn when per-CPU TLB vector allocation fails

On a secondary CPU, setup_tlb_handler() allocates a NUMA-local page for the per-CPU TLB exception vectors and silently returns if the allocation fails. The CPU keeps running on the shared vectors that configure_exception_vector() installed earlier in per_cpu_trap_init(), losing NUMA locality with nothing logged. Warn so the fallback is observable.

---
 arch/loongarch/mm/tlb.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
arch/loongarch/mm/tlb.c +4 -1
index aaf7d685cc2a..e5220653279c 100644
@@ -297,8 +297,11 @@ static void setup_tlb_handler(int cpu)
 			return;
 
 		page = alloc_pages_node(cpu_to_node(cpu), GFP_ATOMIC, get_order(vec_sz));
-		if (!page)
+		if (!page) {
+			pr_warn("CPU%d: TLB vector allocation failed; "
+				"using shared vectors\n", cpu);
 			return;
+		}
 
 		addr = page_address(page);
 		pcpu_handlers[cpu] = (unsigned long)addr;
Signature · 1 line
2.43.0
maintainer
#1 lore raw

Hi, Song,

Quoted 18 lines · Song Hu

On a secondary CPU, setup_tlb_handler() allocates a NUMA-local page for the per-CPU TLB exception vectors and silently returns if the allocation fails. The CPU keeps running on the shared vectors that configure_exception_vector() installed earlier in per_cpu_trap_init(), losing NUMA locality with nothing logged. Warn so the fallback is observable.

---
 arch/loongarch/mm/tlb.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
arch/loongarch/mm/tlb.c +0 -0
index aaf7d685cc2a..e5220653279c 100644

arch/loongarch/mm/tlb.c static void setup_tlb_handler(int cpu) · line 304

Quoted 9 lines
arch/loongarch/mm/tlb.c +4 -1
@@ -297,8 +297,11 @@ static void setup_tlb_handler(int cpu)
                        return;
 
                page = alloc_pages_node(cpu_to_node(cpu), GFP_ATOMIC, get_order(vec_sz));
-               if (!page)
+               if (!page) {
+                       pr_warn("CPU%d: TLB vector allocation failed; "
+                               "using shared vectors\n", cpu);
                        return;
+               }

A warning usually make users nervous, this failure completely doesn't hurt anything, why you want to shout loudly here?

Huacai

Quoted 6 lines
arch/loongarch/mm/tlb.c +0 -1
                addr = page_address(page);
                pcpu_handlers[cpu] = (unsigned long)addr;
--

2.43.0

author
#2 lore raw
Quoted 22 lines · Huacai Chen

Hi, Song,

Quoted 19 lines · Song Hu

On a secondary CPU, setup_tlb_handler() allocates a NUMA-local page for the per-CPU TLB exception vectors and silently returns if the allocation fails. The CPU keeps running on the shared vectors that configure_exception_vector() installed earlier in per_cpu_trap_init(), losing NUMA locality with nothing logged. Warn so the fallback is observable.

---
 arch/loongarch/mm/tlb.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
arch/loongarch/mm/tlb.c +0 -0
index aaf7d685cc2a..e5220653279c 100644
@@ -297,8 +297,11 @@ static void setup_tlb_handler(int cpu)
                        return;
 
Quoted 9 lines

arch/loongarch/mm/tlb.c static void setup_tlb_handler(int cpu) · line 304

Quoted 7 lines
arch/loongarch/mm/tlb.c +4 -1
                page = alloc_pages_node(cpu_to_node(cpu), GFP_ATOMIC, get_order(vec_sz));
-               if (!page)
+               if (!page) {
+                       pr_warn("CPU%d: TLB vector allocation failed; "
+                               "using shared vectors\n", cpu);
                        return;
+               }

A warning usually make users nervous, this failure completely doesn't hurt anything, why you want to shout loudly here?

You're right — the fallback is completely benign and a pr_warn is too loud for something that doesn't affect functionality.  I'll drop this patch.

Thanks,
Song Hu

Quoted 7 lines

Huacai

Quoted 5 lines
arch/loongarch/mm/tlb.c +0 -1
                addr = page_address(page);
                pcpu_handlers[cpu] = (unsigned long)addr;
--

2.43.0