diff options
author | Namhoon Kim <namhoonk@cs.unc.edu> | 2017-09-12 15:57:53 -0400 |
---|---|---|
committer | Namhoon Kim <namhoonk@cs.unc.edu> | 2017-09-12 15:57:53 -0400 |
commit | 5cc515b26848d31deda903fc19e5534723cf4a35 (patch) | |
tree | f961ff143600cebee30a2f8a38795b3b31bfc4a4 /litmus | |
parent | 84e36eb17cd9e5bb4bfb6cc4e29f55542fa69fde (diff) |
ORDER 2 per-partition alloc
Diffstat (limited to 'litmus')
-rw-r--r-- | litmus/page_dev.c | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/litmus/page_dev.c b/litmus/page_dev.c index 2894e93213d3..2fd829b05a0a 100644 --- a/litmus/page_dev.c +++ b/litmus/page_dev.c | |||
@@ -98,6 +98,81 @@ unsigned int llc_partition_min = 0; | |||
98 | unsigned int dram_partition_max = 0x000000ff; | 98 | unsigned int dram_partition_max = 0x000000ff; |
99 | unsigned int dram_partition_min = 0; | 99 | unsigned int dram_partition_min = 0; |
100 | 100 | ||
101 | /* slabtest module */ | ||
102 | int buf_size = 0; | ||
103 | int buf_num = 1; | ||
104 | |||
105 | int slabtest_handler(struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) | ||
106 | { | ||
107 | int ret = 0, i; | ||
108 | int** testbuffer; | ||
109 | mutex_lock(&dev_mutex); | ||
110 | ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); | ||
111 | |||
112 | if (ret) | ||
113 | goto out; | ||
114 | |||
115 | if (write) { | ||
116 | int idx; | ||
117 | int n_data = buf_size/sizeof(int); | ||
118 | |||
119 | testbuffer = kmalloc(sizeof(int*)*buf_num, GFP_KERNEL|GFP_COLOR); | ||
120 | |||
121 | for (idx=0; idx<buf_num; idx++) | ||
122 | { | ||
123 | printk(KERN_INFO "kmalloc size %d, n_data %d\n", buf_size, n_data); | ||
124 | testbuffer[idx] = kmalloc(buf_size, GFP_KERNEL|GFP_COLOR); | ||
125 | |||
126 | if (!testbuffer[idx]) { | ||
127 | printk(KERN_ERR "kmalloc failed size = %d\n", buf_size); | ||
128 | goto out; | ||
129 | } | ||
130 | } | ||
131 | |||
132 | |||
133 | /* do test */ | ||
134 | for (idx=0; idx<buf_num; idx++) | ||
135 | { | ||
136 | int t = 0; | ||
137 | printk(KERN_INFO "kmalloc size = %d n_data = %d\n", buf_size, n_data); | ||
138 | printk(KERN_INFO "write data to buffer\n"); | ||
139 | for (i = 0; i < n_data; i++) { | ||
140 | testbuffer[idx][i] = i%27; | ||
141 | } | ||
142 | printk(KERN_INFO "read data from buffer\n"); | ||
143 | for (i = 0; i < n_data; i++) { | ||
144 | t += testbuffer[idx][i]; | ||
145 | //printk(KERN_INFO "[%d] = %d\n", i, testbuffer[idx][i]); | ||
146 | } | ||
147 | } | ||
148 | |||
149 | for (idx=0; idx<buf_num; idx++) | ||
150 | kfree(testbuffer[idx]); | ||
151 | |||
152 | kfree(testbuffer); | ||
153 | } | ||
154 | out: | ||
155 | mutex_unlock(&dev_mutex); | ||
156 | return ret; | ||
157 | } | ||
158 | |||
159 | int num_buffer_handler(struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) | ||
160 | { | ||
161 | int ret = 0; | ||
162 | mutex_lock(&dev_mutex); | ||
163 | ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); | ||
164 | |||
165 | if (ret) | ||
166 | goto out; | ||
167 | |||
168 | if (write) { | ||
169 | printk(KERN_INFO "buf_num = %d\n", buf_num); | ||
170 | } | ||
171 | out: | ||
172 | mutex_unlock(&dev_mutex); | ||
173 | return ret; | ||
174 | } | ||
175 | |||
101 | static struct ctl_table partition_table[] = | 176 | static struct ctl_table partition_table[] = |
102 | { | 177 | { |
103 | 178 | ||
@@ -227,6 +302,20 @@ static struct ctl_table partition_table[] = | |||
227 | .extra1 = &dram_partition_min, | 302 | .extra1 = &dram_partition_min, |
228 | .extra2 = &dram_partition_max, | 303 | .extra2 = &dram_partition_max, |
229 | }, | 304 | }, |
305 | { | ||
306 | .procname = "slabtest", | ||
307 | .mode = 0666, | ||
308 | .proc_handler = slabtest_handler, | ||
309 | .data = &buf_size, | ||
310 | .maxlen = sizeof(buf_size), | ||
311 | }, | ||
312 | { | ||
313 | .procname = "num_buffer", | ||
314 | .mode = 0666, | ||
315 | .proc_handler = num_buffer_handler, | ||
316 | .data = &buf_num, | ||
317 | .maxlen = sizeof(buf_num), | ||
318 | }, | ||
230 | { } | 319 | { } |
231 | }; | 320 | }; |
232 | 321 | ||