diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-12-07 14:31:07 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-12-07 14:31:07 -0500 |
commit | 1caac0a4cd3027de123306ac7b12bf4c0393f3ed (patch) | |
tree | 5c15b3198198b1cfc7678b4d52cd034a0070abf5 | |
parent | 983773f990053cb0ced72afb4b69594e5d32c779 (diff) |
Send reboot notifications to Litmus
This patch causes reboot notifications to be send
to Litmus. With this patch, Litmus attempts to
switch back to the Linux-plugin before the reboot
proceeds. Any failures to switch back are reported
via printk() (the reboot is not halted).
-rwxr-xr-x | litmus/litmus.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/litmus/litmus.c b/litmus/litmus.c index 8bc159b2fcce..065ef7d3192a 100755 --- a/litmus/litmus.c +++ b/litmus/litmus.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <linux/sched.h> | 9 | #include <linux/sched.h> |
10 | #include <linux/module.h> | 10 | #include <linux/module.h> |
11 | #include <linux/slab.h> | 11 | #include <linux/slab.h> |
12 | #include <linux/reboot.h> | ||
12 | 13 | ||
13 | #include <litmus/litmus.h> | 14 | #include <litmus/litmus.h> |
14 | #include <litmus/bheap.h> | 15 | #include <litmus/bheap.h> |
@@ -704,6 +705,25 @@ static struct sysrq_key_op sysrq_kill_rt_tasks_op = { | |||
704 | 705 | ||
705 | extern struct sched_plugin linux_sched_plugin; | 706 | extern struct sched_plugin linux_sched_plugin; |
706 | 707 | ||
708 | static int litmus_shutdown_nb(struct notifier_block *unused1, | ||
709 | unsigned long unused2, void *unused3) | ||
710 | { | ||
711 | /* Attempt to switch back to regular Linux scheduling. | ||
712 | * Forces the active plugin to clean up. | ||
713 | */ | ||
714 | if (litmus != &linux_sched_plugin) { | ||
715 | int ret = switch_sched_plugin(&linux_sched_plugin); | ||
716 | if (ret) { | ||
717 | printk("Auto-shutdown of active Litmus plugin failed.\n"); | ||
718 | } | ||
719 | } | ||
720 | return NOTIFY_DONE; | ||
721 | } | ||
722 | |||
723 | static struct notifier_block shutdown_notifier = { | ||
724 | .notifier_call = litmus_shutdown_nb, | ||
725 | }; | ||
726 | |||
707 | static int __init _init_litmus(void) | 727 | static int __init _init_litmus(void) |
708 | { | 728 | { |
709 | /* Common initializers, | 729 | /* Common initializers, |
@@ -733,11 +753,15 @@ static int __init _init_litmus(void) | |||
733 | init_topology(); | 753 | init_topology(); |
734 | #endif | 754 | #endif |
735 | 755 | ||
756 | register_reboot_notifier(&shutdown_notifier); | ||
757 | |||
736 | return 0; | 758 | return 0; |
737 | } | 759 | } |
738 | 760 | ||
739 | static void _exit_litmus(void) | 761 | static void _exit_litmus(void) |
740 | { | 762 | { |
763 | unregister_reboot_notifier(&shutdown_notifier); | ||
764 | |||
741 | exit_litmus_proc(); | 765 | exit_litmus_proc(); |
742 | kmem_cache_destroy(bheap_node_cache); | 766 | kmem_cache_destroy(bheap_node_cache); |
743 | kmem_cache_destroy(release_heap_cache); | 767 | kmem_cache_destroy(release_heap_cache); |