diff options
author | Akinobu Mita <akinobu.mita@gmail.com> | 2010-08-31 23:00:08 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2010-09-01 01:33:34 -0400 |
commit | eac243355a99d6b9d41bbeba4fc83e7f735485f9 (patch) | |
tree | 39cd6ab8a7e48dcc0d59085a674dcda84844e041 | |
parent | 46b93b74fc022885ab69dfc8e2af0562dd626638 (diff) |
lockup_detector: Convert cpu notifier to return encapsulate errno value
By the commit e6bde73b07edeb703d4c89c1daabc09c303de11f
("cpu-hotplug: return better errno on cpu hotplug failure"),
the cpu notifier can return encapsulate errno value, resulting
in more meaningful error codes for CPU hotplug failures.
This converts the cpu notifier to return encapsulate errno value
for the lockup_detector as well.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: peterz@infradead.org
Cc: gorcunov@gmail.com
Cc: fweisbec@gmail.com
LKML-Reference: <1283310009-22168-3-git-send-email-dzickus@redhat.com>
Signed-off-by: Don Zickus <dzickus@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | kernel/watchdog.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/kernel/watchdog.c b/kernel/watchdog.c index 0d53c8e853b1..501cb6edca4b 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c | |||
@@ -371,7 +371,7 @@ static int watchdog_nmi_enable(int cpu) | |||
371 | } | 371 | } |
372 | 372 | ||
373 | printk(KERN_ERR "NMI watchdog failed to create perf event on cpu%i: %p\n", cpu, event); | 373 | printk(KERN_ERR "NMI watchdog failed to create perf event on cpu%i: %p\n", cpu, event); |
374 | return -1; | 374 | return PTR_ERR(event); |
375 | 375 | ||
376 | /* success path */ | 376 | /* success path */ |
377 | out_save: | 377 | out_save: |
@@ -415,17 +415,19 @@ static int watchdog_prepare_cpu(int cpu) | |||
415 | static int watchdog_enable(int cpu) | 415 | static int watchdog_enable(int cpu) |
416 | { | 416 | { |
417 | struct task_struct *p = per_cpu(softlockup_watchdog, cpu); | 417 | struct task_struct *p = per_cpu(softlockup_watchdog, cpu); |
418 | int err; | ||
418 | 419 | ||
419 | /* enable the perf event */ | 420 | /* enable the perf event */ |
420 | if (watchdog_nmi_enable(cpu) != 0) | 421 | err = watchdog_nmi_enable(cpu); |
421 | return -1; | 422 | if (err) |
423 | return err; | ||
422 | 424 | ||
423 | /* create the watchdog thread */ | 425 | /* create the watchdog thread */ |
424 | if (!p) { | 426 | if (!p) { |
425 | p = kthread_create(watchdog, (void *)(unsigned long)cpu, "watchdog/%d", cpu); | 427 | p = kthread_create(watchdog, (void *)(unsigned long)cpu, "watchdog/%d", cpu); |
426 | if (IS_ERR(p)) { | 428 | if (IS_ERR(p)) { |
427 | printk(KERN_ERR "softlockup watchdog for %i failed\n", cpu); | 429 | printk(KERN_ERR "softlockup watchdog for %i failed\n", cpu); |
428 | return -1; | 430 | return PTR_ERR(p); |
429 | } | 431 | } |
430 | kthread_bind(p, cpu); | 432 | kthread_bind(p, cpu); |
431 | per_cpu(watchdog_touch_ts, cpu) = 0; | 433 | per_cpu(watchdog_touch_ts, cpu) = 0; |
@@ -519,17 +521,16 @@ static int __cpuinit | |||
519 | cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) | 521 | cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) |
520 | { | 522 | { |
521 | int hotcpu = (unsigned long)hcpu; | 523 | int hotcpu = (unsigned long)hcpu; |
524 | int err = 0; | ||
522 | 525 | ||
523 | switch (action) { | 526 | switch (action) { |
524 | case CPU_UP_PREPARE: | 527 | case CPU_UP_PREPARE: |
525 | case CPU_UP_PREPARE_FROZEN: | 528 | case CPU_UP_PREPARE_FROZEN: |
526 | if (watchdog_prepare_cpu(hotcpu)) | 529 | err = watchdog_prepare_cpu(hotcpu); |
527 | return NOTIFY_BAD; | ||
528 | break; | 530 | break; |
529 | case CPU_ONLINE: | 531 | case CPU_ONLINE: |
530 | case CPU_ONLINE_FROZEN: | 532 | case CPU_ONLINE_FROZEN: |
531 | if (watchdog_enable(hotcpu)) | 533 | err = watchdog_enable(hotcpu); |
532 | return NOTIFY_BAD; | ||
533 | break; | 534 | break; |
534 | #ifdef CONFIG_HOTPLUG_CPU | 535 | #ifdef CONFIG_HOTPLUG_CPU |
535 | case CPU_UP_CANCELED: | 536 | case CPU_UP_CANCELED: |
@@ -542,7 +543,7 @@ cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) | |||
542 | break; | 543 | break; |
543 | #endif /* CONFIG_HOTPLUG_CPU */ | 544 | #endif /* CONFIG_HOTPLUG_CPU */ |
544 | } | 545 | } |
545 | return NOTIFY_OK; | 546 | return notifier_from_errno(err); |
546 | } | 547 | } |
547 | 548 | ||
548 | static struct notifier_block __cpuinitdata cpu_nfb = { | 549 | static struct notifier_block __cpuinitdata cpu_nfb = { |
@@ -558,7 +559,7 @@ static int __init spawn_watchdog_task(void) | |||
558 | return 0; | 559 | return 0; |
559 | 560 | ||
560 | err = cpu_callback(&cpu_nfb, CPU_UP_PREPARE, cpu); | 561 | err = cpu_callback(&cpu_nfb, CPU_UP_PREPARE, cpu); |
561 | WARN_ON(err == NOTIFY_BAD); | 562 | WARN_ON(notifier_to_errno(err)); |
562 | 563 | ||
563 | cpu_callback(&cpu_nfb, CPU_ONLINE, cpu); | 564 | cpu_callback(&cpu_nfb, CPU_ONLINE, cpu); |
564 | register_cpu_notifier(&cpu_nfb); | 565 | register_cpu_notifier(&cpu_nfb); |