]>
Commit | Line | Data |
---|---|---|
715f6251 | 1 | /* |
2 | * This file is part of the SPL: Solaris Porting Layer. | |
3 | * | |
4 | * Copyright (c) 2008 Lawrence Livermore National Security, LLC. | |
5 | * Produced at Lawrence Livermore National Laboratory | |
6 | * Written by: | |
7 | * Brian Behlendorf <behlendorf1@llnl.gov>, | |
8 | * Herb Wartens <wartens2@llnl.gov>, | |
9 | * Jim Garlick <garlick@llnl.gov> | |
10 | * UCRL-CODE-235197 | |
11 | * | |
12 | * This is free software; you can redistribute it and/or modify it | |
13 | * under the terms of the GNU General Public License as published by | |
14 | * the Free Software Foundation; either version 2 of the License, or | |
15 | * (at your option) any later version. | |
16 | * | |
17 | * This is distributed in the hope that it will be useful, but WITHOUT | |
18 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
19 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
20 | * for more details. | |
21 | * | |
22 | * You should have received a copy of the GNU General Public License along | |
23 | * with this program; if not, write to the Free Software Foundation, Inc., | |
24 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
25 | */ | |
26 | ||
04a479f7 | 27 | #include <sys/proc.h> |
57d1b188 | 28 | |
29 | #ifdef DEBUG_SUBSYSTEM | |
30 | #undef DEBUG_SUBSYSTEM | |
31 | #endif | |
32 | ||
33 | #define DEBUG_SUBSYSTEM S_PROC | |
34 | ||
404992e3 | 35 | #ifdef DEBUG_KMEM |
57d1b188 | 36 | static unsigned long table_min = 0; |
37 | static unsigned long table_max = ~0; | |
404992e3 | 38 | #endif |
39 | ||
40 | #ifdef CONFIG_SYSCTL | |
41 | static struct ctl_table_header *spl_header = NULL; | |
c30df9c8 | 42 | #endif /* CONFIG_SYSCTL */ |
43 | ||
4d54fdee | 44 | #if defined(DEBUG_KMEM) || defined(DEBUG_KSTAT) |
c30df9c8 | 45 | static struct proc_dir_entry *proc_spl = NULL; |
04a479f7 | 46 | #ifdef DEBUG_KMEM |
c30df9c8 | 47 | static struct proc_dir_entry *proc_spl_kmem = NULL; |
ff449ac4 | 48 | static struct proc_dir_entry *proc_spl_kmem_slab = NULL; |
c30df9c8 | 49 | #endif /* DEBUG_KMEM */ |
04a479f7 | 50 | #ifdef DEBUG_KSTAT |
c30df9c8 | 51 | struct proc_dir_entry *proc_spl_kstat = NULL; |
52 | #endif /* DEBUG_KSTAT */ | |
4d54fdee | 53 | #endif /* DEBUG_KMEM || DEBUG_KSTAT */ |
57d1b188 | 54 | |
57d86234 | 55 | #ifdef HAVE_CTL_UNNUMBERED |
56 | ||
57 | #define CTL_SPL CTL_UNNUMBERED | |
58 | #define CTL_SPL_DEBUG CTL_UNNUMBERED | |
36b313da | 59 | #define CTL_SPL_VM CTL_UNNUMBERED |
57d86234 | 60 | #define CTL_SPL_MUTEX CTL_UNNUMBERED |
61 | #define CTL_SPL_KMEM CTL_UNNUMBERED | |
62 | #define CTL_SPL_KSTAT CTL_UNNUMBERED | |
63 | ||
64 | #define CTL_VERSION CTL_UNNUMBERED /* Version */ | |
65 | #define CTL_HOSTID CTL_UNNUMBERED /* Host id by /usr/bin/hostid */ | |
66 | #define CTL_HW_SERIAL CTL_UNNUMBERED /* HW serial number by hostid */ | |
d1ff2312 | 67 | #define CTL_KALLSYMS CTL_UNNUMBERED /* kallsyms_lookup_name addr */ |
57d86234 | 68 | |
69 | #define CTL_DEBUG_SUBSYS CTL_UNNUMBERED /* Debug subsystem */ | |
70 | #define CTL_DEBUG_MASK CTL_UNNUMBERED /* Debug mask */ | |
71 | #define CTL_DEBUG_PRINTK CTL_UNNUMBERED /* All messages to console */ | |
72 | #define CTL_DEBUG_MB CTL_UNNUMBERED /* Debug buffer size */ | |
73 | #define CTL_DEBUG_BINARY CTL_UNNUMBERED /* Binary data in buffer */ | |
74 | #define CTL_DEBUG_CATASTROPHE CTL_UNNUMBERED /* Set if BUG'd or panic'd */ | |
75 | #define CTL_DEBUG_PANIC_ON_BUG CTL_UNNUMBERED /* Should panic on BUG */ | |
76 | #define CTL_DEBUG_PATH CTL_UNNUMBERED /* Dump log location */ | |
77 | #define CTL_DEBUG_DUMP CTL_UNNUMBERED /* Dump debug buffer to file */ | |
78 | #define CTL_DEBUG_FORCE_BUG CTL_UNNUMBERED /* Hook to force a BUG */ | |
79 | #define CTL_DEBUG_STACK_SIZE CTL_UNNUMBERED /* Max observed stack size */ | |
80 | ||
81 | #define CTL_CONSOLE_RATELIMIT CTL_UNNUMBERED /* Ratelimit console messages */ | |
82 | #define CTL_CONSOLE_MAX_DELAY_CS CTL_UNNUMBERED /* Max delay skip messages */ | |
83 | #define CTL_CONSOLE_MIN_DELAY_CS CTL_UNNUMBERED /* Init delay skip messages */ | |
84 | #define CTL_CONSOLE_BACKOFF CTL_UNNUMBERED /* Delay increase factor */ | |
85 | ||
36b313da BB |
86 | #define CTL_VM_MINFREE CTL_UNNUMBERED /* Minimum free memory */ |
87 | #define CTL_VM_DESFREE CTL_UNNUMBERED /* Desired free memory */ | |
88 | #define CTL_VM_LOTSFREE CTL_UNNUMBERED /* Lots of free memory */ | |
89 | #define CTL_VM_NEEDFREE CTL_UNNUMBERED /* Need free memory */ | |
90 | #define CTL_VM_SWAPFS_MINFREE CTL_UNNUMBERED /* Minimum swapfs memory */ | |
36b313da | 91 | #define CTL_VM_SWAPFS_RESERVE CTL_UNNUMBERED /* Reserved swapfs memory */ |
4ab13d3b BB |
92 | #define CTL_VM_AVAILRMEM CTL_UNNUMBERED /* Easily available memory */ |
93 | #define CTL_VM_FREEMEM CTL_UNNUMBERED /* Free memory */ | |
94 | #define CTL_VM_PHYSMEM CTL_UNNUMBERED /* Total physical memory */ | |
36b313da | 95 | |
57d86234 | 96 | #ifdef DEBUG_KMEM |
97 | #define CTL_KMEM_KMEMUSED CTL_UNNUMBERED /* Alloc'd kmem bytes */ | |
98 | #define CTL_KMEM_KMEMMAX CTL_UNNUMBERED /* Max alloc'd by kmem bytes */ | |
99 | #define CTL_KMEM_VMEMUSED CTL_UNNUMBERED /* Alloc'd vmem bytes */ | |
100 | #define CTL_KMEM_VMEMMAX CTL_UNNUMBERED /* Max alloc'd by vmem bytes */ | |
101 | #define CTL_KMEM_ALLOC_FAILED CTL_UNNUMBERED /* Cache allocations failed */ | |
102 | #endif | |
103 | ||
57d86234 | 104 | #else /* HAVE_CTL_UNNUMBERED */ |
105 | ||
36b313da BB |
106 | enum { |
107 | CTL_SPL = 0x87, | |
108 | CTL_SPL_DEBUG = 0x88, | |
109 | CTL_SPL_VM = 0x89, | |
110 | CTL_SPL_MUTEX = 0x90, | |
111 | CTL_SPL_KMEM = 0x91, | |
112 | CTL_SPL_KSTAT = 0x92, | |
113 | }; | |
9ab1ac14 | 114 | |
57d1b188 | 115 | enum { |
36b313da BB |
116 | CTL_VERSION = 1, /* Version */ |
117 | CTL_HOSTID, /* Host id reported by /usr/bin/hostid */ | |
118 | CTL_HW_SERIAL, /* Hardware serial number from hostid */ | |
d1ff2312 | 119 | CTL_KALLSYMS, /* Address of kallsyms_lookup_name */ |
36b313da BB |
120 | |
121 | CTL_DEBUG_SUBSYS, /* Debug subsystem */ | |
122 | CTL_DEBUG_MASK, /* Debug mask */ | |
123 | CTL_DEBUG_PRINTK, /* Force all messages to console */ | |
124 | CTL_DEBUG_MB, /* Debug buffer size */ | |
125 | CTL_DEBUG_BINARY, /* Include binary data in buffer */ | |
126 | CTL_DEBUG_CATASTROPHE, /* Set if we have BUG'd or panic'd */ | |
127 | CTL_DEBUG_PANIC_ON_BUG, /* Set if we should panic on BUG */ | |
128 | CTL_DEBUG_PATH, /* Dump log location */ | |
129 | CTL_DEBUG_DUMP, /* Dump debug buffer to file */ | |
130 | CTL_DEBUG_FORCE_BUG, /* Hook to force a BUG */ | |
131 | CTL_DEBUG_STACK_SIZE, /* Max observed stack size */ | |
132 | ||
133 | CTL_CONSOLE_RATELIMIT, /* Ratelimit console messages */ | |
134 | CTL_CONSOLE_MAX_DELAY_CS, /* Max delay which we skip messages */ | |
135 | CTL_CONSOLE_MIN_DELAY_CS, /* Init delay which we skip messages */ | |
136 | CTL_CONSOLE_BACKOFF, /* Delay increase factor */ | |
137 | ||
138 | CTL_VM_MINFREE, /* Minimum free memory threshold */ | |
139 | CTL_VM_DESFREE, /* Desired free memory threshold */ | |
140 | CTL_VM_LOTSFREE, /* Lots of free memory threshold */ | |
141 | CTL_VM_NEEDFREE, /* Need free memory deficit */ | |
142 | CTL_VM_SWAPFS_MINFREE, /* Minimum swapfs memory */ | |
36b313da | 143 | CTL_VM_SWAPFS_RESERVE, /* Reserved swapfs memory */ |
4ab13d3b BB |
144 | CTL_VM_AVAILRMEM, /* Easily available memory */ |
145 | CTL_VM_FREEMEM, /* Free memory */ | |
146 | CTL_VM_PHYSMEM, /* Total physical memory */ | |
9ab1ac14 | 147 | |
57d1b188 | 148 | #ifdef DEBUG_KMEM |
36b313da BB |
149 | CTL_KMEM_KMEMUSED, /* Alloc'd kmem bytes */ |
150 | CTL_KMEM_KMEMMAX, /* Max alloc'd by kmem bytes */ | |
151 | CTL_KMEM_VMEMUSED, /* Alloc'd vmem bytes */ | |
152 | CTL_KMEM_VMEMMAX, /* Max alloc'd by vmem bytes */ | |
57d1b188 | 153 | #endif |
57d1b188 | 154 | }; |
57d86234 | 155 | #endif /* HAVE_CTL_UNNUMBERED */ |
57d1b188 | 156 | |
157 | static int | |
158 | proc_copyin_string(char *kbuffer, int kbuffer_size, | |
159 | const char *ubuffer, int ubuffer_size) | |
160 | { | |
161 | int size; | |
162 | ||
163 | if (ubuffer_size > kbuffer_size) | |
164 | return -EOVERFLOW; | |
165 | ||
166 | if (copy_from_user((void *)kbuffer, (void *)ubuffer, ubuffer_size)) | |
167 | return -EFAULT; | |
168 | ||
169 | /* strip trailing whitespace */ | |
170 | size = strnlen(kbuffer, ubuffer_size); | |
171 | while (size-- >= 0) | |
172 | if (!isspace(kbuffer[size])) | |
173 | break; | |
174 | ||
175 | /* empty string */ | |
176 | if (size < 0) | |
177 | return -EINVAL; | |
178 | ||
179 | /* no space to terminate */ | |
180 | if (size == kbuffer_size) | |
181 | return -EOVERFLOW; | |
182 | ||
183 | kbuffer[size + 1] = 0; | |
184 | return 0; | |
185 | } | |
186 | ||
187 | static int | |
188 | proc_copyout_string(char *ubuffer, int ubuffer_size, | |
189 | const char *kbuffer, char *append) | |
190 | { | |
191 | /* NB if 'append' != NULL, it's a single character to append to the | |
192 | * copied out string - usually "\n", for /proc entries and | |
193 | * (i.e. a terminating zero byte) for sysctl entries | |
194 | */ | |
195 | int size = MIN(strlen(kbuffer), ubuffer_size); | |
196 | ||
197 | if (copy_to_user(ubuffer, kbuffer, size)) | |
198 | return -EFAULT; | |
199 | ||
200 | if (append != NULL && size < ubuffer_size) { | |
201 | if (copy_to_user(ubuffer + size, append, 1)) | |
202 | return -EFAULT; | |
203 | ||
204 | size++; | |
205 | } | |
206 | ||
207 | return size; | |
208 | } | |
209 | ||
210 | static int | |
211 | proc_dobitmasks(struct ctl_table *table, int write, struct file *filp, | |
212 | void __user *buffer, size_t *lenp, loff_t *ppos) | |
213 | { | |
214 | unsigned long *mask = table->data; | |
215 | int is_subsys = (mask == &spl_debug_subsys) ? 1 : 0; | |
216 | int is_printk = (mask == &spl_debug_printk) ? 1 : 0; | |
217 | int size = 512, rc; | |
218 | char *str; | |
219 | ENTRY; | |
220 | ||
221 | str = kmem_alloc(size, KM_SLEEP); | |
222 | if (str == NULL) | |
223 | RETURN(-ENOMEM); | |
224 | ||
225 | if (write) { | |
226 | rc = proc_copyin_string(str, size, buffer, *lenp); | |
227 | if (rc < 0) | |
228 | RETURN(rc); | |
229 | ||
230 | rc = spl_debug_str2mask(mask, str, is_subsys); | |
231 | /* Always print BUG/ASSERT to console, so keep this mask */ | |
232 | if (is_printk) | |
233 | *mask |= D_EMERG; | |
234 | ||
235 | *ppos += *lenp; | |
236 | } else { | |
237 | rc = spl_debug_mask2str(str, size, *mask, is_subsys); | |
238 | if (*ppos >= rc) | |
239 | rc = 0; | |
240 | else | |
241 | rc = proc_copyout_string(buffer, *lenp, | |
242 | str + *ppos, "\n"); | |
243 | if (rc >= 0) { | |
244 | *lenp = rc; | |
245 | *ppos += rc; | |
246 | } | |
247 | } | |
248 | ||
249 | kmem_free(str, size); | |
250 | RETURN(rc); | |
251 | } | |
252 | ||
253 | static int | |
254 | proc_debug_mb(struct ctl_table *table, int write, struct file *filp, | |
255 | void __user *buffer, size_t *lenp, loff_t *ppos) | |
256 | { | |
257 | char str[32]; | |
258 | int rc, len; | |
259 | ENTRY; | |
260 | ||
261 | if (write) { | |
262 | rc = proc_copyin_string(str, sizeof(str), buffer, *lenp); | |
263 | if (rc < 0) | |
264 | RETURN(rc); | |
265 | ||
266 | rc = spl_debug_set_mb(simple_strtoul(str, NULL, 0)); | |
267 | *ppos += *lenp; | |
268 | } else { | |
269 | len = snprintf(str, sizeof(str), "%d", spl_debug_get_mb()); | |
270 | if (*ppos >= len) | |
271 | rc = 0; | |
272 | else | |
273 | rc = proc_copyout_string(buffer, *lenp, str + *ppos, "\n"); | |
274 | ||
275 | if (rc >= 0) { | |
276 | *lenp = rc; | |
277 | *ppos += rc; | |
278 | } | |
279 | } | |
280 | ||
281 | RETURN(rc); | |
282 | } | |
283 | ||
284 | static int | |
285 | proc_dump_kernel(struct ctl_table *table, int write, struct file *filp, | |
286 | void __user *buffer, size_t *lenp, loff_t *ppos) | |
287 | { | |
288 | ENTRY; | |
289 | ||
290 | if (write) { | |
7fea96c0 | 291 | spl_debug_dumplog(0); |
57d1b188 | 292 | *ppos += *lenp; |
293 | } else { | |
294 | *lenp = 0; | |
295 | } | |
296 | ||
297 | RETURN(0); | |
298 | } | |
299 | ||
300 | static int | |
301 | proc_force_bug(struct ctl_table *table, int write, struct file *filp, | |
302 | void __user *buffer, size_t *lenp, loff_t *ppos) | |
303 | { | |
304 | ENTRY; | |
305 | ||
306 | if (write) { | |
2fae1b3d | 307 | CERROR("Crashing due to forced SBUG\n"); |
308 | SBUG(); | |
57d1b188 | 309 | /* Unreachable */ |
310 | } else { | |
311 | *lenp = 0; | |
312 | } | |
313 | ||
314 | RETURN(0); | |
315 | } | |
316 | ||
317 | static int | |
318 | proc_console_max_delay_cs(struct ctl_table *table, int write, struct file *filp, | |
319 | void __user *buffer, size_t *lenp, loff_t *ppos) | |
320 | { | |
321 | int rc, max_delay_cs; | |
322 | struct ctl_table dummy = *table; | |
323 | long d; | |
324 | ENTRY; | |
325 | ||
326 | dummy.data = &max_delay_cs; | |
327 | dummy.proc_handler = &proc_dointvec; | |
328 | ||
329 | if (write) { | |
330 | max_delay_cs = 0; | |
331 | rc = proc_dointvec(&dummy, write, filp, buffer, lenp, ppos); | |
332 | if (rc < 0) | |
333 | RETURN(rc); | |
334 | ||
335 | if (max_delay_cs <= 0) | |
336 | RETURN(-EINVAL); | |
337 | ||
338 | d = (max_delay_cs * HZ) / 100; | |
339 | if (d == 0 || d < spl_console_min_delay) | |
340 | RETURN(-EINVAL); | |
341 | ||
342 | spl_console_max_delay = d; | |
343 | } else { | |
344 | max_delay_cs = (spl_console_max_delay * 100) / HZ; | |
345 | rc = proc_dointvec(&dummy, write, filp, buffer, lenp, ppos); | |
346 | } | |
347 | ||
348 | RETURN(rc); | |
349 | } | |
350 | ||
351 | static int | |
352 | proc_console_min_delay_cs(struct ctl_table *table, int write, struct file *filp, | |
353 | void __user *buffer, size_t *lenp, loff_t *ppos) | |
354 | { | |
355 | int rc, min_delay_cs; | |
356 | struct ctl_table dummy = *table; | |
357 | long d; | |
358 | ENTRY; | |
359 | ||
360 | dummy.data = &min_delay_cs; | |
361 | dummy.proc_handler = &proc_dointvec; | |
362 | ||
363 | if (write) { | |
364 | min_delay_cs = 0; | |
365 | rc = proc_dointvec(&dummy, write, filp, buffer, lenp, ppos); | |
366 | if (rc < 0) | |
367 | RETURN(rc); | |
368 | ||
369 | if (min_delay_cs <= 0) | |
370 | RETURN(-EINVAL); | |
371 | ||
372 | d = (min_delay_cs * HZ) / 100; | |
373 | if (d == 0 || d > spl_console_max_delay) | |
374 | RETURN(-EINVAL); | |
375 | ||
376 | spl_console_min_delay = d; | |
377 | } else { | |
378 | min_delay_cs = (spl_console_min_delay * 100) / HZ; | |
379 | rc = proc_dointvec(&dummy, write, filp, buffer, lenp, ppos); | |
380 | } | |
381 | ||
382 | RETURN(rc); | |
383 | } | |
384 | ||
385 | static int | |
386 | proc_console_backoff(struct ctl_table *table, int write, struct file *filp, | |
387 | void __user *buffer, size_t *lenp, loff_t *ppos) | |
388 | { | |
389 | int rc, backoff; | |
390 | struct ctl_table dummy = *table; | |
391 | ENTRY; | |
392 | ||
393 | dummy.data = &backoff; | |
394 | dummy.proc_handler = &proc_dointvec; | |
395 | ||
396 | if (write) { | |
397 | backoff = 0; | |
398 | rc = proc_dointvec(&dummy, write, filp, buffer, lenp, ppos); | |
399 | if (rc < 0) | |
400 | RETURN(rc); | |
401 | ||
402 | if (backoff <= 0) | |
403 | RETURN(-EINVAL); | |
404 | ||
405 | spl_console_backoff = backoff; | |
406 | } else { | |
407 | backoff = spl_console_backoff; | |
408 | rc = proc_dointvec(&dummy, write, filp, buffer, lenp, ppos); | |
409 | } | |
410 | ||
411 | RETURN(rc); | |
412 | } | |
413 | ||
c6dc93d6 | 414 | #ifdef DEBUG_KMEM |
57d1b188 | 415 | static int |
416 | proc_doatomic64(struct ctl_table *table, int write, struct file *filp, | |
417 | void __user *buffer, size_t *lenp, loff_t *ppos) | |
418 | { | |
419 | int rc = 0; | |
420 | unsigned long min = 0, max = ~0, val; | |
421 | struct ctl_table dummy = *table; | |
422 | ENTRY; | |
423 | ||
424 | dummy.data = &val; | |
425 | dummy.proc_handler = &proc_dointvec; | |
426 | dummy.extra1 = &min; | |
427 | dummy.extra2 = &max; | |
428 | ||
429 | if (write) { | |
430 | *ppos += *lenp; | |
431 | } else { | |
550f1705 | 432 | val = atomic64_read((atomic64_t *)table->data); |
57d1b188 | 433 | rc = proc_doulongvec_minmax(&dummy, write, filp, |
434 | buffer, lenp, ppos); | |
435 | } | |
436 | ||
437 | RETURN(rc); | |
438 | } | |
c6dc93d6 | 439 | #endif /* DEBUG_KMEM */ |
57d1b188 | 440 | |
441 | static int | |
442 | proc_dohostid(struct ctl_table *table, int write, struct file *filp, | |
443 | void __user *buffer, size_t *lenp, loff_t *ppos) | |
444 | { | |
445 | int len, rc = 0; | |
937879f1 | 446 | int32_t val; |
57d1b188 | 447 | char *end, str[32]; |
a0b5ae8a | 448 | ENTRY; |
57d1b188 | 449 | |
450 | if (write) { | |
a0b5ae8a RC |
451 | /* We can't use proc_doulongvec_minmax() in the write |
452 | * case hear because hostid while a hex value has no | |
453 | * leading 0x which confuses the helper function. */ | |
57d1b188 | 454 | rc = proc_copyin_string(str, sizeof(str), buffer, *lenp); |
455 | if (rc < 0) | |
456 | RETURN(rc); | |
457 | ||
937879f1 | 458 | val = simple_strtol(str, &end, 16); |
a0b5ae8a RC |
459 | if (str == end) |
460 | RETURN(-EINVAL); | |
57d1b188 | 461 | |
a0b5ae8a RC |
462 | spl_hostid = (long) val; |
463 | (void) snprintf(hw_serial, HW_HOSTID_LEN, "%u", | |
464 | (val >= 0) ? val : -val); | |
465 | hw_serial[HW_HOSTID_LEN - 1] = '\0'; | |
57d1b188 | 466 | *ppos += *lenp; |
467 | } else { | |
468 | len = snprintf(str, sizeof(str), "%lx", spl_hostid); | |
469 | if (*ppos >= len) | |
470 | rc = 0; | |
471 | else | |
472 | rc = proc_copyout_string(buffer, *lenp, str + *ppos, "\n"); | |
473 | ||
474 | if (rc >= 0) { | |
475 | *lenp = rc; | |
476 | *ppos += rc; | |
477 | } | |
478 | } | |
479 | ||
480 | RETURN(rc); | |
481 | } | |
482 | ||
d1ff2312 BB |
483 | #ifndef HAVE_KALLSYMS_LOOKUP_NAME |
484 | static int | |
485 | proc_dokallsyms_lookup_name(struct ctl_table *table, int write, | |
486 | struct file *filp, void __user *buffer, | |
487 | size_t *lenp, loff_t *ppos) { | |
488 | int len, rc = 0; | |
489 | char *end, str[32]; | |
490 | ENTRY; | |
491 | ||
492 | if (write) { | |
493 | /* This may only be set once at module load time */ | |
96dded38 | 494 | if (spl_kallsyms_lookup_name_fn != SYMBOL_POISON) |
d1ff2312 BB |
495 | RETURN(-EEXIST); |
496 | ||
497 | /* We can't use proc_doulongvec_minmax() in the write | |
498 | * case hear because the address while a hex value has no | |
499 | * leading 0x which confuses the helper function. */ | |
500 | rc = proc_copyin_string(str, sizeof(str), buffer, *lenp); | |
501 | if (rc < 0) | |
502 | RETURN(rc); | |
503 | ||
504 | spl_kallsyms_lookup_name_fn = | |
505 | (kallsyms_lookup_name_t)simple_strtoul(str, &end, 16); | |
506 | if (str == end) | |
507 | RETURN(-EINVAL); | |
508 | ||
509 | *ppos += *lenp; | |
510 | } else { | |
511 | len = snprintf(str, sizeof(str), "%lx", | |
512 | (unsigned long)spl_kallsyms_lookup_name_fn); | |
513 | if (*ppos >= len) | |
514 | rc = 0; | |
515 | else | |
516 | rc = proc_copyout_string(buffer,*lenp,str+*ppos,"\n"); | |
517 | ||
518 | if (rc >= 0) { | |
519 | *lenp = rc; | |
520 | *ppos += rc; | |
521 | } | |
522 | } | |
523 | ||
524 | RETURN(rc); | |
525 | } | |
526 | #endif /* HAVE_KALLSYMS_LOOKUP_NAME */ | |
527 | ||
4ab13d3b BB |
528 | static int |
529 | proc_doavailrmem(struct ctl_table *table, int write, struct file *filp, | |
530 | void __user *buffer, size_t *lenp, loff_t *ppos) | |
531 | { | |
532 | int len, rc = 0; | |
533 | char str[32]; | |
534 | ENTRY; | |
535 | ||
536 | if (write) { | |
537 | *ppos += *lenp; | |
538 | } else { | |
539 | len = snprintf(str, sizeof(str), "%lu", (unsigned long)availrmem); | |
540 | if (*ppos >= len) | |
541 | rc = 0; | |
542 | else | |
543 | rc = proc_copyout_string(buffer, *lenp, str + *ppos, "\n"); | |
544 | ||
545 | if (rc >= 0) { | |
546 | *lenp = rc; | |
547 | *ppos += rc; | |
548 | } | |
549 | } | |
550 | ||
551 | RETURN(rc); | |
552 | } | |
553 | ||
554 | static int | |
555 | proc_dofreemem(struct ctl_table *table, int write, struct file *filp, | |
556 | void __user *buffer, size_t *lenp, loff_t *ppos) | |
557 | { | |
558 | int len, rc = 0; | |
559 | char str[32]; | |
560 | ENTRY; | |
561 | ||
562 | if (write) { | |
563 | *ppos += *lenp; | |
564 | } else { | |
565 | len = snprintf(str, sizeof(str), "%lu", (unsigned long)freemem); | |
566 | if (*ppos >= len) | |
567 | rc = 0; | |
568 | else | |
569 | rc = proc_copyout_string(buffer, *lenp, str + *ppos, "\n"); | |
570 | ||
571 | if (rc >= 0) { | |
572 | *lenp = rc; | |
573 | *ppos += rc; | |
574 | } | |
575 | } | |
576 | ||
577 | RETURN(rc); | |
578 | } | |
579 | ||
ff449ac4 | 580 | #ifdef DEBUG_KMEM |
581 | static void | |
582 | slab_seq_show_headers(struct seq_file *f) | |
583 | { | |
584 | seq_printf(f, "%-36s\n", "name"); | |
585 | } | |
586 | ||
587 | static int | |
588 | slab_seq_show(struct seq_file *f, void *p) | |
589 | { | |
590 | spl_kmem_cache_t *skc = p; | |
591 | ||
592 | ASSERT(skc->skc_magic == SKC_MAGIC); | |
593 | ||
594 | spin_lock(&skc->skc_lock); | |
595 | seq_printf(f, "%-36s ", skc->skc_name); | |
a1502d76 | 596 | seq_printf(f, "%u %u %u - %lu %lu %lu - %lu %lu %lu - %lu %lu %lu\n", |
ff449ac4 | 597 | (unsigned)skc->skc_obj_size, |
a1502d76 | 598 | (unsigned)skc->skc_slab_objs, |
ff449ac4 | 599 | (unsigned)skc->skc_slab_size, |
ff449ac4 | 600 | (long unsigned)skc->skc_slab_fail, |
601 | (long unsigned)skc->skc_slab_create, | |
602 | (long unsigned)skc->skc_slab_destroy, | |
603 | (long unsigned)skc->skc_slab_total, | |
604 | (long unsigned)skc->skc_slab_alloc, | |
605 | (long unsigned)skc->skc_slab_max, | |
606 | (long unsigned)skc->skc_obj_total, | |
607 | (long unsigned)skc->skc_obj_alloc, | |
a1502d76 | 608 | (long unsigned)skc->skc_obj_max); |
ff449ac4 | 609 | |
610 | spin_unlock(&skc->skc_lock); | |
611 | ||
612 | return 0; | |
613 | } | |
614 | ||
615 | static void * | |
616 | slab_seq_start(struct seq_file *f, loff_t *pos) | |
617 | { | |
618 | struct list_head *p; | |
619 | loff_t n = *pos; | |
620 | ENTRY; | |
621 | ||
622 | down_read(&spl_kmem_cache_sem); | |
623 | if (!n) | |
624 | slab_seq_show_headers(f); | |
625 | ||
626 | p = spl_kmem_cache_list.next; | |
627 | while (n--) { | |
628 | p = p->next; | |
629 | if (p == &spl_kmem_cache_list) | |
630 | RETURN(NULL); | |
631 | } | |
632 | ||
633 | RETURN(list_entry(p, spl_kmem_cache_t, skc_list)); | |
634 | } | |
635 | ||
636 | static void * | |
637 | slab_seq_next(struct seq_file *f, void *p, loff_t *pos) | |
638 | { | |
639 | spl_kmem_cache_t *skc = p; | |
640 | ENTRY; | |
641 | ||
642 | ++*pos; | |
643 | RETURN((skc->skc_list.next == &spl_kmem_cache_list) ? | |
644 | NULL : list_entry(skc->skc_list.next, spl_kmem_cache_t, skc_list)); | |
645 | } | |
646 | ||
647 | static void | |
648 | slab_seq_stop(struct seq_file *f, void *v) | |
649 | { | |
650 | up_read(&spl_kmem_cache_sem); | |
651 | } | |
652 | ||
653 | static struct seq_operations slab_seq_ops = { | |
654 | .show = slab_seq_show, | |
655 | .start = slab_seq_start, | |
656 | .next = slab_seq_next, | |
657 | .stop = slab_seq_stop, | |
658 | }; | |
659 | ||
660 | static int | |
661 | proc_slab_open(struct inode *inode, struct file *filp) | |
662 | { | |
663 | return seq_open(filp, &slab_seq_ops); | |
664 | } | |
665 | ||
666 | static struct file_operations proc_slab_operations = { | |
667 | .open = proc_slab_open, | |
668 | .read = seq_read, | |
669 | .llseek = seq_lseek, | |
670 | .release = seq_release, | |
671 | }; | |
672 | #endif /* DEBUG_KMEM */ | |
673 | ||
9ab1ac14 | 674 | static struct ctl_table spl_debug_table[] = { |
57d1b188 | 675 | { |
676 | .ctl_name = CTL_DEBUG_SUBSYS, | |
9ab1ac14 | 677 | .procname = "subsystem", |
57d1b188 | 678 | .data = &spl_debug_subsys, |
679 | .maxlen = sizeof(unsigned long), | |
680 | .mode = 0644, | |
681 | .proc_handler = &proc_dobitmasks | |
682 | }, | |
683 | { | |
684 | .ctl_name = CTL_DEBUG_MASK, | |
9ab1ac14 | 685 | .procname = "mask", |
57d1b188 | 686 | .data = &spl_debug_mask, |
687 | .maxlen = sizeof(unsigned long), | |
688 | .mode = 0644, | |
689 | .proc_handler = &proc_dobitmasks | |
690 | }, | |
691 | { | |
692 | .ctl_name = CTL_DEBUG_PRINTK, | |
9ab1ac14 | 693 | .procname = "printk", |
57d1b188 | 694 | .data = &spl_debug_printk, |
695 | .maxlen = sizeof(unsigned long), | |
696 | .mode = 0644, | |
697 | .proc_handler = &proc_dobitmasks | |
698 | }, | |
699 | { | |
700 | .ctl_name = CTL_DEBUG_MB, | |
9ab1ac14 | 701 | .procname = "mb", |
57d1b188 | 702 | .mode = 0644, |
703 | .proc_handler = &proc_debug_mb, | |
704 | }, | |
705 | { | |
706 | .ctl_name = CTL_DEBUG_BINARY, | |
9ab1ac14 | 707 | .procname = "binary", |
57d1b188 | 708 | .data = &spl_debug_binary, |
709 | .maxlen = sizeof(int), | |
710 | .mode = 0644, | |
711 | .proc_handler = &proc_dointvec, | |
712 | }, | |
713 | { | |
714 | .ctl_name = CTL_DEBUG_CATASTROPHE, | |
715 | .procname = "catastrophe", | |
716 | .data = &spl_debug_catastrophe, | |
717 | .maxlen = sizeof(int), | |
718 | .mode = 0444, | |
719 | .proc_handler = &proc_dointvec, | |
720 | }, | |
721 | { | |
722 | .ctl_name = CTL_DEBUG_PANIC_ON_BUG, | |
723 | .procname = "panic_on_bug", | |
724 | .data = &spl_debug_panic_on_bug, | |
725 | .maxlen = sizeof(int), | |
726 | .mode = 0644, | |
727 | .proc_handler = &proc_dointvec | |
728 | }, | |
729 | { | |
730 | .ctl_name = CTL_DEBUG_PATH, | |
9ab1ac14 | 731 | .procname = "path", |
57d1b188 | 732 | .data = spl_debug_file_path, |
733 | .maxlen = sizeof(spl_debug_file_path), | |
734 | .mode = 0644, | |
735 | .proc_handler = &proc_dostring, | |
736 | }, | |
737 | { | |
738 | .ctl_name = CTL_DEBUG_DUMP, | |
9ab1ac14 | 739 | .procname = "dump", |
57d1b188 | 740 | .mode = 0200, |
741 | .proc_handler = &proc_dump_kernel, | |
742 | }, | |
743 | { .ctl_name = CTL_DEBUG_FORCE_BUG, | |
744 | .procname = "force_bug", | |
745 | .mode = 0200, | |
746 | .proc_handler = &proc_force_bug, | |
747 | }, | |
748 | { | |
749 | .ctl_name = CTL_CONSOLE_RATELIMIT, | |
750 | .procname = "console_ratelimit", | |
751 | .data = &spl_console_ratelimit, | |
752 | .maxlen = sizeof(int), | |
753 | .mode = 0644, | |
754 | .proc_handler = &proc_dointvec, | |
755 | }, | |
756 | { | |
757 | .ctl_name = CTL_CONSOLE_MAX_DELAY_CS, | |
758 | .procname = "console_max_delay_centisecs", | |
759 | .maxlen = sizeof(int), | |
760 | .mode = 0644, | |
761 | .proc_handler = &proc_console_max_delay_cs, | |
762 | }, | |
763 | { | |
764 | .ctl_name = CTL_CONSOLE_MIN_DELAY_CS, | |
765 | .procname = "console_min_delay_centisecs", | |
766 | .maxlen = sizeof(int), | |
767 | .mode = 0644, | |
768 | .proc_handler = &proc_console_min_delay_cs, | |
769 | }, | |
770 | { | |
771 | .ctl_name = CTL_CONSOLE_BACKOFF, | |
772 | .procname = "console_backoff", | |
773 | .maxlen = sizeof(int), | |
774 | .mode = 0644, | |
775 | .proc_handler = &proc_console_backoff, | |
776 | }, | |
777 | { | |
9ab1ac14 | 778 | .ctl_name = CTL_DEBUG_STACK_SIZE, |
57d1b188 | 779 | .procname = "stack_max", |
780 | .data = &spl_debug_stack, | |
781 | .maxlen = sizeof(int), | |
782 | .mode = 0444, | |
783 | .proc_handler = &proc_dointvec, | |
784 | }, | |
9ab1ac14 | 785 | {0}, |
786 | }; | |
787 | ||
36b313da BB |
788 | static struct ctl_table spl_vm_table[] = { |
789 | { | |
790 | .ctl_name = CTL_VM_MINFREE, | |
791 | .procname = "minfree", | |
792 | .data = &minfree, | |
793 | .maxlen = sizeof(int), | |
794 | .mode = 0644, | |
795 | .proc_handler = &proc_dointvec, | |
796 | }, | |
797 | { | |
798 | .ctl_name = CTL_VM_DESFREE, | |
799 | .procname = "desfree", | |
800 | .data = &desfree, | |
801 | .maxlen = sizeof(int), | |
802 | .mode = 0644, | |
803 | .proc_handler = &proc_dointvec, | |
804 | }, | |
805 | { | |
806 | .ctl_name = CTL_VM_LOTSFREE, | |
807 | .procname = "lotsfree", | |
808 | .data = &lotsfree, | |
809 | .maxlen = sizeof(int), | |
810 | .mode = 0644, | |
811 | .proc_handler = &proc_dointvec, | |
812 | }, | |
813 | { | |
814 | .ctl_name = CTL_VM_NEEDFREE, | |
815 | .procname = "needfree", | |
816 | .data = &needfree, | |
817 | .maxlen = sizeof(int), | |
818 | .mode = 0444, | |
819 | .proc_handler = &proc_dointvec, | |
820 | }, | |
821 | { | |
822 | .ctl_name = CTL_VM_SWAPFS_MINFREE, | |
823 | .procname = "swapfs_minfree", | |
824 | .data = &swapfs_minfree, | |
825 | .maxlen = sizeof(int), | |
826 | .mode = 0644, | |
827 | .proc_handler = &proc_dointvec, | |
828 | }, | |
36b313da BB |
829 | { |
830 | .ctl_name = CTL_VM_SWAPFS_RESERVE, | |
831 | .procname = "swapfs_reserve", | |
832 | .data = &swapfs_reserve, | |
833 | .maxlen = sizeof(int), | |
834 | .mode = 0644, | |
835 | .proc_handler = &proc_dointvec, | |
836 | }, | |
837 | { | |
838 | .ctl_name = CTL_VM_AVAILRMEM, | |
839 | .procname = "availrmem", | |
4ab13d3b BB |
840 | .mode = 0444, |
841 | .proc_handler = &proc_doavailrmem, | |
842 | }, | |
843 | { | |
844 | .ctl_name = CTL_VM_FREEMEM, | |
845 | .procname = "freemem", | |
846 | .data = (void *)2, | |
847 | .maxlen = sizeof(int), | |
848 | .mode = 0444, | |
849 | .proc_handler = &proc_dofreemem, | |
850 | }, | |
851 | { | |
852 | .ctl_name = CTL_VM_PHYSMEM, | |
853 | .procname = "physmem", | |
854 | .data = &physmem, | |
36b313da BB |
855 | .maxlen = sizeof(int), |
856 | .mode = 0444, | |
857 | .proc_handler = &proc_dointvec, | |
858 | }, | |
859 | {0}, | |
860 | }; | |
861 | ||
57d1b188 | 862 | #ifdef DEBUG_KMEM |
9ab1ac14 | 863 | static struct ctl_table spl_kmem_table[] = { |
57d1b188 | 864 | { |
865 | .ctl_name = CTL_KMEM_KMEMUSED, | |
866 | .procname = "kmem_used", | |
867 | .data = &kmem_alloc_used, | |
868 | .maxlen = sizeof(atomic64_t), | |
869 | .mode = 0444, | |
870 | .proc_handler = &proc_doatomic64, | |
871 | }, | |
872 | { | |
873 | .ctl_name = CTL_KMEM_KMEMMAX, | |
874 | .procname = "kmem_max", | |
875 | .data = &kmem_alloc_max, | |
876 | .maxlen = sizeof(unsigned long), | |
877 | .extra1 = &table_min, | |
878 | .extra2 = &table_max, | |
879 | .mode = 0444, | |
880 | .proc_handler = &proc_doulongvec_minmax, | |
881 | }, | |
882 | { | |
883 | .ctl_name = CTL_KMEM_VMEMUSED, | |
884 | .procname = "vmem_used", | |
885 | .data = &vmem_alloc_used, | |
886 | .maxlen = sizeof(atomic64_t), | |
887 | .mode = 0444, | |
888 | .proc_handler = &proc_doatomic64, | |
889 | }, | |
890 | { | |
891 | .ctl_name = CTL_KMEM_VMEMMAX, | |
892 | .procname = "vmem_max", | |
893 | .data = &vmem_alloc_max, | |
894 | .maxlen = sizeof(unsigned long), | |
895 | .extra1 = &table_min, | |
896 | .extra2 = &table_max, | |
897 | .mode = 0444, | |
898 | .proc_handler = &proc_doulongvec_minmax, | |
899 | }, | |
9ab1ac14 | 900 | {0}, |
901 | }; | |
04a479f7 | 902 | #endif /* DEBUG_KMEM */ |
903 | ||
904 | #ifdef DEBUG_KSTAT | |
905 | static struct ctl_table spl_kstat_table[] = { | |
906 | {0}, | |
907 | }; | |
908 | #endif /* DEBUG_KSTAT */ | |
9ab1ac14 | 909 | |
910 | static struct ctl_table spl_table[] = { | |
911 | /* NB No .strategy entries have been provided since | |
912 | * sysctl(8) prefers to go via /proc for portability. | |
913 | */ | |
914 | { | |
915 | .ctl_name = CTL_VERSION, | |
916 | .procname = "version", | |
917 | .data = spl_version, | |
918 | .maxlen = sizeof(spl_version), | |
919 | .mode = 0444, | |
920 | .proc_handler = &proc_dostring, | |
921 | }, | |
57d1b188 | 922 | { |
923 | .ctl_name = CTL_HOSTID, | |
924 | .procname = "hostid", | |
925 | .data = &spl_hostid, | |
926 | .maxlen = sizeof(unsigned long), | |
927 | .mode = 0644, | |
928 | .proc_handler = &proc_dohostid, | |
929 | }, | |
930 | { | |
931 | .ctl_name = CTL_HW_SERIAL, | |
932 | .procname = "hw_serial", | |
937879f1 | 933 | .data = hw_serial, |
934 | .maxlen = sizeof(hw_serial), | |
57d1b188 | 935 | .mode = 0444, |
936 | .proc_handler = &proc_dostring, | |
937 | }, | |
d1ff2312 BB |
938 | #ifndef HAVE_KALLSYMS_LOOKUP_NAME |
939 | { | |
940 | .ctl_name = CTL_KALLSYMS, | |
941 | .procname = "kallsyms_lookup_name", | |
942 | .data = &spl_kallsyms_lookup_name_fn, | |
943 | .maxlen = sizeof(unsigned long), | |
944 | .mode = 0644, | |
945 | .proc_handler = &proc_dokallsyms_lookup_name, | |
946 | }, | |
947 | #endif | |
9ab1ac14 | 948 | { |
949 | .ctl_name = CTL_SPL_DEBUG, | |
950 | .procname = "debug", | |
951 | .mode = 0555, | |
952 | .child = spl_debug_table, | |
953 | }, | |
36b313da BB |
954 | { |
955 | .ctl_name = CTL_SPL_VM, | |
956 | .procname = "vm", | |
957 | .mode = 0555, | |
958 | .child = spl_vm_table, | |
959 | }, | |
9ab1ac14 | 960 | #ifdef DEBUG_KMEM |
961 | { | |
962 | .ctl_name = CTL_SPL_KMEM, | |
963 | .procname = "kmem", | |
964 | .mode = 0555, | |
965 | .child = spl_kmem_table, | |
966 | }, | |
04a479f7 | 967 | #endif |
968 | #ifdef DEBUG_KSTAT | |
969 | { | |
970 | .ctl_name = CTL_SPL_KSTAT, | |
971 | .procname = "kstat", | |
972 | .mode = 0555, | |
973 | .child = spl_kstat_table, | |
974 | }, | |
9ab1ac14 | 975 | #endif |
57d1b188 | 976 | { 0 }, |
977 | }; | |
978 | ||
9ab1ac14 | 979 | static struct ctl_table spl_dir[] = { |
57d1b188 | 980 | { |
981 | .ctl_name = CTL_SPL, | |
982 | .procname = "spl", | |
983 | .mode = 0555, | |
984 | .child = spl_table, | |
985 | }, | |
57d86234 | 986 | { 0 } |
987 | }; | |
988 | ||
989 | static struct ctl_table spl_root[] = { | |
990 | { | |
991 | .ctl_name = CTL_KERN, | |
992 | .procname = "kernel", | |
993 | .mode = 0555, | |
994 | .child = spl_dir, | |
995 | }, | |
996 | { 0 } | |
57d1b188 | 997 | }; |
998 | ||
404992e3 | 999 | static int |
1000 | proc_dir_entry_match(int len, const char *name, struct proc_dir_entry *de) | |
1001 | { | |
1002 | if (de->namelen != len) | |
1003 | return 0; | |
1004 | ||
1005 | return !memcmp(name, de->name, len); | |
1006 | } | |
1007 | ||
04a479f7 | 1008 | struct proc_dir_entry * |
404992e3 | 1009 | proc_dir_entry_find(struct proc_dir_entry *root, const char *str) |
1010 | { | |
1011 | struct proc_dir_entry *de; | |
1012 | ||
1013 | for (de = root->subdir; de; de = de->next) | |
1014 | if (proc_dir_entry_match(strlen(str), str, de)) | |
1015 | return de; | |
1016 | ||
1017 | return NULL; | |
1018 | } | |
1019 | ||
04a479f7 | 1020 | int |
1021 | proc_dir_entries(struct proc_dir_entry *root) | |
1022 | { | |
1023 | struct proc_dir_entry *de; | |
1024 | int i = 0; | |
1025 | ||
1026 | for (de = root->subdir; de; de = de->next) | |
1027 | i++; | |
1028 | ||
1029 | return i; | |
1030 | } | |
1031 | ||
57d1b188 | 1032 | int |
1033 | proc_init(void) | |
1034 | { | |
404992e3 | 1035 | int rc = 0; |
57d1b188 | 1036 | ENTRY; |
1037 | ||
1038 | #ifdef CONFIG_SYSCTL | |
57d86234 | 1039 | spl_header = spl_register_sysctl_table(spl_root, 0); |
57d1b188 | 1040 | if (spl_header == NULL) |
1041 | RETURN(-EUNATCH); | |
c30df9c8 | 1042 | #endif /* CONFIG_SYSCTL */ |
9ab1ac14 | 1043 | |
4d54fdee | 1044 | #if defined(DEBUG_KMEM) || defined(DEBUG_KSTAT) |
c30df9c8 | 1045 | proc_spl = proc_mkdir("spl", NULL); |
1046 | if (proc_spl == NULL) | |
404992e3 | 1047 | GOTO(out, rc = -EUNATCH); |
1048 | ||
04a479f7 | 1049 | #ifdef DEBUG_KMEM |
c30df9c8 | 1050 | proc_spl_kmem = proc_mkdir("kmem", proc_spl); |
1051 | if (proc_spl_kmem == NULL) | |
1052 | GOTO(out, rc = -EUNATCH); | |
ff449ac4 | 1053 | |
1054 | proc_spl_kmem_slab = create_proc_entry("slab", 0444, proc_spl_kmem); | |
1055 | if (proc_spl_kmem_slab == NULL) | |
1056 | GOTO(out, rc = -EUNATCH); | |
1057 | ||
1058 | proc_spl_kmem_slab->proc_fops = &proc_slab_operations; | |
04a479f7 | 1059 | #endif /* DEBUG_KMEM */ |
1060 | ||
1061 | #ifdef DEBUG_KSTAT | |
c30df9c8 | 1062 | proc_spl_kstat = proc_mkdir("kstat", proc_spl); |
1063 | if (proc_spl_kstat == NULL) | |
1064 | GOTO(out, rc = -EUNATCH); | |
04a479f7 | 1065 | #endif /* DEBUG_KSTAT */ |
1066 | ||
404992e3 | 1067 | out: |
c30df9c8 | 1068 | if (rc) { |
1069 | remove_proc_entry("kstat", proc_spl); | |
ff449ac4 | 1070 | #ifdef DEBUG_KMEM |
1071 | remove_proc_entry("slab", proc_spl_kmem); | |
1072 | #endif | |
c30df9c8 | 1073 | remove_proc_entry("kmem", proc_spl); |
a02118a8 | 1074 | remove_proc_entry("spl", NULL); |
c30df9c8 | 1075 | #ifdef CONFIG_SYSCTL |
1076 | spl_unregister_sysctl_table(spl_header); | |
404992e3 | 1077 | #endif /* CONFIG_SYSCTL */ |
c30df9c8 | 1078 | } |
4d54fdee | 1079 | #endif /* DEBUG_KMEM || DEBUG_KSTAT */ |
c30df9c8 | 1080 | |
404992e3 | 1081 | RETURN(rc); |
57d1b188 | 1082 | } |
1083 | ||
1084 | void | |
1085 | proc_fini(void) | |
1086 | { | |
1087 | ENTRY; | |
1088 | ||
4d54fdee | 1089 | #if defined(DEBUG_KMEM) || defined(DEBUG_KSTAT) |
c30df9c8 | 1090 | remove_proc_entry("kstat", proc_spl); |
ff449ac4 | 1091 | #ifdef DEBUG_KMEM |
1092 | remove_proc_entry("slab", proc_spl_kmem); | |
1093 | #endif | |
c30df9c8 | 1094 | remove_proc_entry("kmem", proc_spl); |
a02118a8 | 1095 | remove_proc_entry("spl", NULL); |
4d54fdee | 1096 | #endif /* DEBUG_KMEM || DEBUG_KSTAT */ |
c30df9c8 | 1097 | |
57d1b188 | 1098 | #ifdef CONFIG_SYSCTL |
1099 | ASSERT(spl_header != NULL); | |
57d86234 | 1100 | spl_unregister_sysctl_table(spl_header); |
c30df9c8 | 1101 | #endif /* CONFIG_SYSCTL */ |
1102 | ||
57d1b188 | 1103 | EXIT; |
1104 | } |