Skip to contentSkip to conversation

Do not update sysfs cpu registration from invalid context

PATCH Superseded Nathan Fontenot 3 participants 8 messages Jun 24, 2013 – Jun 25, 2013 PowerPC

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Do not update sysfs cpu registration from invalid context

The topology update code that updates the cpu node registration in sysfs should not be called while in stop_machine(). The register/unregister calls take a lock and may sleep.

This patch moves these calls outside of the call to stop_machine().

---
 arch/powerpc/mm/numa.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/powerpc/mm/numa.c +3 -2
Index: powerpc/arch/powerpc/mm/numa.c
===================================================================
@@ -1433,11 +1433,9 @@
 		if (cpu != update->cpu)
 			continue;
 
-		unregister_cpu_under_node(update->cpu, update->old_nid);
 		unmap_cpu_from_node(update->cpu);
 		map_cpu_to_node(update->cpu, update->new_nid);
 		vdso_getcpu_init();
-		register_cpu_under_node(update->cpu, update->new_nid);
 	}
 
 	return 0;
@@ -1485,6 +1483,9 @@
 	stop_machine(update_cpu_topology, &updates[0], &updated_cpus);
 
 	for (ud = &updates[0]; ud; ud = ud->next) {
+		unregister_cpu_under_node(update->cpu, update->old_nid);
+		register_cpu_under_node(update->cpu, update->new_nid);
+
 		dev = get_cpu_device(ud->cpu);
 		if (dev)
 			kobject_uevent(&dev->kobj, KOBJ_CHANGE);
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Nathan Fontenot

The topology update code that updates the cpu node registration in sysfs should not be called while in stop_machine(). The register/unregister calls take a lock and may sleep.

This patch moves these calls outside of the call to stop_machine().

Quoted 36 lines
---
 arch/powerpc/mm/numa.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Index: powerpc/arch/powerpc/mm/numa.c
===================================================================

arch/powerpc/mm/numa.c +3 -2
@@ -1433,11 +1433,9 @@
 		if (cpu != update->cpu)
 			continue;
 
-		unregister_cpu_under_node(update->cpu, update->old_nid);
 		unmap_cpu_from_node(update->cpu);
 		map_cpu_to_node(update->cpu, update->new_nid);
 		vdso_getcpu_init();
-		register_cpu_under_node(update->cpu, update->new_nid);
 	}
 
 	return 0;
