public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cpu hoptlug: avoid usage of smp_processor_id() in preemptible code
@ 2005-11-01 14:54 Heiko Carstens
  2005-11-02  6:48 ` Ingo Molnar
  0 siblings, 1 reply; 3+ messages in thread
From: Heiko Carstens @ 2005-11-01 14:54 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel

From: Heiko Carstens <heiko.carstens@de.ibm.com>

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.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---

diffstat:
 kernel/sched.c      |    3 ++-
 kernel/softirq.c    |    3 ++-
 kernel/softlockup.c |    3 ++-
 kernel/workqueue.c  |    2 +-
 4 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/kernel/sched.c b/kernel/sched.c
index 340dd23..d94ceef 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -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;
diff --git a/kernel/softirq.c b/kernel/softirq.c
index f766b2f..ad3295c 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -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;
diff --git a/kernel/softlockup.c b/kernel/softlockup.c
index 7597620..a2dcceb 100644
--- a/kernel/softlockup.c
+++ b/kernel/softlockup.c
@@ -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;
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 7cee222..42df83d 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -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;

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] cpu hoptlug: avoid usage of smp_processor_id() in preemptible code
  2005-11-01 14:54 [PATCH] cpu hoptlug: avoid usage of smp_processor_id() in preemptible code Heiko Carstens
@ 2005-11-02  6:48 ` Ingo Molnar
  2005-11-02  7:07   ` Heiko Carstens
  0 siblings, 1 reply; 3+ messages in thread
From: Ingo Molnar @ 2005-11-02  6:48 UTC (permalink / raw)
  To: Heiko Carstens; +Cc: Andrew Morton, linux-kernel


* Heiko Carstens <heiko.carstens@de.ibm.com> wrote:

> From: Heiko Carstens <heiko.carstens@de.ibm.com>
> 
> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] cpu hoptlug: avoid usage of smp_processor_id() in preemptible code
  2005-11-02  6:48 ` Ingo Molnar
@ 2005-11-02  7:07   ` Heiko Carstens
  0 siblings, 0 replies; 3+ messages in thread
From: Heiko Carstens @ 2005-11-02  7:07 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Andrew Morton, linux-kernel

> > From: Heiko Carstens <heiko.carstens@de.ibm.com>
> > 
> > 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-11-02  7:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-01 14:54 [PATCH] cpu hoptlug: avoid usage of smp_processor_id() in preemptible code Heiko Carstens
2005-11-02  6:48 ` Ingo Molnar
2005-11-02  7:07   ` Heiko Carstens

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox