aboutsummaryrefslogtreecommitdiffstats
path: root/mm/slab_common.c
diff options
context:
space:
mode:
authorGlauber Costa <glommer@parallels.com>2012-10-19 10:20:25 -0400
committerPekka Enberg <penberg@kernel.org>2012-10-24 02:37:41 -0400
commitb7454ad3cfc3043c5264729a6204f049fe1f34b1 (patch)
treedbfe665034b9c3f3e79fa9410038ecc6f44e61bb /mm/slab_common.c
parentddffeb8c4d0331609ef2581d84de4d763607bd37 (diff)
mm/sl[au]b: Move slabinfo processing to slab_common.c
This patch moves all the common machinery to slabinfo processing to slab_common.c. We can do better by noticing that the output is heavily common, and having the allocators to just provide finished information about this. But after this first step, this can be done easier. Signed-off-by: Glauber Costa <glommer@parallels.com> Acked-by: Christoph Lameter <cl@linux.com> CC: David Rientjes <rientjes@google.com> Signed-off-by: Pekka Enberg <penberg@kernel.org>
Diffstat (limited to 'mm/slab_common.c')
-rw-r--r--mm/slab_common.c70
1 files changed, 70 insertions, 0 deletions
diff --git a/mm/slab_common.c b/mm/slab_common.c
index 069a24e64403..2e4b4c6d89e2 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -13,6 +13,8 @@
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/cpu.h> 14#include <linux/cpu.h>
15#include <linux/uaccess.h> 15#include <linux/uaccess.h>
16#include <linux/seq_file.h>
17#include <linux/proc_fs.h>
16#include <asm/cacheflush.h> 18#include <asm/cacheflush.h>
17#include <asm/tlbflush.h> 19#include <asm/tlbflush.h>
18#include <asm/page.h> 20#include <asm/page.h>
@@ -192,3 +194,71 @@ int slab_is_available(void)
192{ 194{
193 return slab_state >= UP; 195 return slab_state >= UP;
194} 196}
197
198#ifdef CONFIG_SLABINFO
199static void *s_start(struct seq_file *m, loff_t *pos)
200{
201 loff_t n = *pos;
202
203 mutex_lock(&slab_mutex);
204 if (!n)
205 print_slabinfo_header(m);
206
207 return seq_list_start(&slab_caches, *pos);
208}
209
210static void *s_next(struct seq_file *m, void *p, loff_t *pos)
211{
212 return seq_list_next(p, &slab_caches, pos);
213}
214
215static void s_stop(struct seq_file *m, void *p)
216{
217 mutex_unlock(&slab_mutex);
218}
219
220static int s_show(struct seq_file *m, void *p)
221{
222 return slabinfo_show(m, p);
223}
224
225/*
226 * slabinfo_op - iterator that generates /proc/slabinfo
227 *
228 * Output layout:
229 * cache-name
230 * num-active-objs
231 * total-objs
232 * object size
233 * num-active-slabs
234 * total-slabs
235 * num-pages-per-slab
236 * + further values on SMP and with statistics enabled
237 */
238static const struct seq_operations slabinfo_op = {
239 .start = s_start,
240 .next = s_next,
241 .stop = s_stop,
242 .show = s_show,
243};
244
245static int slabinfo_open(struct inode *inode, struct file *file)
246{
247 return seq_open(file, &slabinfo_op);
248}
249
250static const struct file_operations proc_slabinfo_operations = {
251 .open = slabinfo_open,
252 .read = seq_read,
253 .write = slabinfo_write,
254 .llseek = seq_lseek,
255 .release = seq_release,
256};
257
258static int __init slab_proc_init(void)
259{
260 proc_create("slabinfo", S_IRUSR, NULL, &proc_slabinfo_operations);
261 return 0;
262}
263module_init(slab_proc_init);
264#endif /* CONFIG_SLABINFO */