diff options
author | Christopher Kenna <cjk@cs.unc.edu> | 2010-10-22 17:26:38 -0400 |
---|---|---|
committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2010-10-23 01:35:14 -0400 |
commit | 98f56816fcb5c97e0afd21a6e242bb72d5b7a551 (patch) | |
tree | d57ce043d568356d1050c74db6b512fed4783a79 /litmus/litmus.c | |
parent | 3dd41424090a0ca3a660218d06afe6ff4441bad3 (diff) |
Litmus core: per-plugin proc directories
Change the Litmus proc layout so that loaded plugins are visible in
/proc/litmus/plugins/loaded and add Litmus functions make_plugin_proc_dir()
and remove_plugin_proc_dir() to add per-plugin proc directories.
Diffstat (limited to 'litmus/litmus.c')
-rw-r--r-- | litmus/litmus.c | 62 |
1 files changed, 59 insertions, 3 deletions
diff --git a/litmus/litmus.c b/litmus/litmus.c index e854ba317762..3b73b39ffbbf 100644 --- a/litmus/litmus.c +++ b/litmus/litmus.c | |||
@@ -8,12 +8,10 @@ | |||
8 | #include <linux/sysrq.h> | 8 | #include <linux/sysrq.h> |
9 | 9 | ||
10 | #include <linux/module.h> | 10 | #include <linux/module.h> |
11 | #include <linux/proc_fs.h> | ||
12 | #include <linux/slab.h> | 11 | #include <linux/slab.h> |
13 | 12 | ||
14 | #include <litmus/litmus.h> | 13 | #include <litmus/litmus.h> |
15 | #include <linux/sched.h> | 14 | #include <linux/sched.h> |
16 | #include <litmus/sched_plugin.h> | ||
17 | 15 | ||
18 | #include <litmus/bheap.h> | 16 | #include <litmus/bheap.h> |
19 | 17 | ||
@@ -687,6 +685,7 @@ static int proc_write_release_master(struct file *file, | |||
687 | static struct proc_dir_entry *litmus_dir = NULL, | 685 | static struct proc_dir_entry *litmus_dir = NULL, |
688 | *curr_file = NULL, | 686 | *curr_file = NULL, |
689 | *stat_file = NULL, | 687 | *stat_file = NULL, |
688 | *plugs_dir = NULL, | ||
690 | *plugs_file = NULL, | 689 | *plugs_file = NULL, |
691 | #ifdef CONFIG_RELEASE_MASTER | 690 | #ifdef CONFIG_RELEASE_MASTER |
692 | *release_master_file = NULL, | 691 | *release_master_file = NULL, |
@@ -736,7 +735,14 @@ static int __init init_litmus_proc(void) | |||
736 | stat_file = create_proc_read_entry("stats", 0444, litmus_dir, | 735 | stat_file = create_proc_read_entry("stats", 0444, litmus_dir, |
737 | proc_read_stats, NULL); | 736 | proc_read_stats, NULL); |
738 | 737 | ||
739 | plugs_file = create_proc_read_entry("plugins", 0444, litmus_dir, | 738 | plugs_dir = proc_mkdir("plugins", litmus_dir); |
739 | if (!plugs_dir){ | ||
740 | printk(KERN_ERR "Could not allocate plugins directory " | ||
741 | "procfs entry.\n"); | ||
742 | return -ENOMEM; | ||
743 | } | ||
744 | |||
745 | plugs_file = create_proc_read_entry("loaded", 0444, plugs_dir, | ||
740 | proc_read_plugins, NULL); | 746 | proc_read_plugins, NULL); |
741 | 747 | ||
742 | return 0; | 748 | return 0; |
@@ -745,6 +751,8 @@ static int __init init_litmus_proc(void) | |||
745 | static void exit_litmus_proc(void) | 751 | static void exit_litmus_proc(void) |
746 | { | 752 | { |
747 | if (plugs_file) | 753 | if (plugs_file) |
754 | remove_proc_entry("loaded", plugs_dir); | ||
755 | if (plugs_dir) | ||
748 | remove_proc_entry("plugins", litmus_dir); | 756 | remove_proc_entry("plugins", litmus_dir); |
749 | if (stat_file) | 757 | if (stat_file) |
750 | remove_proc_entry("stats", litmus_dir); | 758 | remove_proc_entry("stats", litmus_dir); |
@@ -760,6 +768,54 @@ static void exit_litmus_proc(void) | |||
760 | remove_proc_entry("litmus", NULL); | 768 | remove_proc_entry("litmus", NULL); |
761 | } | 769 | } |
762 | 770 | ||
771 | long make_plugin_proc_dir(struct sched_plugin* plugin, | ||
772 | struct proc_dir_entry** pde_in) | ||
773 | { | ||
774 | struct proc_dir_entry *pde_new = NULL; | ||
775 | long rv; | ||
776 | |||
777 | if (!plugin || !plugin->plugin_name){ | ||
778 | printk(KERN_ERR "Invalid plugin struct passed to %s.\n", | ||
779 | __func__); | ||
780 | rv = -EINVAL; | ||
781 | goto out_no_pde; | ||
782 | } | ||
783 | |||
784 | if (!plugs_dir){ | ||
785 | printk(KERN_ERR "Could not make plugin sub-directory, because " | ||
786 | "/proc/litmus/plugins does not exist.\n"); | ||
787 | rv = -ENOENT; | ||
788 | goto out_no_pde; | ||
789 | } | ||
790 | |||
791 | pde_new = proc_mkdir(plugin->plugin_name, plugs_dir); | ||
792 | if (!pde_new){ | ||
793 | printk(KERN_ERR "Could not make plugin sub-directory: " | ||
794 | "out of memory?.\n"); | ||
795 | rv = -ENOMEM; | ||
796 | goto out_no_pde; | ||
797 | } | ||
798 | |||
799 | rv = 0; | ||
800 | *pde_in = pde_new; | ||
801 | goto out_ok; | ||
802 | |||
803 | out_no_pde: | ||
804 | *pde_in = NULL; | ||
805 | out_ok: | ||
806 | return rv; | ||
807 | } | ||
808 | |||
809 | void remove_plugin_proc_dir(struct sched_plugin* plugin) | ||
810 | { | ||
811 | if (!plugin || !plugin->plugin_name){ | ||
812 | printk(KERN_ERR "Invalid plugin struct passed to %s.\n", | ||
813 | __func__); | ||
814 | return; | ||
815 | } | ||
816 | remove_proc_entry(plugin->plugin_name, plugs_dir); | ||
817 | } | ||
818 | |||
763 | extern struct sched_plugin linux_sched_plugin; | 819 | extern struct sched_plugin linux_sched_plugin; |
764 | 820 | ||
765 | static int __init _init_litmus(void) | 821 | static int __init _init_litmus(void) |