aboutsummaryrefslogtreecommitdiffstats
path: root/litmus/color_proc.c
diff options
context:
space:
mode:
authorChristopher Kenna <cjk@cs.unc.edu>2012-03-29 16:58:20 -0400
committerChristopher Kenna <cjk@cs.unc.edu>2012-03-29 17:21:02 -0400
commit606f24606ecf76a62c2e262e260a51bf6f8dc009 (patch)
tree24bcaaeba38dbfffabf98e5000e8dcdffeca6d14 /litmus/color_proc.c
parentb227313bc9f87f67001e92b898d5da7918102b20 (diff)
Allocate only one page at a time. Add proc interface.
Diffstat (limited to 'litmus/color_proc.c')
-rw-r--r--litmus/color_proc.c79
1 files changed, 79 insertions, 0 deletions
diff --git a/litmus/color_proc.c b/litmus/color_proc.c
new file mode 100644
index 000000000000..1eba0740db9d
--- /dev/null
+++ b/litmus/color_proc.c
@@ -0,0 +1,79 @@
1#include <linux/module.h>
2#include <linux/sysctl.h>
3#include <linux/slab.h>
4
5#include <litmus/color.h>
6
7extern int color_sysctl_add_pages_data; /* litmus/color.c */
8
9static int zero = 0;
10static int one = 1;
11
12#define NR_PAGES_INDEX 1 /* location of nr_pages in the table below */
13static struct ctl_table color_table[] =
14{
15 {
16 .procname = "add_pages",
17 .data = &color_sysctl_add_pages_data,
18 .maxlen = sizeof(int),
19 .mode = 0644,
20 .proc_handler = color_add_pages_handler,
21 .extra1 = &zero,
22 .extra2 = &one,
23 },
24 {
25 .procname = "nr_pages",
26 .mode = 0444,
27 .proc_handler = color_nr_pages_handler,
28 .data = NULL, /* dynamically later */
29 .maxlen = 0, /* also set later */
30 },
31 { }
32};
33
34static struct ctl_table litmus_table[] =
35{
36 {
37 .procname = "color",
38 .mode = 0555,
39 .child = color_table,
40 },
41 { }
42};
43static struct ctl_table litmus_dir_table[] = {
44 {
45 .procname = "litmus",
46 .mode = 0555,
47 .child = litmus_table,
48 },
49 { }
50};
51
52extern unsigned long nr_colors; /* litmus/color.c */
53
54/* must be called AFTER nr_colors is set */
55static int __init init_sysctl_nr_colors(void)
56{
57 int maxlen = ONE_COLOR_LEN * nr_colors;
58 color_table[NR_PAGES_INDEX].data = kmalloc(maxlen, GFP_KERNEL);
59 if (!color_table[NR_PAGES_INDEX].data) {
60 printk(KERN_WARNING "Could not allocate nr_pages buffer.\n");
61 return -ENOMEM;
62 }
63 color_table[NR_PAGES_INDEX].maxlen = maxlen;
64 return 0;
65}
66
67static struct ctl_table_header *litmus_sysctls;
68
69static int __init litmus_sysctl_init(void)
70{
71 litmus_sysctls = register_sysctl_table(litmus_dir_table);
72 if (!litmus_sysctls) {
73 printk(KERN_WARNING "Could not register LITMUS^RT sysctl.\n");
74 return -EFAULT;
75 }
76 return init_sysctl_nr_colors();
77}
78
79module_init(litmus_sysctl_init);