aboutsummaryrefslogtreecommitdiffstats
path: root/litmus/litmus_proc.c
diff options
context:
space:
mode:
authorBjoern B. Brandenburg <bbb@cs.unc.edu>2011-01-26 20:42:49 -0500
committerBjoern B. Brandenburg <bbb@cs.unc.edu>2011-02-01 17:00:26 -0500
commit4ce37704ec0bedb28b5708d32964fca471e793d0 (patch)
tree4e622b0d2d6793e944455ba108ae6dd5bf05ee80 /litmus/litmus_proc.c
parent963fd846e36b48d5338ef2a134d3ee8d208abc07 (diff)
Litmus core: extract userspace interface from C-EDF
Make the cluster size configuration in C-EDF generic so that it can be used by other clustered schedulers.
Diffstat (limited to 'litmus/litmus_proc.c')
-rw-r--r--litmus/litmus_proc.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/litmus/litmus_proc.c b/litmus/litmus_proc.c
index e3f3f11f80e1..4bf725a36c9c 100644
--- a/litmus/litmus_proc.c
+++ b/litmus/litmus_proc.c
@@ -8,6 +8,8 @@
8#include <litmus/litmus.h> 8#include <litmus/litmus.h>
9#include <litmus/litmus_proc.h> 9#include <litmus/litmus_proc.h>
10 10
11#include <litmus/clustered.h>
12
11/* in litmus/litmus.c */ 13/* in litmus/litmus.c */
12extern atomic_t rt_task_count; 14extern atomic_t rt_task_count;
13 15
@@ -267,3 +269,79 @@ int copy_and_chomp(char *kbuf, unsigned long ksize,
267 269
268 return ksize; 270 return ksize;
269} 271}
272
273/* helper functions for clustered plugins */
274static const char* cache_level_names[] = {
275 "ALL",
276 "L1",
277 "L2",
278 "L3",
279};
280
281int parse_cache_level(const char *cache_name, enum cache_level *level)
282{
283 int err = -EINVAL;
284 int i;
285 /* do a quick and dirty comparison to find the cluster size */
286 for (i = GLOBAL_CLUSTER; i <= L3_CLUSTER; i++)
287 if (!strcmp(cache_name, cache_level_names[i])) {
288 *level = (enum cache_level) i;
289 err = 0;
290 break;
291 }
292 return err;
293}
294
295const char* cache_level_name(enum cache_level level)
296{
297 int idx = level;
298
299 if (idx >= GLOBAL_CLUSTER && idx <= L3_CLUSTER)
300 return cache_level_names[idx];
301 else
302 return "INVALID";
303}
304
305
306/* proc file interface to configure the cluster size */
307static int proc_read_cluster_size(char *page, char **start,
308 off_t off, int count,
309 int *eof, void *data)
310{
311 return snprintf(page, PAGE_SIZE, "%s\n",
312 cache_level_name(*((enum cache_level*) data)));;
313}
314
315static int proc_write_cluster_size(struct file *file,
316 const char *buffer,
317 unsigned long count,
318 void *data)
319{
320 int len;
321 char cache_name[8];
322
323 len = copy_and_chomp(cache_name, sizeof(cache_name), buffer, count);
324
325 if (len > 0 && parse_cache_level(cache_name, (enum cache_level*) data))
326 printk(KERN_INFO "Cluster '%s' is unknown.\n", cache_name);
327
328 return len;
329}
330
331struct proc_dir_entry* create_cluster_file(struct proc_dir_entry* parent,
332 enum cache_level* level)
333{
334 struct proc_dir_entry* cluster_file;
335
336 cluster_file = create_proc_entry("cluster", 0644, parent);
337 if (!cluster_file) {
338 printk(KERN_ERR "Could not allocate %s/cluster "
339 "procfs entry.\n", parent->name);
340 } else {
341 cluster_file->read_proc = proc_read_cluster_size;
342 cluster_file->write_proc = proc_write_cluster_size;
343 cluster_file->data = level;
344 }
345 return cluster_file;
346}
347