aboutsummaryrefslogtreecommitdiffstats
path: root/litmus/litmus.c
diff options
context:
space:
mode:
Diffstat (limited to 'litmus/litmus.c')
-rw-r--r--litmus/litmus.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/litmus/litmus.c b/litmus/litmus.c
index c842de46587b..9c6b738ab99d 100644
--- 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>
@@ -528,6 +529,25 @@ static struct sysrq_key_op sysrq_kill_rt_tasks_op = {
528 529
529extern struct sched_plugin linux_sched_plugin; 530extern struct sched_plugin linux_sched_plugin;
530 531
532static int litmus_shutdown_nb(struct notifier_block *unused1,
533 unsigned long unused2, void *unused3)
534{
535 /* Attempt to switch back to regular Linux scheduling.
536 * Forces the active plugin to clean up.
537 */
538 if (litmus != &linux_sched_plugin) {
539 int ret = switch_sched_plugin(&linux_sched_plugin);
540 if (ret) {
541 printk("Auto-shutdown of active Litmus plugin failed.\n");
542 }
543 }
544 return NOTIFY_DONE;
545}
546
547static struct notifier_block shutdown_notifier = {
548 .notifier_call = litmus_shutdown_nb,
549};
550
531static int __init _init_litmus(void) 551static int __init _init_litmus(void)
532{ 552{
533 /* Common initializers, 553 /* Common initializers,
@@ -555,11 +575,15 @@ static int __init _init_litmus(void)
555 init_topology(); 575 init_topology();
556#endif 576#endif
557 577
578 register_reboot_notifier(&shutdown_notifier);
579
558 return 0; 580 return 0;
559} 581}
560 582
561static void _exit_litmus(void) 583static void _exit_litmus(void)
562{ 584{
585 unregister_reboot_notifier(&shutdown_notifier);
586
563 exit_litmus_proc(); 587 exit_litmus_proc();
564 kmem_cache_destroy(bheap_node_cache); 588 kmem_cache_destroy(bheap_node_cache);
565 kmem_cache_destroy(release_heap_cache); 589 kmem_cache_destroy(release_heap_cache);