Skip to contentSkip to conversation

percpu data for non-existant cpus

DISCUSSION Jack Steiner 3 participants 3 messages Nov 4, 2003

lore
Share & tools
lore
#0 lore raw

It was neccessary in 2.4 to allocate cpu_data areas for non-existent cpus. I forget where, but some generic initialization code expected to be able to reference cpu_data for all cpus up to NR_CPUS.

Does 2.6 have the same requirement or can I allocate cpu_data areas only for cpus that exist or might exist (cpu_possible()).

Signature · 4 lines
Thanks

Jack Steiner ([email protected])          651-683-5302
Principal Engineer                      SGI - Silicon Graphics, Inc.
#1 lore raw

Hi,

From: Jack Steiner <[email protected]>
Subject: percpu data for non-existant cpus
Date: Mon, 3 Nov 2003 18:55:24 -0600

Quoted 7 lines

It was neccessary in 2.4 to allocate cpu_data areas for non-existent cpus. I forget where, but some generic initialization code expected to be able to reference cpu_data for all cpus up to NR_CPUS.

Does 2.6 have the same requirement or can I allocate cpu_data areas only for cpus that exist or might exist (cpu_possible()).

The current discontig (for both 2.4 & 2.6) only allocate cpu_data on existing nodes (which means existing cpus eventually), doesn't it?

We've found wrap_mmu_context() refers to all percpu data and if the any of the cpu_data is not valid,
it may cause panic.

Attached patches are for 2.4 & 2.6, which are harmless even when percpu data are allocated for non-existing cpus.

---
Takayoshi Kochi

arch/ia64/mm/tlb.c renamed from arch/ia64/mm/tlb.c.orig +1 -1
@@ -75,7 +75,7 @@
 	 * and because interrupts are disabled during context switch.
 	 */
 	for (i = 0; i < NR_CPUS; ++i)
-		if (i != smp_processor_id())
+		if (cpu_online(i) && (i != smp_processor_id()))
 			cpu_data(i)->need_tlb_flush = 1;
 	local_flush_tlb_all();
 }
arch/ia64/mm/tlb.c +1 -1
@@ -77,7 +77,7 @@
 	{
 		int cpu = get_cpu(); /* prevent preemption/migration */
 		for (i = 0; i < NR_CPUS; ++i)
-			if (i != cpu)
+			if (cpu_online(i) && (i != cpu))
 				per_cpu(ia64_need_tlb_flush, i) = 1;
 		put_cpu();
 	}
#2 lore raw
In reply to Jack Steiner

arch/ia64/mm/tlb.c line 83

Quoted 11 lines · Takayoshi Kochi
arch/ia64/mm/tlb.c +1 -1
@@ -77,7 +77,7 @@
 	{
 		int cpu = get_cpu(); /* prevent preemption/migration */
 		for (i = 0; i < NR_CPUS; ++i)
-			if (i != cpu)
+			if (cpu_online(i) && (i != cpu))
 				per_cpu(ia64_need_tlb_flush, i) = 1;
 		put_cpu();
 	}

Surely this should rather be...

	{
		int cpu = get_cpu(); /* prevent preemption/migration */
-		for (i = 0; i < NR_CPUS; ++i)
+		for_each_cpu(i, cpu_online_map)
			if (i != cpu)
				per_cpu(ia64_need_tlb_flush, i) = 1;
		put_cpu();

I suppose one could create a new cpu_map based on cpu_online_map &~ cpu but that feels rather more heavyweight than a test inside a loop.

Signature · 3 lines
"It's not Hollywood.  War is real, war is primarily not about defeat or
victory, it is about death.  I've seen thousands and thousands of dead bodies.
Do you think I want to have an academic debate on this subject?" -- Robert Fisk