@@ -1485,6 +1483,9 @@
 	stop_machine(update_cpu_topology, &updates[0], &updated_cpus);
 
 	for (ud = &updates[0]; ud; ud = ud->next) {
+		unregister_cpu_under_node(update->cpu, update->old_nid);
+		register_cpu_under_node(update->cpu, update->new_nid);
+
 		dev = get_cpu_device(ud->cpu);
 		if (dev)
 			kobject_uevent(&dev->kobj, KOBJ_CHANGE);

_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev

#2 lore raw
Quoted 10 lines · Seth Jennings
Quoted 7 lines · Nathan Fontenot

The topology update code that updates the cpu node registration in sysfs should not be called while in stop_machine(). The register/unregister calls take a lock and may sleep.

This patch moves these calls outside of the call to stop_machine().

Gah! I _knew_ I should have waited for my cross compiler to finish building. This thing doesn't build:

CC arch/powerpc/mm/numa.o
/home/sjennings/ltc/linux/arch/powerpc/mm/numa.c: In function 'arch_update_cpu_topology':
/home/sjennings/ltc/linux/arch/powerpc/mm/numa.c:1486: error: 'update' undeclared (first use in this function) /home/sjennings/ltc/linux/arch/powerpc/mm/numa.c:1486: error: (Each undeclared identifier is reported only once /home/sjennings/ltc/linux/arch/powerpc/mm/numa.c:1486: error: for each function it appears in.)

s/update/ud/ in the *_cpu_under_node() calls.

Seth

#3 lore raw
Quoted 15 lines · Seth Jennings
Quoted 10 lines · Seth Jennings
Quoted 7 lines · Nathan Fontenot

The topology update code that updates the cpu node registration in sysfs should not be called while in stop_machine(). The register/unregister calls take a lock and may sleep.

This patch moves these calls outside of the call to stop_machine().

Gah! I _knew_ I should have waited for my cross compiler to finish building. This thing doesn't build:

Quoted 7 lines

CC arch/powerpc/mm/numa.o
/home/sjennings/ltc/linux/arch/powerpc/mm/numa.c: In function 'arch_update_cpu_topology':
/home/sjennings/ltc/linux/arch/powerpc/mm/numa.c:1486: error: 'update' undeclared (first use in this function) /home/sjennings/ltc/linux/arch/powerpc/mm/numa.c:1486: error: (Each undeclared identifier is reported only once /home/sjennings/ltc/linux/arch/powerpc/mm/numa.c:1486: error: for each function it appears in.)

s/update/ud/ in the *_cpu_under_node() calls.

Oops! Time for patch submission re-education training.

New, and correct, patch coming soon.

-Nathan

#4 lore raw
Quoted 22 lines · Nathan Fontenot
Quoted 21 lines · Seth Jennings
Quoted 10 lines · Seth Jennings
Quoted 7 lines · Nathan Fontenot

The topology update code that updates the cpu node registration in sysfs should not be called while in stop_machine(). The register/unregister calls take a lock and may sleep.

This patch moves these calls outside of the call to stop_machine().

Gah! I _knew_ I should have waited for my cross compiler to finish building. This thing doesn't build:

CC arch/powerpc/mm/numa.o
/home/sjennings/ltc/linux/arch/powerpc/mm/numa.c: In function 'arch_update_cpu_topology':
/home/sjennings/ltc/linux/arch/powerpc/mm/numa.c:1486: error: 'update' undeclared (first use in this function) /home/sjennings/ltc/linux/arch/powerpc/mm/numa.c:1486: error: (Each undeclared identifier is reported only once /home/sjennings/ltc/linux/arch/powerpc/mm/numa.c:1486: error: for each function it appears in.)

Quoted 3 lines
Quoted 1 line

s/update/ud/ in the *_cpu_under_node() calls.

Oops! Time for patch submission re-education training.

We've all done it, but yes :)

I try to stick to:

1. write code.
2. build code.
3. test code.
4. submit code.

I imagine you tested an early version of the patch, or on RHEL or something, but that can bite you like this. Whenever possible you should build & test the exact code you submit, though that can be hard when trees are moving quickly underneath you.

cheers

#5 lore raw
Quoted 25 lines · Michael Ellerman
Quoted 24 lines · Nathan Fontenot
Quoted 22 lines · Seth Jennings
Quoted 10 lines · Seth Jennings
Quoted 7 lines · Nathan Fontenot

The topology update code that updates the cpu node registration in sysfs should not be called while in stop_machine(). The register/unregister calls take a lock and may sleep.

This patch moves these calls outside of the call to stop_machine().

Gah! I _knew_ I should have waited for my cross compiler to finish building. This thing doesn't build:

CC arch/powerpc/mm/numa.o
/home/sjennings/ltc/linux/arch/powerpc/mm/numa.c: In function 'arch_update_cpu_topology':
/home/sjennings/ltc/linux/arch/powerpc/mm/numa.c:1486: error: 'update' undeclared (first use in this function) /home/sjennings/ltc/linux/arch/powerpc/mm/numa.c:1486: error: (Each undeclared identifier is reported only once /home/sjennings/ltc/linux/arch/powerpc/mm/numa.c:1486: error: for each function it appears in.)

s/update/ud/ in the *_cpu_under_node() calls.

Quoted 7 lines
Quoted 1 line

Oops! Time for patch submission re-education training.

We've all done it, but yes :)

I try to stick to:

1. write code.

I would suggest
1a. ensure you have the proper config options set

Quoted 8 lines

2. build code.
3. test code.
4. submit code.

I imagine you tested an early version of the patch, or on RHEL or something, but that can bite you like this. Whenever possible you should build & test the exact code you submit, though that can be hard when trees are moving quickly underneath you.

Yep, bitten by 1a. I didn't verify the config options I was building with and had SMP disabled in the tree. This ifdef'ed out my code.

-Nathan

#6 lore raw
In reply to Nathan Fontenot
Quoted 5 lines · Nathan Fontenot

The topology update code that updates the cpu node registration in sysfs should not be called while in stop_machine(). The register/unregister calls take a lock and may sleep.

This patch moves these calls outside of the call to stop_machine().

What happens? Do we lockup or do you just get a warning?

And what commit introduced the breakage?

cheers

#7 lore raw
Quoted 10 lines · Michael Ellerman
Quoted 5 lines · Nathan Fontenot

The topology update code that updates the cpu node registration in sysfs should not be called while in stop_machine(). The register/unregister calls take a lock and may sleep.

This patch moves these calls outside of the call to stop_machine().

What happens? Do we lockup or do you just get a warning?

And what commit introduced the breakage?

Guilty on on all counts. Hopefully I can still get by with stern warning.

-Nathan