aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/litmus/sched_plugin.h3
-rw-r--r--litmus/litmus_proc.c70
-rw-r--r--litmus/sched_cedf.c107
-rw-r--r--litmus/sched_plugin.c8
4 files changed, 100 insertions, 88 deletions
diff --git a/include/litmus/sched_plugin.h b/include/litmus/sched_plugin.h
index 9c1c9f28ba79..2d856d587041 100644
--- a/include/litmus/sched_plugin.h
+++ b/include/litmus/sched_plugin.h
@@ -133,9 +133,6 @@ struct sched_plugin {
133 133
134extern struct sched_plugin *litmus; 134extern struct sched_plugin *litmus;
135 135
136/* cluster size: cache_index = 2 L2, cache_index = 3 L3 */
137extern int cluster_cache_index;
138
139int register_sched_plugin(struct sched_plugin* plugin); 136int register_sched_plugin(struct sched_plugin* plugin);
140struct sched_plugin* find_sched_plugin(const char* name); 137struct sched_plugin* find_sched_plugin(const char* name);
141int print_sched_plugins(char* buf, int max); 138int print_sched_plugins(char* buf, int max);
diff --git a/litmus/litmus_proc.c b/litmus/litmus_proc.c
index ee0ad56d445c..c10a6a6d3975 100644
--- a/litmus/litmus_proc.c
+++ b/litmus/litmus_proc.c
@@ -4,6 +4,7 @@
4 4
5#include <linux/uaccess.h> 5#include <linux/uaccess.h>
6 6
7#include <litmus/litmus.h>
7#include <litmus/litmus_proc.h> 8#include <litmus/litmus_proc.h>
8 9
9/* in litmus/litmus.c */ 10/* in litmus/litmus.c */
@@ -13,11 +14,10 @@ static struct proc_dir_entry *litmus_dir = NULL,
13 *curr_file = NULL, 14 *curr_file = NULL,
14 *stat_file = NULL, 15 *stat_file = NULL,
15 *plugs_dir = NULL, 16 *plugs_dir = NULL,
16 *plugs_file = NULL,
17#ifdef CONFIG_RELEASE_MASTER 17#ifdef CONFIG_RELEASE_MASTER
18 *release_master_file = NULL, 18 *release_master_file = NULL,
19#endif 19#endif
20 *clus_cache_idx_file = NULL; 20 *plugs_file = NULL;
21 21
22/* in litmus/sync.c */ 22/* in litmus/sync.c */
23int count_tasks_waiting_for_release(void); 23int count_tasks_waiting_for_release(void);
@@ -93,60 +93,6 @@ static int proc_write_curr(struct file *file,
93 return len; 93 return len;
94} 94}
95 95
96static int proc_read_cluster_size(char *page, char **start,
97 off_t off, int count,
98 int *eof, void *data)
99{
100 int len;
101 if (cluster_cache_index == 2)
102 len = snprintf(page, PAGE_SIZE, "L2\n");
103 else if (cluster_cache_index == 3)
104 len = snprintf(page, PAGE_SIZE, "L3\n");
105 else if (cluster_cache_index == 1)
106 len = snprintf(page, PAGE_SIZE, "L1\n");
107 else
108 len = snprintf(page, PAGE_SIZE, "ALL\n");
109
110 return len;
111}
112
113static int proc_write_cluster_size(struct file *file,
114 const char *buffer,
115 unsigned long count,
116 void *data)
117{
118 int len;
119 /* L2, L3 */
120 char cache_name[33];
121
122 if(count > 32)
123 len = 32;
124 else
125 len = count;
126
127 if(copy_from_user(cache_name, buffer, len))
128 return -EFAULT;
129
130 cache_name[len] = '\0';
131 /* chomp name */
132 if (len > 1 && cache_name[len - 1] == '\n')
133 cache_name[len - 1] = '\0';
134
135 /* do a quick and dirty comparison to find the cluster size */
136 if (!strcmp(cache_name, "L2"))
137 cluster_cache_index = 2;
138 else if (!strcmp(cache_name, "L3"))
139 cluster_cache_index = 3;
140 else if (!strcmp(cache_name, "L1"))
141 cluster_cache_index = 1;
142 else if (!strcmp(cache_name, "ALL"))
143 cluster_cache_index = num_online_cpus();
144 else
145 printk(KERN_INFO "Cluster '%s' is unknown.\n", cache_name);
146
147 return len;
148}
149
150#ifdef CONFIG_RELEASE_MASTER 96#ifdef CONFIG_RELEASE_MASTER
151static int proc_read_release_master(char *page, char **start, 97static int proc_read_release_master(char *page, char **start,
152 off_t off, int count, 98 off_t off, int count,
@@ -229,16 +175,6 @@ int __init init_litmus_proc(void)
229 release_master_file->write_proc = proc_write_release_master; 175 release_master_file->write_proc = proc_write_release_master;
230#endif 176#endif
231 177
232 clus_cache_idx_file = create_proc_entry("cluster_cache",
233 0644, litmus_dir);
234 if (!clus_cache_idx_file) {
235 printk(KERN_ERR "Could not allocate cluster_cache "
236 "procfs entry.\n");
237 return -ENOMEM;
238 }
239 clus_cache_idx_file->read_proc = proc_read_cluster_size;
240 clus_cache_idx_file->write_proc = proc_write_cluster_size;
241
242 stat_file = create_proc_read_entry("stats", 0444, litmus_dir, 178 stat_file = create_proc_read_entry("stats", 0444, litmus_dir,
243 proc_read_stats, NULL); 179 proc_read_stats, NULL);
244 180
@@ -265,8 +201,6 @@ void exit_litmus_proc(void)
265 remove_proc_entry("stats", litmus_dir); 201 remove_proc_entry("stats", litmus_dir);
266 if (curr_file) 202 if (curr_file)
267 remove_proc_entry("active_plugin", litmus_dir); 203 remove_proc_entry("active_plugin", litmus_dir);
268 if (clus_cache_idx_file)
269 remove_proc_entry("cluster_cache", litmus_dir);
270#ifdef CONFIG_RELEASE_MASTER 204#ifdef CONFIG_RELEASE_MASTER
271 if (release_master_file) 205 if (release_master_file)
272 remove_proc_entry("release_master", litmus_dir); 206 remove_proc_entry("release_master", litmus_dir);
diff --git a/litmus/sched_cedf.c b/litmus/sched_cedf.c
index f5b77080cc4f..a729d97535e9 100644
--- a/litmus/sched_cedf.c
+++ b/litmus/sched_cedf.c
@@ -30,6 +30,8 @@
30#include <linux/sched.h> 30#include <linux/sched.h>
31#include <linux/slab.h> 31#include <linux/slab.h>
32 32
33#include <linux/module.h>
34
33#include <litmus/litmus.h> 35#include <litmus/litmus.h>
34#include <litmus/jobs.h> 36#include <litmus/jobs.h>
35#include <litmus/sched_plugin.h> 37#include <litmus/sched_plugin.h>
@@ -38,7 +40,16 @@
38 40
39#include <litmus/bheap.h> 41#include <litmus/bheap.h>
40 42
41#include <linux/module.h> 43/* to configure the cluster size */
44#include <litmus/litmus_proc.h>
45#include <linux/uaccess.h>
46
47/*
48 * It makes sense only to cluster around L2 or L3, so if cluster_index = 2
49 * (default) we cluster all the CPUs that shares a L2 cache, while
50 * cluster_cache_index = 3 we cluster all CPs that shares a L3 cache
51 */
52int cluster_index = 2;
42 53
43/* forward declaration... a funny thing with C ;) */ 54/* forward declaration... a funny thing with C ;) */
44struct clusterdomain; 55struct clusterdomain;
@@ -641,25 +652,25 @@ static long cedf_activate_plugin(void)
641 cleanup_cedf(); 652 cleanup_cedf();
642 653
643 printk(KERN_INFO "C-EDF: Activate Plugin, cache index = %d\n", 654 printk(KERN_INFO "C-EDF: Activate Plugin, cache index = %d\n",
644 cluster_cache_index); 655 cluster_index);
645 656
646 /* need to get cluster_size first */ 657 /* need to get cluster_size first */
647 if(!zalloc_cpumask_var(&mask, GFP_ATOMIC)) 658 if(!zalloc_cpumask_var(&mask, GFP_ATOMIC))
648 return -ENOMEM; 659 return -ENOMEM;
649 660
650 if (unlikely(cluster_cache_index == num_online_cpus())) { 661 if (unlikely(cluster_index == num_online_cpus())) {
651 662
652 cluster_size = num_online_cpus(); 663 cluster_size = num_online_cpus();
653 } else { 664 } else {
654 665
655 chk = get_shared_cpu_map(mask, 0, cluster_cache_index); 666 chk = get_shared_cpu_map(mask, 0, cluster_index);
656 if (chk) { 667 if (chk) {
657 /* if chk != 0 then it is the max allowed index */ 668 /* if chk != 0 then it is the max allowed index */
658 printk(KERN_INFO "C-EDF: Cannot support cache index = %d\n", 669 printk(KERN_INFO "C-EDF: Cannot support cache index = %d\n",
659 cluster_cache_index); 670 cluster_index);
660 printk(KERN_INFO "C-EDF: Using cache index = %d\n", 671 printk(KERN_INFO "C-EDF: Using cache index = %d\n",
661 chk); 672 chk);
662 cluster_cache_index = chk; 673 cluster_index = chk;
663 } 674 }
664 675
665 cluster_size = cpumask_weight(mask); 676 cluster_size = cpumask_weight(mask);
@@ -706,10 +717,10 @@ static long cedf_activate_plugin(void)
706 717
707 /* this cpu isn't in any cluster */ 718 /* this cpu isn't in any cluster */
708 /* get the shared cpus */ 719 /* get the shared cpus */
709 if (unlikely(cluster_cache_index == num_online_cpus())) 720 if (unlikely(cluster_index == num_online_cpus()))
710 cpumask_copy(mask, cpu_online_mask); 721 cpumask_copy(mask, cpu_online_mask);
711 else 722 else
712 get_shared_cpu_map(mask, cpu, cluster_cache_index); 723 get_shared_cpu_map(mask, cpu, cluster_index);
713 724
714 cpumask_copy(cedf[i].cpu_map, mask); 725 cpumask_copy(cedf[i].cpu_map, mask);
715#ifdef VERBOSE_INIT 726#ifdef VERBOSE_INIT
@@ -759,14 +770,92 @@ static struct sched_plugin cedf_plugin __cacheline_aligned_in_smp = {
759}; 770};
760 771
761 772
773/* proc file interface to configure the cluster size */
774
775static int proc_read_cluster_size(char *page, char **start,
776 off_t off, int count,
777 int *eof, void *data)
778{
779 int len;
780 if (cluster_index >= 1 && cluster_index <= 3)
781 len = snprintf(page, PAGE_SIZE, "L%d\n", cluster_index);
782 else
783 len = snprintf(page, PAGE_SIZE, "ALL\n");
784
785 return len;
786}
787
788static int proc_write_cluster_size(struct file *file,
789 const char *buffer,
790 unsigned long count,
791 void *data)
792{
793 int len;
794 /* L2, L3 */
795 char cache_name[33];
796
797 if(count > 32)
798 len = 32;
799 else
800 len = count;
801
802 if(copy_from_user(cache_name, buffer, len))
803 return -EFAULT;
804
805 cache_name[len] = '\0';
806 /* chomp name */
807 if (len > 1 && cache_name[len - 1] == '\n')
808 cache_name[len - 1] = '\0';
809
810 /* do a quick and dirty comparison to find the cluster size */
811 if (!strcmp(cache_name, "L2"))
812 cluster_index = 2;
813 else if (!strcmp(cache_name, "L3"))
814 cluster_index = 3;
815 else if (!strcmp(cache_name, "L1"))
816 cluster_index = 1;
817 else if (!strcmp(cache_name, "ALL"))
818 cluster_index = num_online_cpus();
819 else
820 printk(KERN_INFO "Cluster '%s' is unknown.\n", cache_name);
821
822 return len;
823}
824
825
826static struct proc_dir_entry *cluster_file = NULL, *cedf_dir = NULL;
827
828
762static int __init init_cedf(void) 829static int __init init_cedf(void)
763{ 830{
764 return register_sched_plugin(&cedf_plugin); 831 int err, fs;
832
833 err = register_sched_plugin(&cedf_plugin);
834 if (!err) {
835 fs = make_plugin_proc_dir(&cedf_plugin, &cedf_dir);
836 if (!fs) {
837 cluster_file = create_proc_entry("cluster", 0644, cedf_dir);
838 if (!cluster_file) {
839 printk(KERN_ERR "Could not allocate C-EDF/cluster "
840 "procfs entry.\n");
841 } else {
842 cluster_file->read_proc = proc_read_cluster_size;
843 cluster_file->write_proc = proc_write_cluster_size;
844 }
845 } else {
846 printk(KERN_ERR "Could not allocate C-EDF procfs dir.\n");
847 }
848 }
849 return err;
765} 850}
766 851
767static void clean_cedf(void) 852static void clean_cedf(void)
768{ 853{
769 cleanup_cedf(); 854 cleanup_cedf();
855 if (cluster_file)
856 remove_proc_entry("cluster", cedf_dir);
857 if (cedf_dir)
858 remove_plugin_proc_dir(&cedf_plugin);
770} 859}
771 860
772module_init(init_cedf); 861module_init(init_cedf);
diff --git a/litmus/sched_plugin.c b/litmus/sched_plugin.c
index 3543b7baff53..d706a08fb313 100644
--- a/litmus/sched_plugin.c
+++ b/litmus/sched_plugin.c
@@ -171,14 +171,6 @@ struct sched_plugin linux_sched_plugin = {
171}; 171};
172 172
173/* 173/*
174 * The cluster size is needed in C-EDF: it makes sense only to cluster
175 * around L2 or L3, so if cluster_cache_index = 2 (default) we cluster
176 * all the CPUs that shares a L2 cache, while cluster_cache_index = 3
177 * we cluster all CPs that shares a L3 cache
178 */
179int cluster_cache_index = 2;
180
181/*
182 * The reference to current plugin that is used to schedule tasks within 174 * The reference to current plugin that is used to schedule tasks within
183 * the system. It stores references to actual function implementations 175 * the system. It stores references to actual function implementations
184 * Should be initialized by calling "init_***_plugin()" 176 * Should be initialized by calling "init_***_plugin()"