aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Kenna <cjk@cs.unc.edu>2010-10-22 17:26:38 -0400
committerBjoern B. Brandenburg <bbb@cs.unc.edu>2010-10-23 01:35:14 -0400
commit98f56816fcb5c97e0afd21a6e242bb72d5b7a551 (patch)
treed57ce043d568356d1050c74db6b512fed4783a79
parent3dd41424090a0ca3a660218d06afe6ff4441bad3 (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.
-rw-r--r--include/litmus/litmus.h16
-rw-r--r--litmus/litmus.c62
2 files changed, 75 insertions, 3 deletions
diff --git a/include/litmus/litmus.h b/include/litmus/litmus.h
index 5d20276e44f4..ccb6b137952b 100644
--- a/include/litmus/litmus.h
+++ b/include/litmus/litmus.h
@@ -9,6 +9,9 @@
9#include <linux/jiffies.h> 9#include <linux/jiffies.h>
10#include <litmus/sched_trace.h> 10#include <litmus/sched_trace.h>
11 11
12#include <litmus/sched_plugin.h>
13#include <linux/proc_fs.h>
14
12#ifdef CONFIG_RELEASE_MASTER 15#ifdef CONFIG_RELEASE_MASTER
13extern atomic_t release_master_cpu; 16extern atomic_t release_master_cpu;
14#endif 17#endif
@@ -62,6 +65,19 @@ void exit_litmus(struct task_struct *dead_tsk);
62long litmus_admit_task(struct task_struct *tsk); 65long litmus_admit_task(struct task_struct *tsk);
63void litmus_exit_task(struct task_struct *tsk); 66void litmus_exit_task(struct task_struct *tsk);
64 67
68/*
69 * On success, returns 0 and sets the pointer to the location of the new
70 * proc dir entry, otherwise returns an error code and sets pde to NULL.
71 */
72long make_plugin_proc_dir(struct sched_plugin* plugin,
73 struct proc_dir_entry** pde);
74
75/*
76 * Plugins should deallocate all child proc directory entries before
77 * calling this, to avoid memory leaks.
78 */
79void remove_plugin_proc_dir(struct sched_plugin* plugin);
80
65#define is_realtime(t) ((t)->policy == SCHED_LITMUS) 81#define is_realtime(t) ((t)->policy == SCHED_LITMUS)
66#define rt_transition_pending(t) \ 82#define rt_transition_pending(t) \
67 ((t)->rt_param.transition_pending) 83 ((t)->rt_param.transition_pending)
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,
687static struct proc_dir_entry *litmus_dir = NULL, 685static 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)
745static void exit_litmus_proc(void) 751static 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
771long 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
803out_no_pde:
804 *pde_in = NULL;
805out_ok:
806 return rv;
807}
808
809void 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
763extern struct sched_plugin linux_sched_plugin; 819extern struct sched_plugin linux_sched_plugin;
764 820
765static int __init _init_litmus(void) 821static int __init _init_litmus(void)