From 1caac0a4cd3027de123306ac7b12bf4c0393f3ed Mon Sep 17 00:00:00 2001 From: Glenn Elliott Date: Fri, 7 Dec 2012 14:31:07 -0500 Subject: 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). --- litmus/litmus.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) 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 @@ #include #include #include +#include #include #include @@ -704,6 +705,25 @@ static struct sysrq_key_op sysrq_kill_rt_tasks_op = { extern struct sched_plugin linux_sched_plugin; +static int litmus_shutdown_nb(struct notifier_block *unused1, + unsigned long unused2, void *unused3) +{ + /* Attempt to switch back to regular Linux scheduling. + * Forces the active plugin to clean up. + */ + if (litmus != &linux_sched_plugin) { + int ret = switch_sched_plugin(&linux_sched_plugin); + if (ret) { + printk("Auto-shutdown of active Litmus plugin failed.\n"); + } + } + return NOTIFY_DONE; +} + +static struct notifier_block shutdown_notifier = { + .notifier_call = litmus_shutdown_nb, +}; + static int __init _init_litmus(void) { /* Common initializers, @@ -733,11 +753,15 @@ static int __init _init_litmus(void) init_topology(); #endif + register_reboot_notifier(&shutdown_notifier); + return 0; } static void _exit_litmus(void) { + unregister_reboot_notifier(&shutdown_notifier); + exit_litmus_proc(); kmem_cache_destroy(bheap_node_cache); kmem_cache_destroy(release_heap_cache); -- cgit v1.2.2