Skip to contentSkip to conversation

cpu hoptlug: avoid usage of smp_processor_id() in preemptible code

PATCH In review Heiko Carstens 2 participants 3 messages Nov 1, 2005 – Nov 2, 2005 Workqueue

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cpu hoptlug: avoid usage of smp_processor_id() in preemptible code

From: Heiko Carstens <[email protected]>

Replace smp_processor_id() with any_online_cpu(cpu_online_map) in order to avoid lots of
"BUG: using smp_processor_id() in preemptible [00000001] code:..." messages in case taking a cpu online fails.

---

diffstat:

 kernel/sched.c      |    3 ++-
 kernel/softirq.c    |    3 ++-
 kernel/softlockup.c |    3 ++-
 kernel/workqueue.c  |    2 +-
 4 files changed, 7 insertions(+), 4 deletions(-)
kernel/sched.c +2 -1
index 340dd23..d94ceef 100644
@@ -4680,7 +4680,8 @@ static int migration_call(struct notifie
 #ifdef CONFIG_HOTPLUG_CPU
 	case CPU_UP_CANCELED:
 		/* Unbind it from offline cpu so it can run.  Fall thru. */
-		kthread_bind(cpu_rq(cpu)->migration_thread,smp_processor_id());
+		kthread_bind(cpu_rq(cpu)->migration_thread,
+			     any_online_cpu(cpu_online_map));
 		kthread_stop(cpu_rq(cpu)->migration_thread);
 		cpu_rq(cpu)->migration_thread = NULL;
 		break;
kernel/softirq.c +2 -1
index f766b2f..ad3295c 100644
@@ -470,7 +470,8 @@ static int __devinit cpu_callback(struct
 #ifdef CONFIG_HOTPLUG_CPU
 	case CPU_UP_CANCELED:
 		/* Unbind so it can run.  Fall thru. */
-		kthread_bind(per_cpu(ksoftirqd, hotcpu), smp_processor_id());
+		kthread_bind(per_cpu(ksoftirqd, hotcpu),
+			     any_online_cpu(cpu_online_map));
 	case CPU_DEAD:
 		p = per_cpu(ksoftirqd, hotcpu);
 		per_cpu(ksoftirqd, hotcpu) = NULL;
kernel/softlockup.c +2 -1
index 7597620..a2dcceb 100644
@@ -123,7 +123,8 @@ cpu_callback(struct notifier_block *nfb,
 #ifdef CONFIG_HOTPLUG_CPU
 	case CPU_UP_CANCELED:
 		/* Unbind so it can run.  Fall thru. */
-		kthread_bind(per_cpu(watchdog_task, hotcpu), smp_processor_id());
+		kthread_bind(per_cpu(watchdog_task, hotcpu),
+			     any_online_cpu(cpu_online_map));
 	case CPU_DEAD:
 		p = per_cpu(watchdog_task, hotcpu);
 		per_cpu(watchdog_task, hotcpu) = NULL;
kernel/workqueue.c +1 -1
index 7cee222..42df83d 100644
@@ -524,7 +524,7 @@ static int __devinit workqueue_cpu_callb
 		list_for_each_entry(wq, &workqueues, list) {
 			/* Unbind so it can run. */
 			kthread_bind(per_cpu_ptr(wq->cpu_wq, hotcpu)->thread,
-				     smp_processor_id());
+				     any_online_cpu(cpu_online_map));
 			cleanup_workqueue_thread(wq, hotcpu);
 		}
 		break;
#1 lore raw
Quoted 5 lines · Heiko Carstens

From: Heiko Carstens <[email protected]>

Replace smp_processor_id() with any_online_cpu(cpu_online_map) in order to avoid lots of "BUG: using smp_processor_id() in preemptible [00000001] code:..." messages in case taking a cpu online fails.

could you post the full message, including the stacktrace? I think this patch just works around the debugging message, and there might be some real bug to fix.

Ingo

#2 lore raw
Quoted 11 lines
Quoted 5 lines

From: Heiko Carstens <[email protected]>

Replace smp_processor_id() with any_online_cpu(cpu_online_map) in order to avoid lots of "BUG: using smp_processor_id() in preemptible [00000001] code:..." messages in case taking a cpu online fails.

could you post the full message, including the stacktrace? I think this patch just works around the debugging message, and there might be some real bug to fix.

Ingo

Sure, all traces start actually at the last notifier_call_chain(...) in kernel/cpu.c. Since we hold the cpu_control semaphore it shouldn't be any problem to access cpu_online_map.
The reason why cpu_up failed is simply that the cpu that was supposed to be taken online wasn't even there. That is because on s390 we never know when a new cpu comes and therefore cpu_possible_map consists of only ones and doesn't reflect reality.

Heiko

BUG: using smp_processor_id() in preemptible [00000001] code: bash/1398
caller is migration_call+0x1c8/0x920
000000000d377928 07d9fe4c616704cc 0000000000357d22 0000000000357d22 
       0000000000015dc8 00000000004e3838 000000000dc6a500 000000000d9c5180 
       00000000004072e0 0000000000000000 000000000d377888 000000000d3778d8 
       000000000000000c 000000000032e040 0000000000015dc8 000000000d377888 
       0000000000000004 0000000000000000 000000000d3779c8 000000000d377928 
Call Trace:
([<0000000000015d5c>] show_trace+0xbc/0xd0)
 [<0000000000149fb6>] debug_smp_processor_id+0xee/0xf4
 [<000000000002ac48>] migration_call+0x1c8/0x920
 [<0000000000043292>] notifier_call_chain+0x46/0x84
 [<0000000000052c06>] cpu_up+0x16a/0x1c0
 [<000000000015bc92>] store_online+0xae/0xe0
 [<00000000000d3af0>] sysfs_write_file+0x150/0x1c4
 [<000000000008963a>] vfs_write+0xae/0x184
 [<000000000008a186>] sys_write+0x52/0x84
 [<00000000000211e6>] sysc_do_restart+0x16/0x1c
 [<0000020000107e24>] 0x20000107e24

BUG: using smp_processor_id() in preemptible [00000001] code: bash/1398
caller is cpu_callback+0x156/0x360
000000000d377980 000000000d377870 0000000000357d22 0000000000357d22 
       0000000000015dc8 000000000d374000 000000000dc6a500 0000020000020000 
       00000000004072e0 0000000000000000 000000000d3778e0 000000000d377930 
       000000000000000c 000000000032e040 0000000000015dc8 000000000d3778e0 
       0000000000000004 0000000000000000 000000000d377a20 000000000d377980 
Call Trace:
([<0000000000015d5c>] show_trace+0xbc/0xd0)
 [<0000000000149fb6>] debug_smp_processor_id+0xee/0xf4
 [<0000000000038a4a>] cpu_callback+0x156/0x360
 [<0000000000043292>] notifier_call_chain+0x46/0x84
 [<0000000000052c06>] cpu_up+0x16a/0x1c0
 [<000000000015bc92>] store_online+0xae/0xe0
 [<00000000000d3af0>] sysfs_write_file+0x150/0x1c4
 [<000000000008963a>] vfs_write+0xae/0x184
 [<000000000008a186>] sys_write+0x52/0x84
 [<00000000000211e6>] sysc_do_restart+0x16/0x1c
 [<0000020000107e24>] 0x20000107e24

BUG: using smp_processor_id() in preemptible [00000001] code: bash/1398
caller is cpu_callback+0x138/0x1c0
000000000d377988 0000000000a2f1b0 0000000000357d22 0000000000357d22 
       0000000000015dc8 000000000d374000 000000000dc6a500 0000020000020000 
       00000000004072e0 0000000000000000 000000000d3778e8 000000000d377938 
       000000000000000c 000000000032e040 0000000000015dc8 000000000d3778e8 
       0000000000000004 0000000000000000 000000000d377a28 000000000d377988 
Call Trace:
([<0000000000015d5c>] show_trace+0xbc/0xd0)
 [<0000000000149fb6>] debug_smp_processor_id+0xee/0xf4
 [<000000000005c00c>] cpu_callback+0x138/0x1c0
 [<0000000000043292>] notifier_call_chain+0x46/0x84
 [<0000000000052c06>] cpu_up+0x16a/0x1c0
 [<000000000015bc92>] store_online+0xae/0xe0
 [<00000000000d3af0>] sysfs_write_file+0x150/0x1c4
 [<000000000008963a>] vfs_write+0xae/0x184
 [<000000000008a186>] sys_write+0x52/0x84
 [<00000000000211e6>] sysc_do_restart+0x16/0x1c
 [<0000020000107e24>] 0x20000107e24

BUG: using smp_processor_id() in preemptible [00000001] code: bash/1398
caller is workqueue_cpu_callback+0x17c/0x358
000000000d377978 000000000ebb1280 0000000000357d22 0000000000357d22 
       0000000000015dc8 000000000d374000 000000000dc6a500 0000000000000009 
       00000000004072e0 0000000000000000 000000000d3778d8 000000000d377928 
       000000000000000c 000000000032e040 0000000000015dc8 000000000d3778d8 
       0000000000000004 0000000000000000 000000000d377a18 000000000d377978 
Call Trace:
([<0000000000015d5c>] show_trace+0xbc/0xd0)
 [<0000000000149fb6>] debug_smp_processor_id+0xee/0xf4
 [<00000000000472ac>] workqueue_cpu_callback+0x17c/0x358
 [<0000000000043292>] notifier_call_chain+0x46/0x84
 [<0000000000052c06>] cpu_up+0x16a/0x1c0
 [<000000000015bc92>] store_online+0xae/0xe0
 [<00000000000d3af0>] sysfs_write_file+0x150/0x1c4
 [<000000000008963a>] vfs_write+0xae/0x184
 [<000000000008a186>] sys_write+0x52/0x84
 [<00000000000211e6>] sysc_do_restart+0x16/0x1c
 [<0000020000107e24>] 0x20000107e24

BUG: using smp_processor_id() in preemptible [00000001] code: bash/1398
caller is workqueue_cpu_callback+0x17c/0x358
000000000d377978 000000000d377888 0000000000357d22 0000000000357d22 
       0000000000015dc8 000000000d374000 000000000dc6a500 0000000000000009 
       00000000004072e0 0000000000000000 000000000d3778d8 000000000d377928 
       000000000000000c 000000000032e040 0000000000015dc8 000000000d3778d8 
       0000000000000004 0000000000000000 000000000d377a18 000000000d377978 
Call Trace:
([<0000000000015d5c>] show_trace+0xbc/0xd0)
 [<0000000000149fb6>] debug_smp_processor_id+0xee/0xf4
 [<00000000000472ac>] workqueue_cpu_callback+0x17c/0x358
 [<0000000000043292>] notifier_call_chain+0x46/0x84
 [<0000000000052c06>] cpu_up+0x16a/0x1c0
 [<000000000015bc92>] store_online+0xae/0xe0
 [<00000000000d3af0>] sysfs_write_file+0x150/0x1c4
 [<000000000008963a>] vfs_write+0xae/0x184
 [<000000000008a186>] sys_write+0x52/0x84
 [<00000000000211e6>] sysc_do_restart+0x16/0x1c
 [<0000020000107e24>] 0x20000107e24

BUG: using smp_processor_id() in preemptible [00000001] code: bash/1398
caller is workqueue_cpu_callback+0x17c/0x358
000000000d377978 000000000d377888 0000000000357d22 0000000000357d22 
       0000000000015dc8 000000000d374000 000000000dc6a500 0000000000000009 
       00000000004072e0 0000000000000000 000000000d3778d8 000000000d377928 
       000000000000000c 000000000032e040 0000000000015dc8 000000000d3778d8 
       0000000000000004 0000000000000000 000000000d377a18 000000000d377978 
Call Trace:
([<0000000000015d5c>] show_trace+0xbc/0xd0)
 [<0000000000149fb6>] debug_smp_processor_id+0xee/0xf4
 [<00000000000472ac>] workqueue_cpu_callback+0x17c/0x358
 [<0000000000043292>] notifier_call_chain+0x46/0x84
 [<0000000000052c06>] cpu_up+0x16a/0x1c0
 [<000000000015bc92>] store_online+0xae/0xe0
 [<00000000000d3af0>] sysfs_write_file+0x150/0x1c4
 [<000000000008963a>] vfs_write+0xae/0x184
 [<000000000008a186>] sys_write+0x52/0x84
 [<00000000000211e6>] sysc_do_restart+0x16/0x1c
 [<0000020000107e24>] 0x20000107e24

BUG: using smp_processor_id() in preemptible [00000001] code: bash/1398
caller is workqueue_cpu_callback+0x17c/0x358
000000000d377978 000000000d377888 0000000000357d22 0000000000357d22 
       0000000000015dc8 000000000d374000 000000000dc6a500 0000000000000009 
       00000000004072e0 0000000000000000 000000000d3778d8 000000000d377928 
       000000000000000c 000000000032e040 0000000000015dc8 000000000d3778d8 
       0000000000000004 0000000000000000 000000000d377a18 000000000d377978 
Call Trace:
([<0000000000015d5c>] show_trace+0xbc/0xd0)
 [<0000000000149fb6>] debug_smp_processor_id+0xee/0xf4
 [<00000000000472ac>] workqueue_cpu_callback+0x17c/0x358
 [<0000000000043292>] notifier_call_chain+0x46/0x84
 [<0000000000052c06>] cpu_up+0x16a/0x1c0
 [<000000000015bc92>] store_online+0xae/0xe0
 [<00000000000d3af0>] sysfs_write_file+0x150/0x1c4
 [<000000000008963a>] vfs_write+0xae/0x184
 [<000000000008a186>] sys_write+0x52/0x84
 [<00000000000211e6>] sysc_do_restart+0x16/0x1c
 [<0000020000107e24>] 0x20000107e24

BUG: using smp_processor_id() in preemptible [00000001] code: bash/1398
caller is workqueue_cpu_callback+0x17c/0x358
000000000d377978 000000000d377888 0000000000357d22 0000000000357d22 
       0000000000015dc8 000000000d374000 000000000dc6a500 0000000000000009 
       00000000004072e0 0000000000000000 000000000d3778d8 000000000d377928 
       000000000000000c 000000000032e040 0000000000015dc8 000000000d3778d8 
       0000000000000004 0000000000000000 000000000d377a18 000000000d377978 
Call Trace:
([<0000000000015d5c>] show_trace+0xbc/0xd0)
 [<0000000000149fb6>] debug_smp_processor_id+0xee/0xf4
 [<00000000000472ac>] workqueue_cpu_callback+0x17c/0x358
 [<0000000000043292>] notifier_call_chain+0x46/0x84
 [<0000000000052c06>] cpu_up+0x16a/0x1c0
 [<000000000015bc92>] store_online+0xae/0xe0
 [<00000000000d3af0>] sysfs_write_file+0x150/0x1c4
 [<000000000008963a>] vfs_write+0xae/0x184
 [<000000000008a186>] sys_write+0x52/0x84
 [<00000000000211e6>] sysc_do_restart+0x16/0x1c
 [<0000020000107e24>] 0x20000107e24